com.atlassian.confluence.security
Class MockPermissionManager

java.lang.Object
  extended by com.atlassian.confluence.security.MockPermissionManager
All Implemented Interfaces:
PermissionManager

public class MockPermissionManager
extends Object
implements PermissionManager

The intention of of this mock is to have an implementation of the permission manager that always returns true for all permissions checks. Written for tests.


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
MockPermissionManager()
           
 
Method Summary
 List getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator objects, int maxResults)
          Filter an iterator based on which entities in the list have a particular permission.
 List getPermittedEntities(com.atlassian.user.User user, Permission permission, Iterator objects, int maxResults, Collection otherCriteria)
          Filter an iterator based on which entities in the list have a particular permission.
 List getPermittedEntities(com.atlassian.user.User user, Permission permission, List 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockPermissionManager

public MockPermissionManager()
Method Detail

hasPermission

public boolean hasPermission(com.atlassian.user.User user,
                             Permission permission,
                             Object target)
Description copied from interface: PermissionManager
Determine whether a user has a particular permission against a given target.

Specified by:
hasPermission in interface PermissionManager
Parameters:
user - the user seeking permission, or null if the anonymous user is being checked against
permission - the permission to check
target - 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

hasPermissionNoExemptions

public boolean hasPermissionNoExemptions(com.atlassian.user.User user,
                                         Permission permission,
                                         Object target)
Description copied from interface: PermissionManager
Returns true if the user has the specified permission on the target object. This method does not allow exemptions for super-users like PermissionManager.hasPermission(User, Permission, Object) does.

For parameter and return value information, see PermissionManager.hasPermission(User, Permission, Object).

Specified by:
hasPermissionNoExemptions in interface PermissionManager

hasCreatePermission

public boolean hasCreatePermission(com.atlassian.user.User user,
                                   Object container,
                                   Class typeToCreate)
Description copied from interface: PermissionManager
Determine 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.

Specified by:
hasCreatePermission in interface PermissionManager
Parameters:
user - the user seeking permission, or null if the anonymous user is being checked against
container - the target that the object is being created within. If this object is null, the method will return false
typeToCreate - the type of object being created (see above)
Returns:
true if the user has permission, false otherwise
See Also:
ContentEntityObject.getType()

getPermittedEntities

public List getPermittedEntities(com.atlassian.user.User user,
                                 Permission permission,
                                 List objects)
Description copied from interface: PermissionManager
Filter a list based on which entities in the list have a particular permission.

Specified by:
getPermittedEntities in interface PermissionManager
Parameters:
user - the user seeking permission, or null if the anonymous user is being checked against
permission - the permission to check against the objects
objects - 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 List getPermittedEntities(com.atlassian.user.User user,
                                 Permission permission,
                                 Iterator objects,
                                 int maxResults)
Description copied from interface: PermissionManager
Filter an iterator based on which entities in the list have a particular permission.

Specified by:
getPermittedEntities in interface PermissionManager
Parameters:
user - the user seeking permission, or null if the anonymous user is being checked against
permission - the permission to check against the objects
objects - the objects to check
maxResults - 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 List getPermittedEntities(com.atlassian.user.User user,
                                 Permission permission,
                                 Iterator objects,
                                 int maxResults,
                                 Collection otherCriteria)
Description copied from interface: PermissionManager
Filter 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:
getPermittedEntities in interface PermissionManager
Parameters:
user - the user seeking permission, or null if the anonymous user is being checked against
permission - the permission to check against the objects
objects - the objects to check
maxResults - 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
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: PermissionManager
Determine if the user is a Confluence administrator. Calling this method is identical to calling hasPermission(user, Permission.ADMINISTER, PermissionManager.TARGET_APPLICATION).

Specified by:
isConfluenceAdministrator in interface PermissionManager
Parameters:
user - the user to check permissions against
Returns:
true if the user is a Confluence administrator, false otherwise


Copyright © 2003-2012 Atlassian. All Rights Reserved.