com.atlassian.confluence.security
Class DefaultSpacePermissionManager

java.lang.Object
  extended by com.atlassian.confluence.security.AbstractSpacePermissionManager
      extended by com.atlassian.confluence.security.DefaultSpacePermissionManager
All Implemented Interfaces:
SpacePermissionManager, SpacePermissionSaver
Direct Known Subclasses:
CachingSpacePermissionManager

public class DefaultSpacePermissionManager
extends AbstractSpacePermissionManager


Field Summary
 
Fields inherited from class com.atlassian.confluence.security.AbstractSpacePermissionManager
spacePermissionDao
 
Constructor Summary
protected DefaultSpacePermissionManager(SpacePermissionDao spacePermissionDao, PermissionCheckExemptions permissionCheckExemptions, SpacePermissionDefaultsStoreFactory spacePermissionDefaultsStoreFactory)
           
 
Method Summary
protected  boolean canUseConfluence(com.atlassian.user.User remoteUser, java.lang.String permissionCheck)
           
 void createDefaultSpacePermissions(Space space)
           
 void createInitialSpacePermissions(Space space)
          Deprecated, make it private later
 void createPrivateSpacePermissions(Space space)
           
 void flushCaches()
           
 java.util.List getAllPermissionsForGroup(java.lang.String group)
           
protected  java.util.List<SpacePermission> getAllPermissionsForUser(ConfluenceUser user)
           
 java.util.List getGlobalPermissions()
           
 java.util.List getGlobalPermissions(java.lang.String permissionType)
           
protected  java.util.Set<java.lang.String> getGroupNamesWithPermission(Space targetSpace, java.lang.String permissionType)
           
 java.util.Map getGroupsForPermissionType(java.lang.String permissionType, Space space)
           
 java.util.Collection getGroupsWithPermissions(Space space)
          Returns all groups wich have permissions in a space or on a global level.
 java.util.Map getUsersForPermissionType(java.lang.String permissionType, Space space)
           
 java.util.Collection getUsersWithPermissions(Space space)
          Returns a collection of user objects with VIEWSPACE_PERMISSION in the space.
 boolean groupHasPermission(java.lang.String permissionType, Space space, java.lang.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(java.util.List<java.lang.String> permissionTypes, Space space, com.atlassian.user.User user)
          Determines if remoteUser has all of the given permissions in space

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

 boolean hasPermission(java.util.List permissionTypes, Space space, com.atlassian.user.User user)
          Deprecated. Since 5.0. Use hasAllPermissions(java.util.List, com.atlassian.confluence.spaces.Space, com.atlassian.user.User)
 boolean hasPermission(java.lang.String permissionType, Space space, com.atlassian.user.User remoteUser)
          Determines if remoteUser has the given permission in space Unless you're writing code that is part of the permission checking implementation, or you're changing space permissions, you should be using PermissionManager instead.
 boolean permissionExists(SpacePermission permission)
          Determines if permission exists in the SpacePermissionDao
 void removeAllPermissions(Space space)
          Removes all permissions belonging to space
 void removeAllPermissionsForGroup(java.lang.String group)
           
 void removeAllUserPermissions(ConfluenceUser user)
           
 void removeAllUserPermissions(java.lang.String username)
          Deprecated. 
 void removeGlobalPermissionForUser(ConfluenceUser user, java.lang.String permissionType)
          Removes global permission of specified type that is directly associated with a user
 void removePermission(SpacePermission permission)
          Removes the specified permission.
protected  void removePermissionFromDao(SpacePermission realPermission)
          Removes the permission from the data store

This may be overridden to provide caching, where applicable

protected  void removePermissions(java.util.List permissions)
           
 void savePermission(SpacePermission permission)
          Saves the 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
getDefaultGlobalPermissions, getUserAccessor, hasPermissionForSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSpacePermissionManager

protected DefaultSpacePermissionManager(SpacePermissionDao spacePermissionDao,
                                        PermissionCheckExemptions permissionCheckExemptions,
                                        SpacePermissionDefaultsStoreFactory spacePermissionDefaultsStoreFactory)
Method Detail

flushCaches

public void flushCaches()

savePermission

public void savePermission(SpacePermission permission)
Description copied from interface: SpacePermissionSaver
Saves the permission.

Throws:
java.lang.IllegalArgumentException - if the permission is a disallowed anonymous permission (CONF-4155)

removePermission

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


hasPermission

public boolean hasPermission(java.lang.String permissionType,
                             Space space,
                             com.atlassian.user.User remoteUser)
Description copied from interface: SpacePermissionManager
Determines if remoteUser has the given permission in space Unless you're writing code that is part of the permission checking implementation, or you're changing space permissions, you should be using PermissionManager instead.

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

canUseConfluence

protected boolean canUseConfluence(com.atlassian.user.User remoteUser,
                                   java.lang.String permissionCheck)

hasPermission

public boolean hasPermission(java.util.List permissionTypes,
                             Space space,
                             com.atlassian.user.User user)
Deprecated. Since 5.0. Use hasAllPermissions(java.util.List, com.atlassian.confluence.spaces.Space, com.atlassian.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.

Unless you're writing code that is part of the permission checking implementation, or you're changing space permissions, you should be using PermissionManager instead.

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

hasAllPermissions

public boolean hasAllPermissions(java.util.List<java.lang.String> permissionTypes,
                                 Space space,
                                 com.atlassian.user.User user)
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.

Unless you're writing code that is part of the permission checking implementation, or you're changing space permissions, you should be using PermissionManager instead.

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

groupHasPermission

public boolean groupHasPermission(java.lang.String permissionType,
                                  Space space,
                                  java.lang.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:
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

getGlobalPermissions

public java.util.List getGlobalPermissions()

getGlobalPermissions

public java.util.List getGlobalPermissions(java.lang.String permissionType)

removeAllUserPermissions

public void removeAllUserPermissions(ConfluenceUser user)

removeAllUserPermissions

@Deprecated
public void removeAllUserPermissions(java.lang.String username)
Deprecated. 

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.

removeGlobalPermissionForUser

public void removeGlobalPermissionForUser(ConfluenceUser user,
                                          java.lang.String permissionType)
Description copied from interface: SpacePermissionManager
Removes global permission of specified type that is directly associated with a user

Parameters:
user - the user to look up
permissionType - the permission type to remove

removeAllPermissionsForGroup

public void removeAllPermissionsForGroup(java.lang.String group)

removePermissions

protected void removePermissions(java.util.List permissions)

getAllPermissionsForGroup

public java.util.List getAllPermissionsForGroup(java.lang.String group)

getAllPermissionsForUser

protected java.util.List<SpacePermission> getAllPermissionsForUser(ConfluenceUser user)

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)
Deprecated, make it private later

Parameters:
space -

createPrivateSpacePermissions

public void createPrivateSpacePermissions(Space space)

createDefaultSpacePermissions

public void createDefaultSpacePermissions(Space space)

getUsersWithPermissions

public java.util.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 - - space to query, if null global permissions returned
Returns:
Collection of User objects

getGroupsWithPermissions

public java.util.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 - - space to query, if null global permissions returned
Returns:
Collection of groups with permissions

getUsersForPermissionType

public java.util.Map getUsersForPermissionType(java.lang.String permissionType,
                                               Space space)

getGroupsForPermissionType

public java.util.Map getGroupsForPermissionType(java.lang.String permissionType,
                                                Space space)
Parameters:
permissionType -
space -
Returns:
a map with keys that are String groupNames and values that are Long Group permissionId. The keys in the Map are not case sensitive.

getGroupNamesWithPermission

protected java.util.Set<java.lang.String> getGroupNamesWithPermission(Space targetSpace,
                                                                      java.lang.String permissionType)

permissionExists

public boolean permissionExists(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


Copyright © 2003-2014 Atlassian. All Rights Reserved.