Class AbstractEditPermissionsAdministrator
java.lang.Object
com.atlassian.confluence.impl.security.administrators.DefaultPermissionsAdministrator
com.atlassian.confluence.impl.security.administrators.AbstractEditPermissionsAdministrator
- All Implemented Interfaces:
EditPermissionsAdministrator
,PermissionsAdministrator
- Direct Known Subclasses:
EditGlobalPermissionsAdministrator
,EditSpacePermissionsAdministrator
public abstract class AbstractEditPermissionsAdministrator
extends DefaultPermissionsAdministrator
implements EditPermissionsAdministrator
Contains all the common functionality of the global and space edit permissions administrators
- Since:
- 7.17
-
Field Summary
Fields inherited from interface com.atlassian.confluence.security.administrators.EditPermissionsAdministrator
MAX_ENTRIES
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractEditPermissionsAdministrator
(SpacePermissionManager spacePermissionManager, PermissionResolver permissionResolver, SetSpacePermissionChecker setSpacePermissionChecker, ConfluenceUserResolver userResolver, GroupResolver groupResolver) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllPermissions
(Set<SpacePermission> permissionsToAdd) Adds the given set of permissions if the current user has permission to do so, otherwise does nothing silently.addGuardPermissionToGroups
(List<String> groupNames, UserAccessor userAccessor, String guardPermission) Add the guard permissions for each group if they existaddGuardPermissionToGroups
(List<String> groupNames, String guardPermission) Add the guard permissions for each group if they existaddGuardPermissionToUsers
(List<String> userNames, UserAccessor userAccessor, String guardPermission) Add the guard permissions for each user if they existaddGuardPermissionToUsers
(List<String> userNames, String guardPermission) Add the guard permissions for each user if they existvoid
applyPermissionChanges
(Collection<SpacePermission> oldPermissions, Collection<SpacePermission> newPermissions) Given the old permissions and new permissions, apply necessary permission changes to make old permissions the same as new permissionsprotected Collection<SpacePermission>
buildPermissionsFromWebForm
(Space space, Map<String, ?> formParameters, String parameterQualifier) Private implementation that doesn't check to ensure space key is nullprotected boolean
canAddPermission
(SpacePermission permission) Used by both space and global permission administrators to determine if the user can add the permission.void
denyAnonymousPermissions
(Collection<SpacePermission> currentPermissions, Set<SpacePermission> permissionsToAdd, Set<SpacePermission> permissionsToRemove) Removes all anonymous permissionsint
Returns the number of group entries that are to be added.int
Returns the number of user entries that are to be added.boolean
isGroupsToAddEmpty
(Map requestParams) Validate if the number of groups to add is empty Validation only occurs if the group add button is pressedboolean
isGroupsToAddTooLarge
(Map requestParams) Validate if the number of groups to add is greater than maximum allowed.boolean
isRemoveAllAdminPermissions
(Set<SpacePermission> permissionsToRemove) Returns if all admin permissions would be removed by the request.boolean
isUsersToAddEmpty
(Map requestParams) Validate if the number of users to add is empty Validation only occurs if the user add button is pressedboolean
isUsersToAddTooLarge
(Map requestParams) Validate if the number of users to add is greater than maximum allowed.void
removeAllPermissions
(Set<SpacePermission> permissionsToRemove) Removes the given set of permissions if the current user has permission to do so, otherwise does nothing silently.void
removePermission
(SpacePermission permissionToRemove) Removes the given permission if the current user has permission to do so, otherwise does nothing silently.void
setGroupsToAdd
(List<String> groupsToAdd) Set the groups to add from the UIvoid
setRemoteUser
(com.atlassian.user.User remoteUser) The current logged in uservoid
setUsersToAdd
(List<String> usersToAdd) Set the users to add from the UIvoid
splitPermissions
(Collection<SpacePermission> existingPermissions, Collection<SpacePermission> initialPermissions, Collection<SpacePermission> requestedPermissions, Set<SpacePermission> permissionsToAdd, Set<SpacePermission> permissionsToRemove) Determine which permissions need to be added or removed.Methods inherited from class com.atlassian.confluence.impl.security.administrators.DefaultPermissionsAdministrator
buildAnonymousPermissionRow, buildGroupPermissionTable, buildUnlicensedAuthenticatedPermissionRow, buildUserPermissionTable, getPermissions
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.confluence.security.administrators.EditPermissionsAdministrator
addPermission, buildPermissionsFromWebForm, createGroupGuardPermission, createUserGuardPermission, getAdministrativePermissionType, getInitialPermissionsFromForm, getRequestedPermissionsFromForm
Methods inherited from interface com.atlassian.confluence.security.administrators.PermissionsAdministrator
buildAnonymousPermissionRow, buildGroupPermissionTable, buildUnlicensedAuthenticatedPermissionRow, buildUserPermissionTable, getPermissions
-
Field Details
-
remoteUser
protected com.atlassian.user.User remoteUser -
PARAMETER_PREFIX
- See Also:
-
-
Constructor Details
-
AbstractEditPermissionsAdministrator
protected AbstractEditPermissionsAdministrator(SpacePermissionManager spacePermissionManager, PermissionResolver permissionResolver, SetSpacePermissionChecker setSpacePermissionChecker, ConfluenceUserResolver userResolver, GroupResolver groupResolver)
-
-
Method Details
-
isGroupsToAddTooLarge
Description copied from interface:EditPermissionsAdministrator
Validate if the number of groups to add is greater than maximum allowed. Validation only occurs if the group add button is pressed- Specified by:
isGroupsToAddTooLarge
in interfaceEditPermissionsAdministrator
- Parameters:
requestParams
- params from the request- Returns:
- true if limit is exceeded.
-
isGroupsToAddEmpty
Description copied from interface:EditPermissionsAdministrator
Validate if the number of groups to add is empty Validation only occurs if the group add button is pressed- Specified by:
isGroupsToAddEmpty
in interfaceEditPermissionsAdministrator
- Parameters:
requestParams
- params from the request- Returns:
- true if groups are empty
-
getNumOfGroupEntries
public int getNumOfGroupEntries()Description copied from interface:EditPermissionsAdministrator
Returns the number of group entries that are to be added.- Specified by:
getNumOfGroupEntries
in interfaceEditPermissionsAdministrator
- Returns:
- the number of group entries that are to be added
-
isUsersToAddTooLarge
Description copied from interface:EditPermissionsAdministrator
Validate if the number of users to add is greater than maximum allowed. Validation only occurs if the user add button is pressed- Specified by:
isUsersToAddTooLarge
in interfaceEditPermissionsAdministrator
- Parameters:
requestParams
- params from the request- Returns:
- true if limit is exceeded.
-
isUsersToAddEmpty
Description copied from interface:EditPermissionsAdministrator
Validate if the number of users to add is empty Validation only occurs if the user add button is pressed- Specified by:
isUsersToAddEmpty
in interfaceEditPermissionsAdministrator
- Parameters:
requestParams
- params from the request- Returns:
- true if users are empty
-
getNumOfUserEntries
public int getNumOfUserEntries()Description copied from interface:EditPermissionsAdministrator
Returns the number of user entries that are to be added.- Specified by:
getNumOfUserEntries
in interfaceEditPermissionsAdministrator
- Returns:
- the number of user entries that are to be added
-
splitPermissions
public void splitPermissions(Collection<SpacePermission> existingPermissions, Collection<SpacePermission> initialPermissions, Collection<SpacePermission> requestedPermissions, Set<SpacePermission> permissionsToAdd, Set<SpacePermission> permissionsToRemove) Description copied from interface:EditPermissionsAdministrator
Determine which permissions need to be added or removed. Given a collection of how permissions are now (existingPermissions) and how you wish the permissions to be (newPermissions), this will populate the collectionspermissionsToAdd
andpermissionsToRemove
with those permissions that you will need to add or remove to reach the desired state.- Specified by:
splitPermissions
in interfaceEditPermissionsAdministrator
- Parameters:
existingPermissions
- the currently existing permissionsinitialPermissions
- the permissions the user was initially shownrequestedPermissions
- the new state we want these permissions to be inpermissionsToAdd
- collection into which permissions that need adding will be placedpermissionsToRemove
- collection into which permissions that need removing will be placed
-
buildPermissionsFromWebForm
protected Collection<SpacePermission> buildPermissionsFromWebForm(Space space, Map<String, ?> formParameters, String parameterQualifier) Private implementation that doesn't check to ensure space key is null -
isRemoveAllAdminPermissions
Description copied from interface:EditPermissionsAdministrator
Returns if all admin permissions would be removed by the request.- Specified by:
isRemoveAllAdminPermissions
in interfaceEditPermissionsAdministrator
- Parameters:
permissionsToRemove
- - permissions to be removed- Returns:
- true if all admin permissions would be removed by the request
-
denyAnonymousPermissions
public void denyAnonymousPermissions(Collection<SpacePermission> currentPermissions, Set<SpacePermission> permissionsToAdd, Set<SpacePermission> permissionsToRemove) Description copied from interface:EditPermissionsAdministrator
Removes all anonymous permissions- Specified by:
denyAnonymousPermissions
in interfaceEditPermissionsAdministrator
- Parameters:
currentPermissions
- - current state of the permissionspermissionsToAdd
- - permissions to be addedpermissionsToRemove
- - permissions to be removed
-
addAllPermissions
Description copied from interface:EditPermissionsAdministrator
Adds the given set of permissions if the current user has permission to do so, otherwise does nothing silently.- Specified by:
addAllPermissions
in interfaceEditPermissionsAdministrator
- Parameters:
permissionsToAdd
- the set of permissions you want rid of.
-
removeAllPermissions
Description copied from interface:EditPermissionsAdministrator
Removes the given set of permissions if the current user has permission to do so, otherwise does nothing silently.- Specified by:
removeAllPermissions
in interfaceEditPermissionsAdministrator
- Parameters:
permissionsToRemove
- the permission you want rid of.
-
canAddPermission
Used by both space and global permission administrators to determine if the user can add the permission. The criteria to be met are: - User has the right to add the permission - permission does not exist already. - permission is a valid anonymous permission. - permission is a valid "all authenticated users" user permission.- Parameters:
permission
- permission to be added- Returns:
- true if the permission can be added.
-
removePermission
Description copied from interface:EditPermissionsAdministrator
Removes the given permission if the current user has permission to do so, otherwise does nothing silently.- Specified by:
removePermission
in interfaceEditPermissionsAdministrator
- Parameters:
permissionToRemove
- the permission you want rid of.
-
addGuardPermissionToGroups
Description copied from interface:EditPermissionsAdministrator
Add the guard permissions for each group if they exist- Specified by:
addGuardPermissionToGroups
in interfaceEditPermissionsAdministrator
- Parameters:
groupNames
- - names of the groups to be addedguardPermission
- - the name of the guard permission to add- Returns:
- false if an error occurred.
-
addGuardPermissionToUsers
Description copied from interface:EditPermissionsAdministrator
Add the guard permissions for each user if they exist- Specified by:
addGuardPermissionToUsers
in interfaceEditPermissionsAdministrator
- Parameters:
userNames
- - names of the users to be addedguardPermission
- - the name of the guard permission to add- Returns:
- false if an error occurred.
-
addGuardPermissionToUsers
public List<String> addGuardPermissionToUsers(List<String> userNames, UserAccessor userAccessor, String guardPermission) Description copied from interface:EditPermissionsAdministrator
Add the guard permissions for each user if they exist- Specified by:
addGuardPermissionToUsers
in interfaceEditPermissionsAdministrator
- Parameters:
userNames
- - names of the users to be addeduserAccessor
- - user accessorguardPermission
- - the name of the guard permission to add- Returns:
- false if an error occurred.
-
addGuardPermissionToGroups
public List<String> addGuardPermissionToGroups(List<String> groupNames, UserAccessor userAccessor, String guardPermission) Description copied from interface:EditPermissionsAdministrator
Add the guard permissions for each group if they exist- Specified by:
addGuardPermissionToGroups
in interfaceEditPermissionsAdministrator
- Parameters:
groupNames
- - names of the groups to be addeduserAccessor
- - user accessorguardPermission
- - the name of the guard permission to add- Returns:
- false if an error occurred.
-
setUsersToAdd
Set the users to add from the UI- Parameters:
usersToAdd
- a list of user names
-
setGroupsToAdd
Set the groups to add from the UI- Parameters:
groupsToAdd
- a list of group names
-
setRemoteUser
public void setRemoteUser(com.atlassian.user.User remoteUser) The current logged in user- Parameters:
remoteUser
- current logged in user
-
applyPermissionChanges
public void applyPermissionChanges(Collection<SpacePermission> oldPermissions, Collection<SpacePermission> newPermissions) throws IllegalArgumentException Description copied from interface:EditPermissionsAdministrator
Given the old permissions and new permissions, apply necessary permission changes to make old permissions the same as new permissions- Specified by:
applyPermissionChanges
in interfaceEditPermissionsAdministrator
- Parameters:
oldPermissions
- - initial permissionsnewPermissions
- - expected permissions- Throws:
IllegalArgumentException
-