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
-
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;
}
}
-
Use your Java SDK to compile the file into a Java class, for example,
com.sampleclass.RoleMembershipHandlerImpl.class.
-
Save the Java class file to a location that can be accessed by your Content Platform Engine
server.
-
In the Administration Console for Content Platform Engine, open the object store where you want
to add the Dynamic Role.
-
Navigate to , and right-click Code Modules.
-
Click Actions, and click New Document.
-
On the Define New Document Object panel, provide a title, click
Select Class as Code Module, and click Next.
-
Click Add, browse to the Java class file that you created, and click
Add Content Element.
-
Click Next to accept the default values in the rest of the wizard, then
click Finish.
-
In the Object Store view, navigate to and expand Events, Actions,
Processes, then right-click Role Membership Actions and click
New.
-
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.
-
Click Configure code module, then click
Next.
-
Click Load Existing, select the code module that you just created, and
click OK.
-
Click Next and Finish.
-
In the Object Store view, navigate to .
-
Right-click Dynamic Role and click New.
-
Provide a name and other details for your new Dynamic Role class.
-
Select the Role Membership Action that you just created.
-
Click Next and Finish.
-
In the Object Store view, navigate to .
-
Right-click Dynamic Roles, click New, and create the dynamic role by
using the class that you just created.