Show TOC Start of Content Area

Background documentation Permissions  Locate the document in its SAP Library structure

With the IPermission interface, you can do the following:

      Check if a specific user has a specific permission – isAllowed().

      Get a list of all the permissions that can be assigned for this object – getAllPermissions().

The interface also has the helper function getPermissionTitle() for getting the display name for a specific permission.

In order to modify permissions, use the PCD API, as described in Permissions.

Checking a User’s Permission

The following code example checks whether the current user has read permission on the object with the PCD name stored in the string myObject:

IAdminBase myAdmin = (IAdminBase)iCtx.lookup(myObject);

IPermission myIview = (IPermission)
    myAdmin.getImplementation(IAdminBase.PERMISSION);

        

boolean hasPermission = myIview
    .isAllowed(request.getUser(),IPermission.PCM_ADMIN_READ);

 

if (hasPermission) {

    response.write(request.getUser().getName() + " has "
        + myIview.getPermissionTitle("Pcd.Read",request.getLocale())
            +
" permission.<br>");    

}

Permission Constants

The IPermissioninterface provides constants for checking the following permissions:

      Owner

      Read

      Write

      Read-Write

      Full Control

      Use

To check the role assigner permission, use the constant IPortalBasicRoleFactoryService.ROLE_ASSIGNMENT_PERMISSION.

Note

The PCM’s IPermission and PCD’s IPcdStandarPermissions interfaces define different sets of permissions constants. They are not interchangeable.

End of Content Area