public class CmsRoleManager extends java.lang.Object
Constructor and Description |
---|
CmsRoleManager(CmsSecurityManager securityManager)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addUserToRole(CmsObject cms,
CmsRole role,
java.lang.String username)
Adds a user to the given role.
|
void |
checkRole(CmsObject cms,
CmsRole role)
Checks if the user of this OpenCms context is a member of the given role
for the given organizational unit.
|
void |
checkRoleForResource(CmsObject cms,
CmsRole role,
java.lang.String resourceName)
Checks if the user of this OpenCms context is a member of the given role
for the given resource.
|
java.util.List<CmsGroup> |
getManageableGroups(CmsObject cms,
java.lang.String ouFqn,
boolean includeSubOus)
Returns all groups of organizational units for which the current user
has the
CmsRole.ACCOUNT_MANAGER role. |
java.util.List<CmsOrganizationalUnit> |
getManageableOrgUnits(CmsObject cms,
java.lang.String ouFqn,
boolean includeSubOus,
boolean includeWebusers)
Returns a list of those organizational units whose members can be managed by the current user.
|
java.util.List<CmsResource> |
getManageableResources(CmsObject cms,
CmsRole role)
Returns all resources of organizational units for which the current user has
the given role role.
|
java.util.List<CmsUser> |
getManageableUsers(CmsObject cms,
java.lang.String ouFqn,
boolean includeSubOus)
Returns all users of organizational units for which the current user has
the
CmsRole.ACCOUNT_MANAGER role. |
java.util.List<CmsUser> |
getManageableUsers(CmsObject cms,
java.lang.String ouFqn,
boolean includeSubOus,
boolean includeWebusers)
Returns all users of organizational units for which the current user has
the
CmsRole.ACCOUNT_MANAGER role. |
java.util.List<CmsOrganizationalUnit> |
getOrgUnitsForRole(CmsObject cms,
CmsRole role,
boolean includeSubOus)
Returns all the organizational units for which the current user has the given role.
|
java.util.Set<CmsGroup> |
getRoleGroups(CmsObject cms,
CmsRole role,
boolean directUsersOnly)
Returns the groups which constitute a given role, i.e. the set of groups such that a member of any of them
has the given role.
|
java.util.List<CmsRole> |
getRoles(CmsObject cms,
java.lang.String ouFqn,
boolean includeSubOus)
Returns all roles, in the given organizational unit.
|
java.util.List<CmsRole> |
getRolesForResource(CmsObject cms,
CmsUser user,
CmsResource resource)
Returns all roles the given user has over the given resource.
|
java.util.List<CmsRole> |
getRolesForResource(CmsObject cms,
java.lang.String userFqn,
java.lang.String resourceName)
Returns all roles the given user has over the given resource.
|
java.util.List<CmsRole> |
getRolesOfUser(CmsObject cms,
java.lang.String username,
java.lang.String ouFqn,
boolean includeChildOus,
boolean directRolesOnly,
boolean recursive)
Returns all roles the given user belongs to, in the given organizational unit.
|
java.util.List<CmsUser> |
getUsersOfRole(CmsObject cms,
CmsRole role,
boolean includeOtherOuUsers,
boolean directUsersOnly)
Returns all direct users of a given role, in the given organizational unit.
|
boolean |
hasRole(CmsObject cms,
CmsRole role)
Checks if the given context user has the given role in the given organizational unit.
|
boolean |
hasRole(CmsObject cms,
java.lang.String userName,
CmsRole role)
Checks if the given user has the given role in the given organizational unit.
|
boolean |
hasRoleForResource(CmsObject cms,
CmsRole role,
java.lang.String resourceName)
Checks if the given context user has the given role for the given resource.
|
boolean |
hasRoleForResource(CmsObject cms,
java.lang.String userName,
CmsRole role,
java.lang.String resourceName)
Checks if the given context user has the given role for the given resource.
|
void |
removeUserFromRole(CmsObject cms,
CmsRole role,
java.lang.String username)
Removes a user from a role, in the given organizational unit.
|
public CmsRoleManager(CmsSecurityManager securityManager)
securityManager
- the security managerpublic void addUserToRole(CmsObject cms, CmsRole role, java.lang.String username) throws CmsException
cms
- the opencms contextrole
- the roleusername
- the name of the user that is to be added to the roleCmsException
- if something goes wrongpublic void checkRole(CmsObject cms, CmsRole role) throws CmsRoleViolationException
The user must have the given role in at least one parent organizational unit.
cms
- the opencms contextrole
- the role to checkCmsRoleViolationException
- if the user does not have the required role permissionspublic void checkRoleForResource(CmsObject cms, CmsRole role, java.lang.String resourceName) throws CmsException, CmsRoleViolationException
The user must have the given role in at least one organizational unit to which this resource belongs.
cms
- the opencms contextrole
- the role to checkresourceName
- the name of the resource to check the role forCmsRoleViolationException
- if the user does not have the required role permissionsCmsException
- if something goes wrong, while reading the resourcepublic java.util.List<CmsGroup> getManageableGroups(CmsObject cms, java.lang.String ouFqn, boolean includeSubOus) throws CmsException
CmsRole.ACCOUNT_MANAGER
role.cms
- the current cms contextouFqn
- the fully qualified name of the organizational unitincludeSubOus
- if sub organizational units should be included in the searchCmsGroup
objectsCmsException
- if something goes wrongpublic java.util.List<CmsOrganizationalUnit> getManageableOrgUnits(CmsObject cms, java.lang.String ouFqn, boolean includeSubOus, boolean includeWebusers) throws CmsException
cms
- the current CMS contextouFqn
- the fully qualified name of the organizational unitincludeSubOus
- if sub organizational units should be included in the searchincludeWebusers
- if webuser organizational units should be included in the searchCmsException
- if something goes wrongpublic java.util.List<CmsResource> getManageableResources(CmsObject cms, CmsRole role) throws CmsException
cms
- the current cms contextrole
- the role to checkCmsResource
objectsCmsException
- if something goes wrongpublic java.util.List<CmsUser> getManageableUsers(CmsObject cms, java.lang.String ouFqn, boolean includeSubOus) throws CmsException
CmsRole.ACCOUNT_MANAGER
role.cms
- the current cms contextouFqn
- the fully qualified name of the organizational unitincludeSubOus
- if sub organizational units should be included in the searchCmsUser
objectsCmsException
- if something goes wrongpublic java.util.List<CmsUser> getManageableUsers(CmsObject cms, java.lang.String ouFqn, boolean includeSubOus, boolean includeWebusers) throws CmsException
CmsRole.ACCOUNT_MANAGER
role.cms
- the current cms contextouFqn
- the fully qualified name of the organizational unitincludeSubOus
- if sub organizational units should be included in the searchincludeWebusers
- if webuser organizational units should be included in the searchCmsUser
objectsCmsException
- if something goes wrongpublic java.util.List<CmsOrganizationalUnit> getOrgUnitsForRole(CmsObject cms, CmsRole role, boolean includeSubOus) throws CmsException
cms
- the current cms contextrole
- the role to checkincludeSubOus
- if sub organizational units should be included in the searchCmsOrganizationalUnit
objectsCmsException
- if something goes wrongpublic java.util.Set<CmsGroup> getRoleGroups(CmsObject cms, CmsRole role, boolean directUsersOnly) throws CmsException
cms
- the CMS contextrole
- the roledirectUsersOnly
- if true, only the role's direct group will be returnedCmsException
- if something goes wrongpublic java.util.List<CmsRole> getRoles(CmsObject cms, java.lang.String ouFqn, boolean includeSubOus) throws CmsException
cms
- the opencms contextouFqn
- the fully qualified name of the organizational unit of the roleincludeSubOus
- include roles of child organizational unitsCmsRole
objectsCmsException
- if operation was not successfulpublic java.util.List<CmsRole> getRolesForResource(CmsObject cms, CmsUser user, CmsResource resource) throws CmsException
cms
- the current cms contextuser
- the userresource
- the resourceCmsRole
objectsCmsException
- if something goes wrongpublic java.util.List<CmsRole> getRolesForResource(CmsObject cms, java.lang.String userFqn, java.lang.String resourceName) throws CmsException
cms
- the current cms contextuserFqn
- the user name to checkresourceName
- the resource nameCmsRole
objectsCmsException
- if something goes wrongpublic java.util.List<CmsRole> getRolesOfUser(CmsObject cms, java.lang.String username, java.lang.String ouFqn, boolean includeChildOus, boolean directRolesOnly, boolean recursive) throws CmsException
cms
- the opencms contextusername
- the name of the user to get all roles forouFqn
- the fully qualified name of the organizational unit to restrict the search toincludeChildOus
- include roles of child organizational unitsdirectRolesOnly
- if set only the direct assigned roles will be returned, if not also indirect rolesrecursive
- if this is set, also roles of higher organizational unit are consideredCmsRole
objectsCmsException
- if operation was not successfulpublic java.util.List<CmsUser> getUsersOfRole(CmsObject cms, CmsRole role, boolean includeOtherOuUsers, boolean directUsersOnly) throws CmsException
Users that are "indirectly" in the role are not returned in the result.
cms
- the opencms contextrole
- the role to get all users forincludeOtherOuUsers
- include users of other organizational unitsdirectUsersOnly
- if set only the direct assigned users will be returned,
if not also indirect users, ie. members of child groupsCmsUser
objects in the groupCmsException
- if operation was not successfulpublic boolean hasRole(CmsObject cms, CmsRole role)
cms
- the opencms contextrole
- the role to checktrue
if the given context user has the given role in the given organizational unitpublic boolean hasRole(CmsObject cms, java.lang.String userName, CmsRole role)
cms
- the opencms contextuserName
- the name of the user to check the role forrole
- the role to checktrue
if the given user has the given role in the given organizational unitpublic boolean hasRoleForResource(CmsObject cms, CmsRole role, java.lang.String resourceName)
cms
- the opencms contextrole
- the role to checkresourceName
- the name of the resource to checktrue
if the given context user has the given role for the given resourcepublic boolean hasRoleForResource(CmsObject cms, java.lang.String userName, CmsRole role, java.lang.String resourceName)
cms
- the opencms contextuserName
- the name of the user to check the role forrole
- the role to checkresourceName
- the name of the resource to checktrue
if the given context user has the given role for the given resourcepublic void removeUserFromRole(CmsObject cms, CmsRole role, java.lang.String username) throws CmsException
cms
- the opencms contextrole
- the role to remove the user fromusername
- the name of the user that is to be removed from the groupCmsException
- if operation was not successful