I am writing JSR286 portlet and want to modify access control of some portal resources from this portlet itself. Hence, I want to know how can I get the instance of com.ibm.portal.ac.RoleDataProvider interface?
Hi Mohammad,
I just did a quick search and I found:
https://opensource.hcltechsw.com/digital-experience/CF214/extend_dx/apis/portal_access_control_interfaces/wpspacspi/
which provides the following sample code:
Identifiable resource = ... ; // some resource, for example a portlet Principal bob = ... ; // some principal, for example Bob Context ctx = new InitialContext(); AccessControlHome home = (AccessControlHome) ctx.lookup(AccessControlHome.JNDI_NAME); AccessControlEnvironment environment = home.getAccessControlEnvironment(); Permission permission = environment.getPermission(resource, RoleType.USER); AccessControlGlobalRuntimeModel globalModel = home.getAccessControlGlobalRuntimeModel(); isAllowed = globalModel.hasPermission(bob, permission);
To show up in how to get the AccessControlEnvironment object. I assume you can get similar back the com.ibm.portal.ac.RoleDataProvider, because that interface is mentioned on the same product-page.
I hope that helps
thanks, Thorsten