public class DefaultGlobalPermissionManager extends Object implements GlobalPermissionManager, GroupConfigurable
Constructor and Description |
---|
DefaultGlobalPermissionManager(com.atlassian.crowd.embedded.api.CrowdService crowdService,
OfBizDelegator ofBizDelegator,
com.atlassian.event.api.EventPublisher eventPublisher,
GlobalPermissionTypesManager globalPermissionTypesManager,
com.atlassian.cache.CacheManager cacheManager,
ApplicationRoleManager applicationRoleManager,
GroupManager groupManager,
RecoveryMode recoveryMode,
FeatureManager featureManager,
RequestCacheFactory requestCacheFactory) |
Modifier and Type | Method and Description |
---|---|
boolean |
addPermission(GlobalPermissionType globalPermissionType,
String group)
Grants a user group a global permission.
|
boolean |
addPermission(int permissionId,
String group)
Adds a global permission
|
void |
clearCache() |
Collection<GlobalPermissionType> |
getAllGlobalPermissions() |
io.atlassian.fugue.Option<GlobalPermissionType> |
getGlobalPermission(GlobalPermissionKey permissionKey)
Returns the global permission details for the given permission key.
|
io.atlassian.fugue.Option<GlobalPermissionType> |
getGlobalPermission(int permissionId) |
io.atlassian.fugue.Option<GlobalPermissionType> |
getGlobalPermission(String permissionKey)
Returns a global permission matching the specified key.
|
Collection<String> |
getGroupNames(GlobalPermissionType globalPermissionType)
Retrieve all the group names with this permission.
|
Collection<String> |
getGroupNames(int permissionId)
Retrieve all the group names with this permission.
|
Collection<String> |
getGroupNamesWithPermission(GlobalPermissionKey permissionKey)
Retrieve all the group names with this permission.
|
Collection<com.atlassian.crowd.embedded.api.Group> |
getGroupsWithPermission(GlobalPermissionKey permissionKey)
Retrieve all the groups with the given permission.
|
Collection<com.atlassian.crowd.embedded.api.Group> |
getGroupsWithPermission(GlobalPermissionType globalPermissionType)
Retrieve all the groups with this permission.
|
Collection<com.atlassian.crowd.embedded.api.Group> |
getGroupsWithPermission(int permissionId)
Retrieve all the groups with this permission.
|
Collection<GlobalPermissionEntry> |
getPermissions(GlobalPermissionKey globalPermissionKey)
Retrieve a list of user groups which have been granted the specified permission.
|
Collection<GlobalPermissionEntry> |
getPermissions(GlobalPermissionType globalPermissionType)
Retrieve a list of user groups which have been granted a specified permission.
|
Collection<JiraPermission> |
getPermissions(int permissionType)
Retrieve a list of user groups which have been granted a specified permission.
|
protected boolean |
hasPermission(GlobalPermissionEntry permissionEntry) |
boolean |
hasPermission(GlobalPermissionKey globalPermissionKey,
ApplicationUser user)
Check if the given user has the given Global Permission.
|
boolean |
hasPermission(GlobalPermissionType globalPermissionType)
Left in here temporarily in case it is being used by SD 2.0
|
boolean |
hasPermission(GlobalPermissionType globalPermissionType,
ApplicationUser user)
Left in here temporarily in case it is being used by SD 2.0
|
boolean |
hasPermission(int permissionId)
Check if a global anonymous permission exists
|
boolean |
hasPermission(int permissionId,
ApplicationUser user)
Check if a global permission for one of the users groups exists.
|
boolean |
isGlobalPermission(int permissionId) |
boolean |
isGroupUsed(com.atlassian.crowd.embedded.api.Group group)
Determine whether configuration exists for the specified
Group . |
boolean |
isPermissionManagedByJira(GlobalPermissionKey permissionKey)
Checks if jira should be responsible for managing a permission.
|
void |
onClearCache(ClearCacheEvent event) |
boolean |
removePermission(GlobalPermissionType globalPermissionType,
String group)
Revokes a global permission for a user group
|
boolean |
removePermission(int permissionId,
String group)
Revokes a global permission for a user group
|
boolean |
removePermissions(String group)
Revoke all global permissions for a user group.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isGroupUsed
public DefaultGlobalPermissionManager(com.atlassian.crowd.embedded.api.CrowdService crowdService, OfBizDelegator ofBizDelegator, com.atlassian.event.api.EventPublisher eventPublisher, GlobalPermissionTypesManager globalPermissionTypesManager, com.atlassian.cache.CacheManager cacheManager, ApplicationRoleManager applicationRoleManager, GroupManager groupManager, RecoveryMode recoveryMode, FeatureManager featureManager, RequestCacheFactory requestCacheFactory)
@EventListener public void onClearCache(ClearCacheEvent event)
public Collection<GlobalPermissionType> getAllGlobalPermissions()
getAllGlobalPermissions
in interface GlobalPermissionManager
public io.atlassian.fugue.Option<GlobalPermissionType> getGlobalPermission(int permissionId)
getGlobalPermission
in interface GlobalPermissionManager
permissionId
- id of the permission.public io.atlassian.fugue.Option<GlobalPermissionType> getGlobalPermission(@Nonnull String permissionKey)
GlobalPermissionManager
getGlobalPermission
in interface GlobalPermissionManager
permissionKey
- the key of the permission declared by global permission module.public io.atlassian.fugue.Option<GlobalPermissionType> getGlobalPermission(@Nonnull GlobalPermissionKey permissionKey)
GlobalPermissionManager
getGlobalPermission
in interface GlobalPermissionManager
permissionKey
- the global permission keypublic boolean addPermission(int permissionId, String group)
addPermission
in interface GlobalPermissionManager
permissionId
- must be a global permission typegroup
- can be null if it is anyone permissionpublic boolean addPermission(@Nonnull GlobalPermissionType globalPermissionType, String group)
GlobalPermissionManager
addPermission
in interface GlobalPermissionManager
globalPermissionType
- global permission, must not be null.group
- the name of the group. Null means "anyone" group.
The JIRA use, admin and sysadmin permission cannot be granted to "anyone".public Collection<JiraPermission> getPermissions(int permissionType)
GlobalPermissionManager
JiraPermission
contains a reference to the user group.
JiraPermission.getScheme()
is always NULL, because Global permission are not configured using schemes.
JiraPermission.getType()
will always return "group", because global permissions can only be granted to groups.
getPermissions
in interface GlobalPermissionManager
permissionType
- The key of pluggable global permission. Must be a global permission.JiraPermission.getPermType()
, must never return null.public Collection<GlobalPermissionEntry> getPermissions(GlobalPermissionType globalPermissionType)
GlobalPermissionManager
JiraPermission
contains a reference to the user group.
JiraPermission.getScheme()
is always NULL, because Global permission are not configured using schemes.
JiraPermission.getType()
will always return "group", because global permissions can only be granted to groups.
getPermissions
in interface GlobalPermissionManager
globalPermissionType
- global permission, must not be null.JiraPermission.getPermType()
, must never return null.@Nonnull public Collection<GlobalPermissionEntry> getPermissions(@Nonnull GlobalPermissionKey globalPermissionKey)
GlobalPermissionManager
The returned GlobalPermissionEntry
contains a reference to the user group.
getPermissions
in interface GlobalPermissionManager
globalPermissionKey
- global permission, must not be null.GlobalPermissionEntry
, never null.public boolean removePermission(int permissionId, String group)
GlobalPermissionManager
removePermission
in interface GlobalPermissionManager
permissionId
- the global permission.group
- the group name. NULL means the anyone group.public boolean removePermission(GlobalPermissionType globalPermissionType, String group)
GlobalPermissionManager
removePermission
in interface GlobalPermissionManager
globalPermissionType
- global permission, must not be null.group
- the group name. NULL means the anyone group.public boolean removePermissions(@Nonnull String group)
GlobalPermissionManager
removePermissions
in interface GlobalPermissionManager
group
- cannot NOT be null and the group must exist.public boolean hasPermission(int permissionId)
hasPermission
in interface GlobalPermissionManager
permissionId
- must be global permissionGlobalPermissionManager.hasPermission(int, ApplicationUser)
public boolean hasPermission(@Nonnull GlobalPermissionType globalPermissionType)
GlobalPermissionManager
hasPermission
in interface GlobalPermissionManager
public boolean hasPermission(int permissionId, ApplicationUser user)
GlobalPermissionManager
If the permission type is Permissions.ADMINISTER
and the lookup is false then the same
query will be executed for the Permissions.SYSTEM_ADMIN
permission type, since
it is implied that having a Permissions.SYSTEM_ADMIN
permission grants
Permissions.ADMINISTER
rights.
Note: Use GlobalPermissionManager.hasPermission(int)
method is you do not have the user object, i.e. user is anonymous.
If you are using this method directly, consider using
PermissionManager.hasPermission(int, ApplicationUser)
instead as it handles logged in and anonymous users as well.
hasPermission
in interface GlobalPermissionManager
permissionId
- must be a global permissionuser
- must not be nullGlobalPermissionManager.hasPermission(int)
,
PermissionManager.hasPermission(int, ApplicationUser)
public boolean hasPermission(@Nonnull GlobalPermissionKey globalPermissionKey, @Nullable ApplicationUser user)
GlobalPermissionManager
If the permission type is GlobalPermissionKey.ADMINISTER
and the lookup is false then the same
query will be executed for the GlobalPermissionKey.SYSTEM_ADMIN
permission type, since
it is implied that having a GlobalPermissionKey.SYSTEM_ADMIN
permission grants
GlobalPermissionKey.ADMINISTER
rights.
hasPermission
in interface GlobalPermissionManager
globalPermissionKey
- global permission, must not be null.user
- The user - can be null indicating "anonymous"public boolean hasPermission(@Nonnull GlobalPermissionType globalPermissionType, @Nullable ApplicationUser user)
GlobalPermissionManager
hasPermission
in interface GlobalPermissionManager
public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsWithPermission(int permissionId)
GlobalPermissionManager
getGroupsWithPermission
in interface GlobalPermissionManager
permissionId
- must be a global permissionGroup
's, will never be null.public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsWithPermission(@Nonnull GlobalPermissionType globalPermissionType)
GlobalPermissionManager
getGroupsWithPermission
in interface GlobalPermissionManager
globalPermissionType
- global permission, must not be null.Group
's, will never be null.@Nonnull public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsWithPermission(@Nonnull GlobalPermissionKey permissionKey)
GlobalPermissionManager
Only groups directly associated with the permission will be returned.
getGroupsWithPermission
in interface GlobalPermissionManager
permissionKey
- global permission, must not be null.Group
's, will never be null.@Nonnull public Collection<String> getGroupNames(int permissionId)
GlobalPermissionManager
getGroupNames
in interface GlobalPermissionManager
permissionId
- must be a global permissionpublic Collection<String> getGroupNames(@Nonnull GlobalPermissionType globalPermissionType)
GlobalPermissionManager
getGroupNames
in interface GlobalPermissionManager
globalPermissionType
- global permission, must not be null.@Nonnull public Collection<String> getGroupNamesWithPermission(@Nonnull GlobalPermissionKey permissionKey)
GlobalPermissionManager
getGroupNamesWithPermission
in interface GlobalPermissionManager
permissionKey
- global permission, must not be null.public boolean isGlobalPermission(int permissionId)
isGlobalPermission
in interface GlobalPermissionManager
permissionId
- id of the permission to check.public void clearCache()
clearCache
in interface GlobalPermissionManager
public boolean isPermissionManagedByJira(@Nonnull GlobalPermissionKey permissionKey)
GlobalPermissionManager
isPermissionManagedByJira
in interface GlobalPermissionManager
permissionKey
- global permissionprotected boolean hasPermission(GlobalPermissionEntry permissionEntry)
public boolean isGroupUsed(@Nonnull com.atlassian.crowd.embedded.api.Group group)
GroupConfigurable
Group
.isGroupUsed
in interface GroupConfigurable
group
- that may or may not exist.Copyright © 2002-2021 Atlassian. All Rights Reserved.