public class BambooAclUpdateHelper extends Object
It converts between Acl
and AccessControlEntry
objects and a "permissionKey" which is a String
representation of a Acl
and AccessControlEntry
combination.
The "permissionKeys" are in the format: bambooPermission_TYPE_PRINCIPAL_PERMISSION
The permission configuration UI understands this format.
Modifier and Type | Field and Description |
---|---|
static String |
BAMBOO_PERMISSION_FORM_GROUP_PREFIX |
static String |
BAMBOO_PERMISSION_PREFIX |
static com.google.common.base.Joiner |
PERMISSION_KEY_JOINER |
Constructor and Description |
---|
BambooAclUpdateHelper() |
Modifier and Type | Method and Description |
---|---|
void |
addPermissionsToAclForCurrentUser(org.acegisecurity.acls.MutableAcl acl,
List<BambooPermission> permissions)
Adds the given
permissions for the currently logged in user to the acl entry. |
void |
addReadPermissionForAnonymousAndLoggedinUsers(org.acegisecurity.acls.MutableAcl acl)
Grant READ permission for Anonymous and Logged-in users.
|
List<String> |
addViewPermissionsForEditPermissions(List<String> permissionKeys)
For each of the WRITE permission keys in the list make sure there's corresponding READ permission.
|
void |
buildPermissionAndUserGroupListsFromAcl(List<String> grantedPermissions,
List<String> grantedUsers,
List<String> grantedGroups,
List<String> nonProcessedGrantedPermissions,
org.acegisecurity.acls.Acl acl,
boolean showAdminPermissions,
BambooPermissionManager bambooPermissionManager)
Helper conversion method for the permission configuration pages.
|
void |
buildUserGroupListsFromPermissions(List<String> grantedPermissions,
List<String> grantedUsers,
List<String> grantedGroups)
Given a list of granted permissions (permissionKey
String s), it will populate the grantedUsers list with
unique usernames of those users which have permissions. |
org.acegisecurity.acls.MutableAcl |
clonePermissions(com.atlassian.user.User user,
Class<? extends BambooIdProvider> permissionObject,
long id,
org.acegisecurity.acls.Acl parentAcl) |
org.acegisecurity.acls.MutableAcl |
copyProjectPermissionsToEnvironment(com.atlassian.user.User user,
Class<? extends BambooIdProvider> permissionObject,
long id,
org.acegisecurity.acls.Acl parentAcl) |
static String |
createGroupPermissionKey(String sid,
String permissionName)
Create permission key for a group permission
|
org.acegisecurity.acls.MutableAcl |
createNewDefaultAcl(com.atlassian.user.User user,
Class<? extends Plan> planType,
boolean accessForAllUsers)
Creates a default Acl for a specific plan types which has: - All permissions for the creator (user argument) of
the plan - READ permission for all logged in users - READ permission for all anonymous users
|
org.acegisecurity.acls.MutableAcl |
createNewObjectAcl(com.atlassian.user.User user,
Class<? extends BambooIdProvider> permissionObject,
long id,
boolean accessForAllUsers)
Creates a default Acl for a object which has: - EDIT permission for the creator (user argument) of the deployment
project - READ permission for all logged in users - READ permission for all anonymous users
|
static String |
createPermissionKey(org.acegisecurity.acls.sid.Sid sid,
String permissionName)
Create permission key for a permission
|
static String |
createPermissionKey(String sidType,
String authority,
String permissionName)
Create permission key for a permission
|
static String |
createRolePermissionKey(String sid,
String permissionName)
Create permission key for a role permission
|
static String |
createUserPermissionKey(String sid,
String permissionName)
Create permission key for a user permission
|
static String |
extractPrincipalFromSid(org.acegisecurity.acls.sid.Sid sid)
Extract a principal as a String from a
Sid . |
static String |
extractSidTypeFromSid(org.acegisecurity.acls.sid.Sid sid)
Extract a principal type as String from a
Sid . |
Iterable<org.acegisecurity.acls.Permission> |
getGroupPermissions(String groupName,
org.acegisecurity.acls.Acl acl,
BambooPermissionManager bambooPermissionManager,
boolean showAdminPermission)
Retrieve granted global permission of the given group Name.
|
org.acegisecurity.acls.Permission |
getPermission(String permissionKey) |
static Optional<String> |
getPermissionKeyFromAce(org.acegisecurity.acls.AccessControlEntry ace)
Given an
AccessControlEntry return a String representation. |
Map<String,List<org.acegisecurity.acls.Permission>> |
getRolePermissions(org.acegisecurity.acls.Acl acl,
BambooPermissionManager bambooPermissionManager,
boolean showAdminPermission)
Retrieve global permissions of the two known roles, logged in user and anonymous user.
|
org.acegisecurity.acls.sid.Sid |
getSidFromIdAndType(String id,
String type)
Attempt to extract
Sid from a given sid id and type. |
org.acegisecurity.acls.sid.Sid |
getSidFromPermissionKey(String permissionKey)
Get the
Sid based on a permission key. |
Iterable<org.acegisecurity.acls.Permission> |
getUserPermissions(String userName,
org.acegisecurity.acls.Acl acl,
BambooPermissionManager bambooPermissionManager,
boolean showAdminPermissions)
Retrieve granted global permission of the given user.
|
void |
modifyAclAces(org.acegisecurity.acls.MutableAcl acl,
List<String> newPermissionKeys)
Updates an
MutableAcl with new AccessControlEntry s with permissions represented by a list of
String permissionKeys. |
static String |
retrievePermissionFromACE(org.acegisecurity.acls.AccessControlEntry ace)
Deprecated.
since 5.11, use
getPermissionKeyFromAce(AccessControlEntry) |
void |
updateGroupPermissions(com.atlassian.user.Group group,
List<org.acegisecurity.acls.Permission> permissions,
BambooPermissionManager bambooPermissionManager,
HibernateMutableAclService aclService)
Update global permissions of the given group.
|
void |
updateGroupPermissions(String groupName,
List<org.acegisecurity.acls.Permission> permissions,
BambooPermissionManager bambooPermissionManager,
HibernateMutableAclService aclService,
BambooUserManager userManager,
com.atlassian.sal.api.message.I18nResolver i18nResolver) |
void |
updateGroupPermissions(String groupName,
List<org.acegisecurity.acls.Permission> permissions,
BambooPermissionManager bambooPermissionManager,
HibernateMutableAclService aclService,
BambooUserManager userManager,
com.atlassian.struts.TextProvider textProvider) |
void |
updateRolePermissions(String roleName,
List<org.acegisecurity.acls.Permission> permissions,
BambooPermissionManager permissionManager,
HibernateMutableAclService aclService,
AdministrationConfigurationAccessor administrationConfigurationAccessor,
AdministrationConfigurationPersister administrationConfigurationPersister)
Update permission of a given role.
|
void |
updateUserPermissions(String userName,
List<org.acegisecurity.acls.Permission> permissions,
BambooUserManager bambooUserManager,
BambooPermissionManager bambooPermissionManager,
HibernateMutableAclService aclService,
com.atlassian.sal.api.message.I18nResolver i18nResolver)
Update global permissions of the given user.
|
protected ErrorCollection |
validateRolePermissionUpdateRequest(String roleName,
List<org.acegisecurity.acls.Permission> permissions) |
protected ErrorCollection |
validateUpdateRequest(com.atlassian.user.Group group,
List<org.acegisecurity.acls.Permission> permissions,
BambooPermissionManager bambooPermissionManager) |
public static final String BAMBOO_PERMISSION_PREFIX
public static final String BAMBOO_PERMISSION_FORM_GROUP_PREFIX
public static com.google.common.base.Joiner PERMISSION_KEY_JOINER
public static String createUserPermissionKey(String sid, String permissionName)
public static String createGroupPermissionKey(String sid, String permissionName)
public static String createRolePermissionKey(String sid, String permissionName)
public static String createPermissionKey(@NotNull org.acegisecurity.acls.sid.Sid sid, @NotNull String permissionName)
public static String createPermissionKey(@NotNull String sidType, @NotNull String authority, @NotNull String permissionName)
public static Optional<String> getPermissionKeyFromAce(@NotNull org.acegisecurity.acls.AccessControlEntry ace)
AccessControlEntry
return a String
representation.public void buildUserGroupListsFromPermissions(List<String> grantedPermissions, List<String> grantedUsers, List<String> grantedGroups)
String
s), it will populate the grantedUsers list with
unique usernames of those users which have permissions. Likewise, it will populate the grantedGroups list with
unique group names of those groups which have permissions.@NotNull public List<String> addViewPermissionsForEditPermissions(@NotNull List<String> permissionKeys)
public Iterable<org.acegisecurity.acls.Permission> getUserPermissions(@NotNull String userName, @NotNull org.acegisecurity.acls.Acl acl, @NotNull BambooPermissionManager bambooPermissionManager, boolean showAdminPermissions)
buildPermissionAndUserGroupListsFromAcl
and filter out permissions for the user nameuserName
- name of the user to be filteredacl
- showAdminPermissions
- Permission
of the given userpublic Iterable<org.acegisecurity.acls.Permission> getGroupPermissions(@NotNull String groupName, @NotNull org.acegisecurity.acls.Acl acl, @NotNull BambooPermissionManager bambooPermissionManager, boolean showAdminPermission)
buildPermissionAndUserGroupListsFromAcl
and filter out permissions for the group namegroupName
- group name to be filteredacl
- showAdminPermission
- Permission
of the given group namepublic Map<String,List<org.acegisecurity.acls.Permission>> getRolePermissions(@NotNull org.acegisecurity.acls.Acl acl, @NotNull BambooPermissionManager bambooPermissionManager, boolean showAdminPermission)
acl
- bambooPermissionManager
- showAdminPermission
- public void updateRolePermissions(@Nullable String roleName, @NotNull List<org.acegisecurity.acls.Permission> permissions, @NotNull BambooPermissionManager permissionManager, @NotNull HibernateMutableAclService aclService, @NotNull AdministrationConfigurationAccessor administrationConfigurationAccessor, @NotNull AdministrationConfigurationPersister administrationConfigurationPersister) throws WebValidationException
UnauthorisedException
will be thrown.
If updating ROLE_ANONYMOUS it will also update the anonymous access flag in the administration configuration depending on the READ permission.
roleName
- Role name. Must be one of the know roles, ROLE_USER or ROLE_ANONYMOUS. ROLE_USER can only have ACCESS or CREATE permissions.
ROLE_ANONYMOUS can only have ACCESS permission.permissions
- permissionManager
- aclService
- administrationConfigurationAccessor
- administrationConfigurationPersister
- WebValidationException
- If the role name is invalid or the role is given extra permission than it should have.protected ErrorCollection validateRolePermissionUpdateRequest(@NotNull String roleName, @NotNull List<org.acegisecurity.acls.Permission> permissions)
public void updateUserPermissions(@Nullable String userName, @NotNull List<org.acegisecurity.acls.Permission> permissions, @NotNull BambooUserManager bambooUserManager, @NotNull BambooPermissionManager bambooPermissionManager, @NotNull HibernateMutableAclService aclService, @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver) throws WebValidationException
UnauthorisedException
will be thrown.userName
- name of user for which permissions should be updatedpermissions
- updated permissionsWebValidationException
public void updateGroupPermissions(@Nullable String groupName, @NotNull List<org.acegisecurity.acls.Permission> permissions, @NotNull BambooPermissionManager bambooPermissionManager, @NotNull HibernateMutableAclService aclService, @NotNull BambooUserManager userManager, @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver) throws WebValidationException
WebValidationException
public void updateGroupPermissions(@Nullable String groupName, @NotNull List<org.acegisecurity.acls.Permission> permissions, @NotNull BambooPermissionManager bambooPermissionManager, @NotNull HibernateMutableAclService aclService, @NotNull BambooUserManager userManager, @NotNull com.atlassian.struts.TextProvider textProvider) throws WebValidationException
WebValidationException
public void updateGroupPermissions(@NotNull com.atlassian.user.Group group, @NotNull List<org.acegisecurity.acls.Permission> permissions, @NotNull BambooPermissionManager bambooPermissionManager, @NotNull HibernateMutableAclService aclService) throws WebValidationException
UnauthorisedException
will be thrown.group
- permissions
- WebValidationException
@Deprecated public static String retrievePermissionFromACE(@NotNull org.acegisecurity.acls.AccessControlEntry ace)
getPermissionKeyFromAce(AccessControlEntry)
@NotNull protected ErrorCollection validateUpdateRequest(@Nullable com.atlassian.user.Group group, @NotNull List<org.acegisecurity.acls.Permission> permissions, @NotNull BambooPermissionManager bambooPermissionManager)
public void buildPermissionAndUserGroupListsFromAcl(@NotNull List<String> grantedPermissions, @NotNull List<String> grantedUsers, @NotNull List<String> grantedGroups, @NotNull List<String> nonProcessedGrantedPermissions, @NotNull org.acegisecurity.acls.Acl acl, boolean showAdminPermissions, @NotNull BambooPermissionManager bambooPermissionManager)
Takes in an Acl
and populates three lists from this Acl: - grantedPermissions - a list of String
in format: bambooPermission_TYPE_PRINCIPAL_PERMISSION - grantedUsers - a list of String
usernames - who
have at least one AccessControlEntry
against the Acl
- grantedGroups - a list of String
groupnames - who have at least one AccessControlEntry
against the Acl
-
nonProcessedGrantedPermissions - a list of permissions, that are not processed - so could not be changed here. It
is introduced to avoid cleaning up permissions, that are not visible for user performing this action
grantedPermissions
- grantedUsers
- grantedGroups
- nonProcessedGrantedPermissions
- acl
- showAdminPermissions
- bambooPermissionManager
- public void modifyAclAces(org.acegisecurity.acls.MutableAcl acl, List<String> newPermissionKeys)
MutableAcl
with new AccessControlEntry
s with permissions represented by a list of
String
permissionKeys.acl
- newPermissionKeys
- public void addPermissionsToAclForCurrentUser(@NotNull org.acegisecurity.acls.MutableAcl acl, @NotNull List<BambooPermission> permissions)
permissions
for the currently logged in user to the acl
entry. This method will
not persist the modifications on the MutableAcl
.acl
- acl to updatepermissions
- permissions to grant@NotNull public org.acegisecurity.acls.MutableAcl createNewDefaultAcl(@Nullable com.atlassian.user.User user, Class<? extends Plan> planType, boolean accessForAllUsers)
user
- to create acl for.planType
- to create acl for.accessForAllUsers
- to create acl for anonymous and logged-in userMutableAcl
representing a default permission set@NotNull public org.acegisecurity.acls.MutableAcl createNewObjectAcl(@Nullable com.atlassian.user.User user, Class<? extends BambooIdProvider> permissionObject, long id, boolean accessForAllUsers)
user
- to create acl for.permissionObject
- to create acl for.MutableAcl
representing a default permission set@NotNull public org.acegisecurity.acls.MutableAcl copyProjectPermissionsToEnvironment(@Nullable com.atlassian.user.User user, Class<? extends BambooIdProvider> permissionObject, long id, org.acegisecurity.acls.Acl parentAcl)
@NotNull public org.acegisecurity.acls.MutableAcl clonePermissions(@Nullable com.atlassian.user.User user, Class<? extends BambooIdProvider> permissionObject, long id, org.acegisecurity.acls.Acl parentAcl)
@NotNull public static String extractPrincipalFromSid(@NotNull org.acegisecurity.acls.sid.Sid sid)
Sid
. Throws IllegalStateException
if the sid type is
unknown.sid
- ACEGI sidGroupPrincipalSid.getPrincipal()
or PrincipalSid.getPrincipal()
.IllegalStateException
- when sid type is not recognizedpublic static String extractSidTypeFromSid(@NotNull org.acegisecurity.acls.sid.Sid sid)
Sid
. Throws IllegalStateException
if the sid type
is unknown.sid
- ACEGI sidBAMBOO_PERMISSION_FORM_GROUP
or
BAMBOO_PERMISSION_FORM_USER
.@NotNull public org.acegisecurity.acls.sid.Sid getSidFromPermissionKey(@NotNull String permissionKey)
Sid
based on a permission key.permissionKey
- full permission key, containing sid type, principal name and permission nameSid
based on the passed keyIllegalArgumentException
- if the key can't be used to properly construct a Sid
public void addReadPermissionForAnonymousAndLoggedinUsers(@NotNull org.acegisecurity.acls.MutableAcl acl)
@NotNull public org.acegisecurity.acls.sid.Sid getSidFromIdAndType(@NotNull String id, @NotNull String type)
Sid
from a given sid id and type.id
- unique id of the sidtype
- type of the sid, one of the values defined in HibernateSidUserType
IllegalArgumentException
- if the sid type is not recognisedpublic org.acegisecurity.acls.Permission getPermission(String permissionKey)
Copyright © 2021 Atlassian Software Systems Pty Ltd. All rights reserved.