com.atlassian.confluence.security
Class SpacePermissionCoordinator

java.lang.Object
  extended by com.atlassian.confluence.security.SpacePermissionCoordinator
All Implemented Interfaces:
SpacePermissionManager

public class SpacePermissionCoordinator
extends Object
implements SpacePermissionManager

Space permission manager that adds a layer of security over the write operations in this class. That is, it performs permission checking via the PermissionManager and SetSpacePermissionChecker before forwarding the call to the underlying space permission manager.


Constructor Summary
SpacePermissionCoordinator()
           
 
Method Summary
 void createDefaultSpacePermissions(Space space)
           
 void createInitialSpacePermissions(Space space)
          Creates initial space permissions for the specified space.
 void createPrivateSpacePermissions(Space space)
           
 void fixPermissions()
           
 void flushCaches()
           
 List getAllPermissionsForGroup(String group)
           
 List getGlobalPermissions()
           
 List getGlobalPermissions(String permissionType)
           
 Map getGroupsForPermissionType(String permissionType, Space space)
           
 Collection getGroupsWithPermissions(Space space)
          Returns all groups wich have permissions in a space or on a global level.
 Map getUsersForPermissionType(String permissionType, Space space)
           
 Collection getUsersWithPermissions(Space space)
          Returns a collection of user objects with VIEWSPACE_PERMISSION in the space.
 boolean groupHasPermission(String permissionType, Space space, String group)
          Checks whether the given group has the given permission

If a null space is specified, this method looks up matching global permissions, otherwise space's permissions list is queried to see if the permission matches.

 boolean hasAllPermissions(List<String> permissionTypes, Space space, com.atlassian.user.User remoteUser)
          Determines if remoteUser has all of the given permissions in space

If remoteUser lacks any of the given permissions, false is returned.

 boolean hasPermission(List permissionTypes, Space space, com.atlassian.user.User remoteUser)
          Determines if remoteUser has the given permissions in space

If remoteUser lacks any of the given permissions, false is returned.

 boolean hasPermission(String permissionType, Space space, com.atlassian.user.User remoteUser)
          Determines if remoteUser has the given permission in space
 boolean hasPermissionForSpace(com.atlassian.user.User user, List permissionTypes, Space space)
           
 boolean permissionExists(SpacePermission permission)
          Check whether the given SpacePermission exists.
 void removeAllPermissions(Space space)
          Removes all SpacePermission's from the specified space.
 void removeAllPermissionsForGroup(String groupName)
          Removes all the SpacePermission's for the specified group.
 void removeAllUserPermissions(String username)
          Removes all the SpacePermission's for the specified user.
 void removePermission(SpacePermission permission)
          Removes the specified permission.
 void savePermission(SpacePermission permission)
          Saves the specified permission.
 void setGroupManager(com.atlassian.user.GroupManager groupManager)
           
 void setPermissionManager(PermissionManager permissionManager)
           
 void setSetSpacePermissionChecker(SetSpacePermissionChecker setSpacePermissionChecker)
           
 void setSpacePermissionManager(SpacePermissionManager spacePermissionManager)
           
 void setUserManager(com.atlassian.user.UserManager userManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpacePermissionCoordinator

public SpacePermissionCoordinator()
Method Detail

savePermission

public void savePermission(SpacePermission permission)
Saves the specified permission.

Specified by:
savePermission in interface SpacePermissionManager
Throws:
InsufficientPrivilegeException - if the current logged in user does not have sufficient permissions to do this. Check SetSpacePermissionChecker.canSetPermission(User, SpacePermission) first.

removeAllPermissions

public void removeAllPermissions(Space space)
Removes all SpacePermission's from the specified space.

Specified by:
removeAllPermissions in interface SpacePermissionManager
Parameters:
space - The space to remove the permissions for
Throws:
InsufficientPrivilegeException - if the current logged in user does not have sufficient permissions to do this. Check Permission.SET_PERMISSIONS on PermissionManager first.

removePermission

public void removePermission(SpacePermission permission)
Removes the specified permission.

Specified by:
removePermission in interface SpacePermissionManager
Throws:
InsufficientPrivilegeException - if the current logged in user does not have sufficient permissions to do this. Check SetSpacePermissionChecker.canSetPermission(User, SpacePermission) first.

createInitialSpacePermissions

public void createInitialSpacePermissions(Space space)
Creates initial space permissions for the specified space.

Specified by:
createInitialSpacePermissions in interface SpacePermissionManager
Throws:
InvalidOperationException - if you try to do this and you are not the creator of the specified space or not the system administrator.

createDefaultSpacePermissions

public void createDefaultSpacePermissions(Space space)
Specified by:
createDefaultSpacePermissions in interface SpacePermissionManager

createPrivateSpacePermissions

public void createPrivateSpacePermissions(Space space)
Specified by:
createPrivateSpacePermissions in interface SpacePermissionManager

removeAllUserPermissions

public void removeAllUserPermissions(String username)
Removes all the SpacePermission's for the specified user.

Specified by:
removeAllUserPermissions in interface SpacePermissionManager
Throws:
InsufficientPrivilegeException - if the current logged in user does not have sufficient permissions to do this. Check Permission.SET_PERMISSIONS using PermissionManager first.
EntityRuntimeException - if there is an error retrieving the user with the specified username

removeAllPermissionsForGroup

public void removeAllPermissionsForGroup(String groupName)
Removes all the SpacePermission's for the specified group.

Specified by:
removeAllPermissionsForGroup in interface SpacePermissionManager
Throws:
InsufficientPrivilegeException - if the current logged in user does not have sufficient permissions to do this. Check Permission.SET_PERMISSIONS using PermissionManager first.
EntityRuntimeException - if there is an error retrieving the group with the specified group name

hasPermission

public boolean hasPermission(String permissionType,
                             Space space,
                             com.atlassian.user.User remoteUser)
Description copied from interface: SpacePermissionManager
Determines if remoteUser has the given permission in space

Specified by:
hasPermission in interface SpacePermissionManager
Parameters:
permissionType - The permission type to look up
space - The space the permission applies to (can be null for global permissions)
remoteUser - The user to look up (can be null for the anonymous user)
Returns:
true if remoteUser has the permission, false otherwise

hasPermission

public boolean hasPermission(List permissionTypes,
                             Space space,
                             com.atlassian.user.User remoteUser)
Description copied from interface: SpacePermissionManager
Determines if remoteUser has the given permissions in space

If remoteUser lacks any of the given permissions, false is returned.

Specified by:
hasPermission in interface SpacePermissionManager
Parameters:
permissionTypes - A List of permission types (see SpacePermission) to check
space - The space the permissions apply to
remoteUser - The user to look up
Returns:
true if remoteUser has the permission, false otherwise

hasAllPermissions

public boolean hasAllPermissions(List<String> permissionTypes,
                                 Space space,
                                 com.atlassian.user.User remoteUser)
Description copied from interface: SpacePermissionManager
Determines if remoteUser has all of the given permissions in space

If remoteUser lacks any of the given permissions, false is returned.

Specified by:
hasAllPermissions in interface SpacePermissionManager
Parameters:
permissionTypes - A List of permission types (see SpacePermission) to check
space - The space the permissions apply to
Returns:
true if remoteUser has the permission, false otherwise

getAllPermissionsForGroup

public List getAllPermissionsForGroup(String group)
Specified by:
getAllPermissionsForGroup in interface SpacePermissionManager

getGlobalPermissions

public List getGlobalPermissions()
Specified by:
getGlobalPermissions in interface SpacePermissionManager

getGlobalPermissions

public List getGlobalPermissions(String permissionType)
Specified by:
getGlobalPermissions in interface SpacePermissionManager

fixPermissions

public void fixPermissions()
Specified by:
fixPermissions in interface SpacePermissionManager

flushCaches

public void flushCaches()
Specified by:
flushCaches in interface SpacePermissionManager

groupHasPermission

public boolean groupHasPermission(String permissionType,
                                  Space space,
                                  String group)
Description copied from interface: SpacePermissionManager
Checks whether the given group has the given permission

If a null space is specified, this method looks up matching global permissions, otherwise space's permissions list is queried to see if the permission matches.

Similarly, if permissionType is not a space permission, a matching global permission is looked up.

Specified by:
groupHasPermission in interface SpacePermissionManager
Parameters:
permissionType - The permission type to look up
space - The space the permission applies to (can be null for global permissions)
group - The group to look up the permission for
Returns:
true if the group has the required permission, false otherwise

hasPermissionForSpace

public boolean hasPermissionForSpace(com.atlassian.user.User user,
                                     List permissionTypes,
                                     Space space)
Specified by:
hasPermissionForSpace in interface SpacePermissionManager

getGroupsWithPermissions

public Collection getGroupsWithPermissions(Space space)
Description copied from interface: SpacePermissionManager
Returns all groups wich have permissions in a space or on a global level. If space is null, permissions on the global level will be checked.

Specified by:
getGroupsWithPermissions in interface SpacePermissionManager
Parameters:
space - - space to query, if null global permissions returned
Returns:
Collection of groups with permissions

getGroupsForPermissionType

public Map getGroupsForPermissionType(String permissionType,
                                      Space space)
Specified by:
getGroupsForPermissionType in interface SpacePermissionManager

getUsersWithPermissions

public Collection getUsersWithPermissions(Space space)
Description copied from interface: SpacePermissionManager
Returns a collection of user objects with VIEWSPACE_PERMISSION in the space. If no space is provided A list of users with USE_CONFLUENCE_PERMISSION will be returned

Specified by:
getUsersWithPermissions in interface SpacePermissionManager
Parameters:
space - - space to query, if null global permissions returned
Returns:
Collection of User objects

getUsersForPermissionType

public Map getUsersForPermissionType(String permissionType,
                                     Space space)
Specified by:
getUsersForPermissionType in interface SpacePermissionManager

permissionExists

public boolean permissionExists(SpacePermission permission)
Description copied from interface: SpacePermissionManager
Check whether the given SpacePermission exists. Checks by attribute equality rather than by id.

Specified by:
permissionExists in interface SpacePermissionManager
Parameters:
permission - the permission to look for.
Returns:
true if the permission is recognised by the manager as existing.

setPermissionManager

public void setPermissionManager(PermissionManager permissionManager)

setSpacePermissionManager

public void setSpacePermissionManager(SpacePermissionManager spacePermissionManager)

setSetSpacePermissionChecker

public void setSetSpacePermissionChecker(SetSpacePermissionChecker setSpacePermissionChecker)

setUserManager

public void setUserManager(com.atlassian.user.UserManager userManager)

setGroupManager

public void setGroupManager(com.atlassian.user.GroupManager groupManager)


Copyright © 2003-2013 Atlassian. All Rights Reserved.