com.atlassian.confluence.security
Class DefaultSpacePermissionManager

java.lang.Object
  extended bycom.atlassian.confluence.security.AbstractSpacePermissionManager
      extended bycom.atlassian.confluence.security.DefaultSpacePermissionManager
All Implemented Interfaces:
SpacePermissionManager
Direct Known Subclasses:
CachingSpacePermissionManager

public class DefaultSpacePermissionManager
extends AbstractSpacePermissionManager


Field Summary
protected static org.apache.log4j.Category log
           
 
Fields inherited from class com.atlassian.confluence.security.AbstractSpacePermissionManager
spacePermissionDao
 
Constructor Summary
DefaultSpacePermissionManager()
           
 
Method Summary
 void createInitialSpacePermissions(Space space, User creator)
           
 void flushCaches()
           
 List getAllPermissionsForGroup(String group)
           
 List getGlobalPermissions()
           
 List getGlobalPermissions(String permissionType)
           
 Map getGroupsForPermissionType(String permissionType, Space space)
          returns a map with groupName --> Group permissionId
 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 hasPermission(List permissionTypes, Space space, User user)
          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, User remoteUser)
          Determines if remoteUser has the given permission in space
protected  boolean hasPermissionInDao(SpacePermission permission)
          Determines if permission exists in the SpacePermissionDao
 void removeAllPermissions(Space space)
          Removes all permissions belonging to space
 void removeAllPermissionsForGroup(String group)
           
 void removeAllUserPermissions(String username)
          Remove all permissions that directly relate to this username.
 void removePermission(SpacePermission permission)
           
protected  void removePermissionFromDao(SpacePermission realPermission)
          Removes the permission from the data store

This may be overridden to provide caching, where applicable

 void savePermission(SpacePermission permission)
           
protected  void savePermissionToDao(SpacePermission permission)
          Saves the permission to the data store

This may be overridden to provide caching, where applicable.

 
Methods inherited from class com.atlassian.confluence.security.AbstractSpacePermissionManager
fixPermissions, getUserAccessor, hasPermissionForSpace, setSpacePermissionDao, setUserAccessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Category log
Constructor Detail

DefaultSpacePermissionManager

public DefaultSpacePermissionManager()
Method Detail

flushCaches

public void flushCaches()

savePermission

public void savePermission(SpacePermission permission)

removePermission

public void removePermission(SpacePermission permission)

hasPermission

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

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,
                             User user)
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.

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

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.

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

getGlobalPermissions

public List getGlobalPermissions()

getGlobalPermissions

public List getGlobalPermissions(String permissionType)

removeAllUserPermissions

public void removeAllUserPermissions(String username)
Remove all permissions that directly relate to this username. This is necessary for deactivating a user. Global and group permissions should remain unaffected.

Parameters:
username - the username of the user whose permissions are being removed.

removeAllPermissionsForGroup

public void removeAllPermissionsForGroup(String group)

getAllPermissionsForGroup

public List getAllPermissionsForGroup(String group)

removeAllPermissions

public void removeAllPermissions(Space space)
Description copied from interface: SpacePermissionManager
Removes all permissions belonging to space

Parameters:
space - The space to remove the permissions for

createInitialSpacePermissions

public void createInitialSpacePermissions(Space space,
                                          User creator)

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

Parameters:
space -
Returns:
Collection of User objects

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.

Parameters:
space -
Returns:
Collection of groups with permissions

getUsersForPermissionType

public Map getUsersForPermissionType(String permissionType,
                                     Space space)

getGroupsForPermissionType

public Map getGroupsForPermissionType(String permissionType,
                                      Space space)
returns a map with groupName --> Group permissionId

Parameters:
permissionType -

hasPermissionInDao

protected boolean hasPermissionInDao(SpacePermission permission)
Determines if permission exists in the SpacePermissionDao

Parameters:
permission - The SpacePermission object to look up
Returns:
true if present, false otherwise

savePermissionToDao

protected void savePermissionToDao(SpacePermission permission)
Saves the permission to the data store

This may be overridden to provide caching, where applicable.

Parameters:
permission - the SpacePermission to be saved

removePermissionFromDao

protected void removePermissionFromDao(SpacePermission realPermission)
Removes the permission from the data store

This may be overridden to provide caching, where applicable

Parameters:
realPermission - the SpacePermission to be removed


Confluence is developed by Atlassian.