Creating a dynamic role

A dynamic role enables custom code to make the determination of whether a given user is to be considered as a member of the role, versus that determination being made solely on the basis of a stored list of members. The custom code might, for example, consult an external database to answer the question of membership.

About this task

In this procedure, you create and compile a java class. You can use an editor and your Java SDK to create and compile the class. The rest of the steps for creating the code module, the role membership action, the dynamic role class, and the dynamic role, are completed in the Administration Console for Content Platform Engine.

Procedure

  1. Create a java file that describes the dynamic role:
    package com.sampleclass;
    
    import com.filenet.api.admin.CmRoleMembershipAction;
    import com.filenet.api.engine.AuthorizationServices;
    import com.filenet.api.engine.RoleMembershipHandler;
    import com.filenet.api.security.CmDynamicRole;
    import com.filenet.api.security.User;
    
    public class RoleMembershipHandlerImpl implements RoleMembershipHandler {
    
    	@Override
    	public boolean isUserInRole(CmRoleMembershipAction arg0,
    			CmDynamicRole arg1, User arg2, AuthorizationServices arg3) {
    			System.out.println("in RoleMembershipHandlerImpl.isUserInRole()");
    		return false;
    	}
    }
  2. Use your Java SDK to compile the file into a Java class, for example, com.sampleclass.RoleMembershipHandlerImpl.class.
  3. Save the Java class file to a location that can be accessed by your Content Platform Engine server.
  4. In the Administration Console for Content Platform Engine, open the object store where you want to add the Dynamic Role.
  5. Navigate to Browse > Root folder, and right-click Code Modules.
  6. Click Actions, and click New Document.
  7. On the Define New Document Object panel, provide a title, click Select Class as Code Module, and click Next.
  8. Click Add, browse to the Java class file that you created, and click Add Content Element.
  9. Click Next to accept the default values in the rest of the wizard, then click Finish.
  10. In the Object Store view, navigate to and expand Events, Actions, Processes, then right-click Role Membership Actions and click New.
  11. On the New Role Membership Action screen, click Class, and for the Java class handler value, enter the name of your newly created Java class, for example, com.sampleclass.RoleMembershipHandlerImpl.class.
  12. Click Configure code module, then click Next.
  13. Click Load Existing, select the code module that you just created, and click OK.
  14. Click Next and Finish.
  15. In the Object Store view, navigate to Data Design > Classes > Other Classes > Role > Dynamic Role.
  16. Right-click Dynamic Role and click New.
  17. Provide a name and other details for your new Dynamic Role class.
  18. Select the Role Membership Action that you just created.
  19. Click Next and Finish.
  20. In the Object Store view, navigate to Roles > Dynamic Roles.
  21. Right-click Dynamic Roles, click New, and create the dynamic role by using the class that you just created.