public interface PermissionManager
Modifier and Type | Interface and Description |
---|---|
static interface |
PermissionManager.Criterion
A criterion for whether an entity should be permitted or not
|
Modifier and Type | Field and Description |
---|---|
static Object |
TARGET_APPLICATION
A target that encompasses most administrative functions minus the ones covered by TARGET_SYSTEM.
|
static Object |
TARGET_PEOPLE_DIRECTORY
A target the represents the People Directory function of Confluence.
|
static Object |
TARGET_SYSTEM
A target that encompasses functions that have system impact and can compromise system security.
|
Modifier and Type | Method and 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> objects,
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> objects,
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.
|
boolean |
hasCreatePermission(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.
|
boolean |
hasCreatePermission(com.atlassian.user.User user,
Object container,
Object objectToCreate)
Determine whether a user has permission to create a particular entity within a given container.
|
boolean |
hasPermission(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.
|
boolean |
hasPermission(com.atlassian.user.User user,
Permission permission,
Object target)
Determine whether a user has a particular permission against a given target.
|
boolean |
hasPermissionNoExemptions(com.atlassian.user.User user,
Permission permission,
Object target)
Returns true if the user has the specified permission on the target object.
|
boolean |
isConfluenceAdministrator(com.atlassian.user.User user)
Determine if the user is a Confluence administrator.
|
boolean |
isSystemAdministrator(com.atlassian.user.User user)
Determine if the user is a system administrator.
|
void |
withExemption(Runnable runnable)
Execute the given task with permission exemption.
|
static final Object TARGET_APPLICATION
static final Object TARGET_SYSTEM
static final Object TARGET_PEOPLE_DIRECTORY
boolean hasPermission(com.atlassian.user.User user, Permission permission, @Nullable Object target)
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 falseIllegalStateException
- if the permission being checked against does not apply to the targetboolean hasPermission(com.atlassian.user.User user, Permission permission, Class targetType)
user
- the userpermission
- the permission to check (see Permission
targetType
- the type of the targetboolean hasPermissionNoExemptions(com.atlassian.user.User user, Permission permission, Object target)
hasPermission(User, Permission, Object)
does.
For parameter and return value information, see hasPermission(User, Permission, Object)
.boolean hasCreatePermission(com.atlassian.user.User user, Object container, Class<?> typeToCreate)
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 hasCreatePermission(com.atlassian.user.User, Object, Object)
.
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)IllegalStateException
- if the permission being checked against does not apply to the targetContentEntityObject.getType()
boolean hasCreatePermission(com.atlassian.user.User user, Object container, Object objectToCreate)
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
hasCreatePermission(com.atlassian.user.User, Object, Class)
.
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)IllegalStateException
- if the permission being checked against does not apply to the target<X> List<X> getPermittedEntities(com.atlassian.user.User user, Permission permission, List<? extends X> objects)
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<X> List<X> getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator<? extends X> objects, int maxResults)
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)<X> List<X> getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator<X> objects, int maxResults, Collection<? extends PermissionManager.Criterion> otherCriteria)
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)otherCriteria
- a collection of PermissionManager.Criterion
objects through which the permitted entities must also be filtered<X> List<X> getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, List<? extends X> objects)
getPermittedEntities(User, Permission, List)
does.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<X> List<X> getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, Iterator<? extends X> objects, int maxResults)
getPermittedEntities(User, Permission, Iterator, int)
does.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)<X> List<X> getPermittedEntitiesNoExemptions(com.atlassian.user.User user, Permission permission, Iterator<X> objects, int maxResults, Collection<? extends PermissionManager.Criterion> otherCriteria)
getPermittedEntities(User, Permission, Iterator, int, Collection)
does. You may also supply additional
criteria through which to filter the iterator.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)otherCriteria
- a collection of PermissionManager.Criterion
objects through which the permitted entities must also be filteredboolean isConfluenceAdministrator(com.atlassian.user.User user)
hasPermission(user, Permission.ADMINISTER, PermissionManager.TARGET_APPLICATION)
.user
- the user to check permissions againstboolean isSystemAdministrator(com.atlassian.user.User user)
hasPermission(user, Permission.ADMINISTER, PermissionManager.TARGET_SYSTEM)
.user
- the user to check permissions againstvoid withExemption(Runnable runnable)
Calls to:
hasPermission(com.atlassian.user.User, Permission, Object)
hasPermission(com.atlassian.user.User, Permission, Class)
hasCreatePermission(com.atlassian.user.User, Object, Object)
hasCreatePermission(com.atlassian.user.User, Object, Class)
SpacePermissionManager
and ConfluenceAccessManager
,
unless "noExemptions" variants are called.
Use with care.
runnable
- task to execute with permission exemptionCopyright © 2003–2015 Atlassian. All rights reserved.