public class PermissionsServiceUtils extends Object
AbstractProjectPermissionsService
DefaultPlanPermissionsService
Modifier and Type | Field and Description |
---|---|
static com.google.common.collect.Ordering<BambooPermission> |
PERMISSIONS_ORDERING
Globally-consistent ordering of Bamboo permissions.
|
Constructor and Description |
---|
PermissionsServiceUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
assertCanManagePermissionsForDeploymentProject(DeploymentProject deploymentProject,
BambooPermissionManager bambooPermissionManager) |
static void |
assertCanManagePermissionsForEnvironment(Environment environment,
BambooPermissionManager bambooPermissionManager) |
static void |
assertCanManagePermissionsForRepository(RepositoryDataEntity repository,
BambooPermissionManager bambooPermissionManager) |
static Set<BambooPermission> |
extractDependencies(com.google.common.collect.Multimap<BambooPermission,BambooPermission> permissionDependencies,
Collection<BambooPermission> supportedPermissions,
BambooPermission permission)
Obtain a collection of Bamboo permissions dependent on the passed
permission . |
static com.google.common.collect.ImmutableMultimap<BambooPermission,BambooPermission> |
findMissingDependencies(Collection<BambooPermission> permissions,
Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier)
Validates permission dependencies.
|
static Collection<BambooPermission> |
getPermissionsAndDependencies(Collection<BambooPermission> permissions,
Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier)
Return a collection of permissions with all missing dependencies added.
|
static void |
validateDependenciesAfterGranting(Collection<BambooPermission> permissions,
Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier)
Validates permission dependencies after granting new permissions.
|
static <E extends Exception> |
validateDependenciesAfterGranting(Collection<BambooPermission> permissions,
Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier,
Function<BambooPermission,String> permissionNameFunction,
Function<String,E> exceptionConstructorFunction)
Validates permission dependencies after granting new permissions.
|
static void |
validateDependenciesAfterRevoking(Collection<BambooPermission> permissions,
Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier)
Validates permission dependencies after revoking permissions.
|
static <E extends Exception> |
validateDependenciesAfterRevoking(Collection<BambooPermission> permissions,
Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier,
Function<BambooPermission,String> permissionNameFunction,
Function<String,E> exceptionConstructorFunction)
Validates permission dependencies after revoking permissions.
|
static com.atlassian.user.Group |
validateGroup(String groupName,
BambooUserManager bambooUserManager) |
static void |
validatePermissions(List<BambooPermission> permissions,
Collection<BambooPermission> supportedPermissions,
String entityName) |
static com.atlassian.user.User |
validateUser(String username,
BambooUserManager bambooUserManager) |
public static final com.google.common.collect.Ordering<BambooPermission> PERMISSIONS_ORDERING
Note: some permissions appearing later on the list are not necessarily expected to be granting permissions which
appear earlier. For example, BambooPermission.CLONE
does not grant BambooPermission.BUILD
, yet
to maintain a consistent order one had to be placed after another.
public static com.atlassian.user.User validateUser(String username, BambooUserManager bambooUserManager)
public static com.atlassian.user.Group validateGroup(String groupName, BambooUserManager bambooUserManager)
public static void assertCanManagePermissionsForDeploymentProject(DeploymentProject deploymentProject, BambooPermissionManager bambooPermissionManager) throws org.acegisecurity.AccessDeniedException
org.acegisecurity.AccessDeniedException
public static void assertCanManagePermissionsForEnvironment(Environment environment, BambooPermissionManager bambooPermissionManager) throws org.acegisecurity.AccessDeniedException
org.acegisecurity.AccessDeniedException
public static void assertCanManagePermissionsForRepository(RepositoryDataEntity repository, BambooPermissionManager bambooPermissionManager) throws org.acegisecurity.AccessDeniedException
org.acegisecurity.AccessDeniedException
public static void validatePermissions(List<BambooPermission> permissions, Collection<BambooPermission> supportedPermissions, String entityName) throws IllegalArgumentException
IllegalArgumentException
@NotNull public static Set<BambooPermission> extractDependencies(com.google.common.collect.Multimap<BambooPermission,BambooPermission> permissionDependencies, Collection<BambooPermission> supportedPermissions, BambooPermission permission)
permission
. A dependent permission is
expected to always be granted whenever the parent permission is granted too.
The result is an effective collection of dependencies, meaning there's no need to recursively traverse the dependency graph.
permissionDependencies
- permission dependency graph in the format of a Multimap
supportedPermissions
- a collection of supported permissions to filter out the resultpermission
- permission for which to obtain the dependenciespermission
public static void validateDependenciesAfterGranting(@NotNull Collection<BambooPermission> permissions, @NotNull Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier) throws IllegalArgumentException
permissions
- a collection of permissions to validatepermissionDependenciesSupplier
- function to obtain dependencies for a permissionIllegalArgumentException
- on validation errorpublic static <E extends Exception> void validateDependenciesAfterGranting(@NotNull Collection<BambooPermission> permissions, @NotNull Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier, @NotNull Function<BambooPermission,String> permissionNameFunction, @NotNull Function<String,E> exceptionConstructorFunction) throws E extends Exception
permissions
- a collection of permissions to validatepermissionDependenciesSupplier
- function to obtain dependencies for a permissionpermissionNameFunction
- function to extract display name of a permissionexceptionConstructorFunction
- function to create exception in case of validation errorE
- on validation errorE extends Exception
public static void validateDependenciesAfterRevoking(@NotNull Collection<BambooPermission> permissions, @NotNull Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier)
permissions
- a collection of permissions to validatepermissionDependenciesSupplier
- function to obtain dependencies for a permissionIllegalArgumentException
- on validation errorpublic static <E extends Exception> void validateDependenciesAfterRevoking(@NotNull Collection<BambooPermission> permissions, @NotNull Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier, @NotNull Function<BambooPermission,String> permissionNameFunction, @NotNull Function<String,E> exceptionConstructorFunction) throws E extends Exception
permissions
- a collection of permissions to validatepermissionDependenciesSupplier
- function to obtain dependencies for a permissionpermissionNameFunction
- function to extract display name of a permissionexceptionConstructorFunction
- function to create exception in case of validation errorE
- on validation errorE extends Exception
@NotNull public static com.google.common.collect.ImmutableMultimap<BambooPermission,BambooPermission> findMissingDependencies(@NotNull Collection<BambooPermission> permissions, @NotNull Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier)
Example: provided that permission 'A' depends on 'B', and 'B' depends on 'C', then:
permissions
- a collection of permissions to validatepermissionDependenciesSupplier
- function to obtain dependencies for a permission@NotNull public static Collection<BambooPermission> getPermissionsAndDependencies(@NotNull Collection<BambooPermission> permissions, @NotNull Function<BambooPermission,Collection<BambooPermission>> permissionDependenciesSupplier)
permissions
- a collection of permissionspermissionDependenciesSupplier
- function to obtain dependencies for a permissionCopyright © 2018 Atlassian Software Systems Pty Ltd. All rights reserved.