Class DefaultPermissionManager
- java.lang.Object
-
- com.atlassian.confluence.security.DefaultPermissionManager
-
- All Implemented Interfaces:
PermissionDelegateRegistry,PermissionManager
public class DefaultPermissionManager extends Object implements PermissionManager, PermissionDelegateRegistry
Default implementation of PermissionManager. Delegates all the decision-making to a collection of delegates that handle the per-target-type permission checking.- Since:
- 2.0
- See Also:
PermissionDelegate
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.confluence.security.PermissionManager
PermissionManager.Criterion
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.security.PermissionManager
TARGET_APPLICATION, TARGET_PEOPLE_DIRECTORY, TARGET_SYSTEM
-
-
Constructor Summary
Constructors Constructor Description DefaultPermissionManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <X> List<X>getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator<? extends X> objects, int maxResults)Filter an iterator based on which entities in the list have a particular permission.<X> List<X>getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator<X> entities, int maxResults, Collection<? extends PermissionManager.Criterion> otherCriteria)Filter an iterator based on which entities in the list have a particular permission.<X> List<X>getPermittedEntities(com.atlassian.user.User user, Permission permission, List<? extends X> objects)Filter a list based on which entities in the list have a particular permission.<X> List<X>getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, Iterator<? extends X> objects, int maxResults)Filter an iterator based on which entities in the list have a particular permission.<X> List<X>getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, Iterator<X> entities, int maxResults, Collection<? extends PermissionManager.Criterion> otherCriteria)Filter an iterator based on which entities in the list have a particular permission.<X> List<X>getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, List<? extends X> objects)Filter a list based on which entities in the list have a particular permission.booleanhasCreatePermission(com.atlassian.user.User user, Object container, Class<?> typeToCreate)Determine whether a user has permission to create an entity of a particular type within a given container.booleanhasCreatePermission(com.atlassian.user.User user, Object container, Object objectToCreate)Determine whether a user has permission to create a particular entity within a given container.booleanhasMovePermission(com.atlassian.user.User user, Object source, Object target, String movePoint)Determine whether a user has permission to move a particular entity to a given target.booleanhasPermission(com.atlassian.user.User user, Permission permission, Class targetType)Determine whether a user has a particular permission for all instances of the specified target type.booleanhasPermission(com.atlassian.user.User user, Permission permission, Object target)Determine whether a user has a particular permission against a given target.booleanhasPermissionNoExemptions(com.atlassian.user.User user, Permission permission, Object target)Returns true if the user has the specified permission on the target object.booleanhasRemoveHierarchyPermission(com.atlassian.user.User user, Object target)Determine whether a user has permission to remove a particular entity and all it children.booleanisConfluenceAdministrator(com.atlassian.user.User user)Determine if the user is a Confluence administrator.booleanisSystemAdministrator(com.atlassian.user.User user)Determine if the user is a system administrator.voidregister(String key, PermissionDelegate<?> delegate)voidsetAccessModeManager(AccessModeManager accessModeManager)voidsetConfluenceAccessManager(ConfluenceAccessManager confluenceAccessManager)voidsetContentTypeManager(ContentTypeManager contentTypeManager)Deprecated.since 7.16 usesetContentTypeModuleResolver(ContentTypeModuleResolver)voidsetContentTypeModuleResolver(ContentTypeModuleResolver contentTypeModuleResolver)voidsetDelegates(Map<String,PermissionDelegate> delegates)Deprecated.since 7.15 useregister(String, PermissionDelegate)voidsetPermissionCheckExemptions(PermissionCheckExemptions permissionCheckExemptions)voidsetScopesRequestCacheDelegate(ScopesRequestCacheDelegate scopesRequestCache)voidwithExemption(Runnable runnable)Execute the given task with permission exemption.
-
-
-
Method Detail
-
hasPermission
public boolean hasPermission(com.atlassian.user.User user, Permission permission, Object target)Description copied from interface:PermissionManagerDetermine whether a user has a particular permission against a given target.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstpermission- the permission to checktarget- the object that the permission is being checked against. If this object is null, the method will return false- Returns:
- true if the user has this permission, false otherwise
-
hasPermission
public boolean hasPermission(com.atlassian.user.User user, Permission permission, Class targetType)Description copied from interface:PermissionManagerDetermine whether a user has a particular permission for all instances of the specified target type.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
user- the userpermission- the permission to check (seePermissiontargetType- the type of the target- Returns:
- true if the user has this permission, false otherwise.
-
hasPermissionNoExemptions
public boolean hasPermissionNoExemptions(com.atlassian.user.User user, Permission permission, Object target)Returns true if the user has the specified permission on the target object. Does not allow exemptions for super-users likehasPermission(User, Permission, Object)does.This implementation should become the default one once the exemption for the 'confluence-administrators' group is removed.
For parameter and return value information, see
hasPermission(User, Permission, Object).- Specified by:
hasPermissionNoExemptionsin interfacePermissionManager
-
hasCreatePermission
public boolean hasCreatePermission(com.atlassian.user.User user, Object container, Class<?> typeToCreate)Description copied from interface:PermissionManagerDetermine whether a user has permission to create an entity of a particular type within a given container.The container is the natural container of the object being created. For example, a comment is contained in a page, which is contained within a space. A space is contained within TARGET_APPLICATION.
This overload should not be used when creating CustomContentEntityObject instances. In that case, permission checks should use
PermissionManager.hasCreatePermission(com.atlassian.user.User, Object, Object).- Specified by:
hasCreatePermissionin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstcontainer- the target that the object is being created within. If this object is null, the method will return falsetypeToCreate- the type of object being created (see above)- Returns:
- true if the user has permission, false otherwise
- See Also:
ContentEntityObject.getType()
-
hasCreatePermission
public boolean hasCreatePermission(com.atlassian.user.User user, Object container, Object objectToCreate)Description copied from interface:PermissionManagerDetermine whether a user has permission to create a particular entity within a given container.The container is the natural container of the object being created. For example, a comment is contained in a page, which is contained within a space. A space is contained within TARGET_APPLICATION.
This overload is best when creating CustomContentEntityObject instances. Other permission checks should use
PermissionManager.hasCreatePermission(com.atlassian.user.User, Object, Class).- Specified by:
hasCreatePermissionin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstcontainer- the target that the object is being created within. If this object is null, the method will return falseobjectToCreate- the object being created (see above)- Returns:
- true if the user has permission, false otherwise
-
getPermittedEntities
public <X> List<X> getPermittedEntities(com.atlassian.user.User user, Permission permission, List<? extends X> objects)
Description copied from interface:PermissionManagerFilter a list based on which entities in the list have a particular permission.- Specified by:
getPermittedEntitiesin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstpermission- the permission to check against the objectsobjects- the objects to check- Returns:
- a new list of those members of the objects list that satisfy the given permission for the user
-
getPermittedEntities
public <X> List<X> getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator<? extends X> objects, int maxResults)
Description copied from interface:PermissionManagerFilter an iterator based on which entities in the list have a particular permission.- Specified by:
getPermittedEntitiesin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstpermission- the permission to check against the objectsobjects- the objects to checkmaxResults- the maximum number of permitted entities to retrieve from the iterator (un-permitted entities are not counted)- Returns:
- a new list of those members of the objects list that satisfy the given permission for the user
-
getPermittedEntities
public <X> List<X> getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator<X> entities, int maxResults, Collection<? extends PermissionManager.Criterion> otherCriteria)
Description copied from interface:PermissionManagerFilter an iterator based on which entities in the list have a particular permission. You may also supply additional criteria through which to filter the iterator.- Specified by:
getPermittedEntitiesin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstpermission- the permission to check against the objectsentities- the objects to checkmaxResults- the maximum number of permitted entities to retrieve from the iterator (un-permitted entities are not counted)otherCriteria- a collection ofPermissionManager.Criterionobjects through which the permitted entities must also be filtered- Returns:
- a new list of those members of the objects list that satisfy the given permission for the user
-
getPermittedEntitiesNoExemptions
public <X> List<X> getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, List<? extends X> objects)
Description copied from interface:PermissionManagerFilter a list based on which entities in the list have a particular permission. This method does not allow exemptions for super-users likePermissionManager.getPermittedEntities(User, Permission, List)does.- Specified by:
getPermittedEntitiesNoExemptionsin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstpermission- the permission to check against the objectsobjects- the objects to check- Returns:
- a new list of those members of the objects list that satisfy the given permission for the user
-
getPermittedEntitiesNoExemptions
public <X> List<X> getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, Iterator<? extends X> objects, int maxResults)
Description copied from interface:PermissionManagerFilter an iterator based on which entities in the list have a particular permission. This method does not allow exemptions for super-users likePermissionManager.getPermittedEntities(User, Permission, Iterator, int)does.- Specified by:
getPermittedEntitiesNoExemptionsin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstpermission- the permission to check against the objectsobjects- the objects to checkmaxResults- the maximum number of permitted entities to retrieve from the iterator (un-permitted entities are not counted)- Returns:
- a new list of those members of the objects list that satisfy the given permission for the user
-
getPermittedEntitiesNoExemptions
public <X> List<X> getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, Iterator<X> entities, int maxResults, Collection<? extends PermissionManager.Criterion> otherCriteria)
Description copied from interface:PermissionManagerFilter an iterator based on which entities in the list have a particular permission. This method does not allow exemptions for super-users likePermissionManager.getPermittedEntities(User, Permission, Iterator, int, Collection)does. You may also supply additional criteria through which to filter the iterator.- Specified by:
getPermittedEntitiesNoExemptionsin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstpermission- the permission to check against the objectsentities- the objects to checkmaxResults- the maximum number of permitted entities to retrieve from the iterator (un-permitted entities are not counted)otherCriteria- a collection ofPermissionManager.Criterionobjects through which the permitted entities must also be filtered- Returns:
- a new list of those members of the objects list that satisfy the given permission for the user
-
isConfluenceAdministrator
public boolean isConfluenceAdministrator(com.atlassian.user.User user)
Description copied from interface:PermissionManagerDetermine if the user is a Confluence administrator. Calling this method is identical to callinghasPermission(user, Permission.ADMINISTER, PermissionManager.TARGET_APPLICATION).- Specified by:
isConfluenceAdministratorin interfacePermissionManager- Parameters:
user- the user to check permissions against- Returns:
- true if the user is a Confluence administrator, false otherwise
-
isSystemAdministrator
public boolean isSystemAdministrator(com.atlassian.user.User user)
Description copied from interface:PermissionManagerDetermine if the user is a system administrator. Calling this method is identical to callinghasPermission(user, Permission.ADMINISTER, PermissionManager.TARGET_SYSTEM).- Specified by:
isSystemAdministratorin interfacePermissionManager- Parameters:
user- the user to check permissions against- Returns:
- true if the user is a system administrator, false otherwise
-
withExemption
public void withExemption(Runnable runnable)
Description copied from interface:PermissionManagerExecute the given task with permission exemption.Calls to:
PermissionManager.hasPermission(com.atlassian.user.User, Permission, Object)PermissionManager.hasPermission(com.atlassian.user.User, Permission, Class)PermissionManager.hasCreatePermission(com.atlassian.user.User, Object, Object)PermissionManager.hasCreatePermission(com.atlassian.user.User, Object, Class)
SpacePermissionManagerandConfluenceAccessManager, unless "noExemptions" variants are called.Use with care.
- Specified by:
withExemptionin interfacePermissionManager- Parameters:
runnable- task to execute with permission exemption
-
setDelegates
@Deprecated public void setDelegates(Map<String,PermissionDelegate> delegates)
Deprecated.since 7.15 useregister(String, PermissionDelegate)
-
setPermissionCheckExemptions
public void setPermissionCheckExemptions(PermissionCheckExemptions permissionCheckExemptions)
-
setContentTypeManager
@Deprecated public void setContentTypeManager(ContentTypeManager contentTypeManager)
Deprecated.since 7.16 usesetContentTypeModuleResolver(ContentTypeModuleResolver)
-
setContentTypeModuleResolver
public void setContentTypeModuleResolver(ContentTypeModuleResolver contentTypeModuleResolver)
- Since:
- 7.16
-
setConfluenceAccessManager
public void setConfluenceAccessManager(ConfluenceAccessManager confluenceAccessManager)
-
setAccessModeManager
public void setAccessModeManager(AccessModeManager accessModeManager)
-
setScopesRequestCacheDelegate
public void setScopesRequestCacheDelegate(ScopesRequestCacheDelegate scopesRequestCache)
-
hasMovePermission
public boolean hasMovePermission(com.atlassian.user.User user, Object source, Object target, String movePoint)Description copied from interface:PermissionManagerDetermine whether a user has permission to move a particular entity to a given target.The target is the natural container of the object being moved to. For example, a pages is contained in a page, which is contained within a space. A space is contained within TARGET_APPLICATION.
- Specified by:
hasMovePermissionin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againstsource- the object and all it descendants is being moved. If this object is null, the method will return falsetarget- where is the source being moved to (see above)movePoint- indicate where source node and target node relative (i.a before, after, append)- Returns:
- true if the user has permission, false otherwise
-
hasRemoveHierarchyPermission
public boolean hasRemoveHierarchyPermission(com.atlassian.user.User user, Object target)Description copied from interface:PermissionManagerDetermine whether a user has permission to remove a particular entity and all it children.The target is the natural container of the object being removed. For example, a page and all its descendants in a page, which is contained within a space.
- Specified by:
hasRemoveHierarchyPermissionin interfacePermissionManager- Parameters:
user- the user seeking permission, or null if the anonymous user is being checked againsttarget- where is the object and all its descendant are being removed- Returns:
- true if the user has permission, false otherwise
-
register
public void register(String key, PermissionDelegate<?> delegate)
- Specified by:
registerin interfacePermissionDelegateRegistry- Since:
- 7.15
-
-