public interface PermissionService
PermissionAdminService| Modifier and Type | Method and Description |
|---|---|
Page<String> |
getGrantedGroups(Permission permission,
PageRequest request)
Get the groups which are granted a permission
|
Page<ApplicationUser> |
getGrantedUsers(Permission permission,
PageRequest request)
Get the users which are granted a permission
|
Permission |
getHighestGlobalGroupPermission(String groupName)
Get the highest global permission for a group.
|
Permission |
getHighestGlobalPermission(ApplicationUser user)
Get the highest global permission for a user.
|
Permission |
getHighestGlobalPermission(String username)
Get the highest global permission for a user.
|
Set<String> |
getUsersWithPermission(Permission permission)
Get the usernames of the users with the given permission (whether directly or though permission inheritance)
This includes users granted the permission directly and those who have the permission through their group
membership.
|
boolean |
hasAnyUserPermission(ApplicationUser user,
Permission permission) |
boolean |
hasAnyUserPermission(Permission permission) |
boolean |
hasDirectGlobalUserPermission(Permission permission) |
boolean |
hasDirectProjectUserPermission(Project project,
Permission permission) |
boolean |
hasDirectRepositoryUserPermission(Repository repository,
Permission permission) |
boolean |
hasGlobalGroupPermission(Permission permission,
String group) |
boolean |
hasGlobalPermission(ApplicationUser user,
Permission permission)
Will return true if the user is
active and one of the following conditions
is met:
permission is granted directly for the given user
permission is granted to a group the given user is a member of
|
boolean |
hasGlobalPermission(Permission permission) |
boolean |
hasGlobalPermission(String username,
Permission permission)
Will return true if the user is
active and one of the following conditions
is met:
permission is granted directly for the given user
permission is granted to a group the given user is a member of
|
boolean |
hasGlobalPermissionThroughGroupMembership(Permission permission,
Set<String> excludedGroups) |
boolean |
hasProjectPermission(ApplicationUser user,
int projectId,
Permission permission) |
boolean |
hasProjectPermission(ApplicationUser user,
Project project,
Permission permission)
Will return true if the user is
active and one of the following conditions
is met:
permission is granted directly for the given user on the given project
permission is granted for all logged in users on the given project
permission is granted to a group the given user is a member of on the given project
The given user is directly granted a permission on at least one repository within the given project
and the given permission is implied as a result
A group the given user is a member of is granted a permission on at least one repository within the
given project and the given permission is implied as a result
The given project is publicly accessible and the permission is
implied as a result
the given user is directly granted administration rights
A group the given user is a member of is granted administration rights
|
boolean |
hasProjectPermission(int projectId,
Permission permission) |
boolean |
hasProjectPermission(Project project,
Permission permission) |
boolean |
hasProjectPermissionThroughGroupMembership(Project project,
Permission permission,
Set<String> excludedGroups) |
boolean |
hasRepositoryPermission(ApplicationUser user,
int repositoryId,
Permission permission) |
boolean |
hasRepositoryPermission(ApplicationUser user,
Repository repository,
Permission permission)
Will return true if the user is
active and one of the following conditions
is met:
permission is granted directly for the given user on the given repository
permission is granted to a group the given user is a member of on the given repository
The given user is directly granted a permission on the containing project and the given permission is
implied as a result
A group the given user is a member of is granted a permission on the containing project and the given
permission is implied as a result
All logged in users are granted a permission to the containing project and the given permission is
implied as a result
The given repository is publicly accessible and the permission
is implied as a result
the given user is directly granted administration rights
A group the given user is a member of is granted administration rights
This method will always return false if the user given is null as
anonymous users cannot be granted permissions by definition. |
boolean |
hasRepositoryPermission(int repositoryId,
Permission permission) |
boolean |
hasRepositoryPermission(Repository repository,
Permission permission) |
boolean |
hasRepositoryPermissionThroughGroupMembership(Repository repository,
Permission permission,
Set<String> excludedGroups) |
boolean |
hasUserPermission(ApplicationUser user,
ApplicationUser targetUser,
Permission permission) |
boolean |
hasUserPermission(ApplicationUser user,
int targetUserId,
Permission permission) |
boolean |
hasUserPermission(ApplicationUser targetUser,
Permission permission) |
boolean |
hasUserPermission(int targetUserId,
Permission permission) |
boolean |
hasUserPermission(Permission permission) |
boolean |
isProjectAccessible(int projectId) |
boolean |
isProjectAccessible(Project project)
Retrieve whether the current user (authenticated or not) has access to the given project.
|
boolean |
isPubliclyAccessible(Project project)
Retrieves whether the project is publicly accessible.
|
boolean |
isPubliclyAccessible(Repository repository)
Retrieves whether the repository is publicly accessible.
|
boolean |
isRepositoryAccessible(int repositoryId) |
boolean |
isRepositoryAccessible(Repository repository)
Retrieve whether the current user (authenticated or not) has access to the given repository.
|
boolean hasGlobalPermission(@Nullable String username, @Nonnull Permission permission)
active and one of the following conditions
is met:
username - the user in questionpermission - the requested permission. Must be global.true if the given user identified by username has the requested Permissionboolean hasGlobalPermission(@Nullable ApplicationUser user, @Nonnull Permission permission)
active and one of the following conditions
is met:
user - the user in questionpermission - the requested permission. Must be global.true if the given ApplicationUser has the requested Permissionboolean hasGlobalPermission(@Nonnull Permission permission)
permission - the requested permission. Must be global.PermissionhasGlobalPermission(ApplicationUser, Permission)boolean hasProjectPermission(@Nullable ApplicationUser user, @Nonnull Project project, @Nonnull Permission permission)
active and one of the following conditions
is met:
publicly accessible and the permission is
implied as a resultadministration rightsadministration rightsuser - the user in questionproject - the project in questionpermission - the requested permission. Must be non-global.true if the given ApplicationUser has the requested Permission for the
given Projectboolean hasProjectPermission(@Nonnull Project project, @Nonnull Permission permission)
project - the project in questionpermission - the requested permission. Must be non-global.Permission for the given
ProjecthasProjectPermission(ApplicationUser, Project, Permission)boolean hasProjectPermission(@Nullable ApplicationUser user, int projectId, @Nonnull Permission permission)
user - the user in questionprojectId - the ID of projectpermission - the requested permission. Must be non-global.ApplicationUser has the requested Permission for the Project
identified by projectIdhasProjectPermission(ApplicationUser, Project, Permission)boolean hasProjectPermission(int projectId,
@Nonnull
Permission permission)
projectId - the ID project in questionpermission - the requested permission. Must be non-global.Permission for the given
ProjecthasProjectPermission(ApplicationUser, int, Permission)boolean hasRepositoryPermission(@Nullable ApplicationUser user, @Nonnull Repository repository, @Nonnull Permission permission)
active and one of the following conditions
is met:
publicly accessible and the permission
is implied as a resultadministration rightsadministration rightsfalse if the user given is null as
anonymous users cannot be granted permissions by definition.user - the user in questionrepository - the repository in questionpermission - the requested permission. Must be non-global.ApplicationUser has the requested Permission for the given
Repositoryboolean hasRepositoryPermission(@Nullable ApplicationUser user, int repositoryId, @Nonnull Permission permission)
user - the user in questionrepositoryId - the repository in questionpermission - the requested permission. Must be non-global.ApplicationUser has the requested Permission for the given
RepositoryhasRepositoryPermission(ApplicationUser, Repository, Permission)boolean hasRepositoryPermission(@Nonnull Repository repository, @Nonnull Permission permission)
repository - the repository in questionpermission - the requested permission. Must be non-global.Permission for the given
RepositoryhasRepositoryPermission(ApplicationUser, Repository, Permission)boolean hasRepositoryPermission(int repositoryId,
@Nonnull
Permission permission)
repositoryId - the repository in questionpermission - the requested permission. Must be non-global.Permission for the given
Repository identified by repositoryIdhasRepositoryPermission(ApplicationUser, Repository, Permission)boolean hasUserPermission(@Nonnull ApplicationUser user, @Nonnull ApplicationUser targetUser, @Nonnull Permission permission)
user - the user requesting the permissiontargetUser - the user that the permission applies topermission - the requested permission. Must be non-global.user has the requested Permission with respect to
targetUser's settingshasUserPermission(int, Permission)boolean hasUserPermission(@Nonnull ApplicationUser user, int targetUserId, @Nonnull Permission permission)
user - the user requesting the permissiontargetUserId - the ID of the user that the permission applies topermission - the requested permission. Must be non-global.user has the requested Permission with respect to
of the ApplicationUser identified by targetUserIdhasUserPermission(ApplicationUser, Permission)boolean hasUserPermission(@Nonnull ApplicationUser targetUser, @Nonnull Permission permission)
targetUser - the user that the permission applies topermission - the requested permission. Must be non-global.Permission with respect to
targetUser's settingshasUserPermission(int, Permission)boolean hasUserPermission(int targetUserId,
@Nonnull
Permission permission)
targetUserId - the ID of the user that the permission applies topermission - the requested permission. Must be non-global.Permission with respect to
the user identified by targetUserIdhasUserPermission(ApplicationUser, Permission)boolean hasUserPermission(@Nonnull Permission permission)
permission - the requested permission. Must be non-global.Permission for the account
of the currently authenticated userhasUserPermission(ApplicationUser, Permission)boolean hasAnyUserPermission(@Nonnull ApplicationUser user, @Nonnull Permission permission)
user - the user in questionpermission - the requested permission. Must be non-global.ApplicationUser has the requested Permission for any
project / repositoryboolean hasAnyUserPermission(@Nonnull Permission permission)
permission - the requested permission. Must be non-global.Permission for any
project / repositoryboolean hasGlobalPermissionThroughGroupMembership(@Nonnull Permission permission, @Nonnull Set<String> excludedGroups)
permission - The permission required.excludedGroups - A Set of groups to be excluded from consideration.boolean hasProjectPermissionThroughGroupMembership(@Nonnull Project project, @Nonnull Permission permission, @Nonnull Set<String> excludedGroups)
project - The project on which permission is being checkedpermission - The permission requiredexcludedGroups - A Set of groups to be excluded from considerationboolean hasRepositoryPermissionThroughGroupMembership(@Nonnull Repository repository, @Nonnull Permission permission, @Nonnull Set<String> excludedGroups)
repository - the repository on which permission is being checkedpermission - the permission requiredexcludedGroups - a Set of groups to be excluded from considerationboolean hasDirectGlobalUserPermission(@Nonnull Permission permission)
permission - the permission requiredboolean hasDirectProjectUserPermission(@Nonnull Project project, @Nonnull Permission permission)
project - the project on which permission is being checkedpermission - the permission requiredboolean hasDirectRepositoryUserPermission(@Nonnull Repository repository, @Nonnull Permission permission)
repository - the repository on which permission is being checkedpermission - the permission requiredboolean hasGlobalGroupPermission(@Nonnull Permission permission, @Nonnull String group)
permission - the permission requiredgroup - the group to be checkedboolean isProjectAccessible(@Nonnull Project project)
The user may have access as a result of the following:
Permission.PROJECT_VIEW permission for the given
project; orSecurityService.withPermission(Permission, String) running with}
Permission.PROJECT_VIEW permission; oris public; orare publicproject - the project on which to checktrue if the current user has access to the given project, false otherwiseboolean isProjectAccessible(int projectId)
projectId - the ID of the project on which to checktrue if the current user has access to the given project, false otherwiseisProjectAccessible(Project)boolean isRepositoryAccessible(@Nonnull Repository repository)
The user may have access as a result of the following:
Permission.REPO_READ permission for the given
repository; orSecurityService.withPermission(Permission, String) running with}
Permission.REPO_READ permission; orrepository - the repository on which to checktrue if the current user has access to the given repository, false otherwiseboolean isRepositoryAccessible(int repositoryId)
repositoryId - the ID of the repository on which to checktrue if the current user has access to the given repository, false otherwiseisRepositoryAccessible(Repository)boolean isPubliclyAccessible(@Nonnull Repository repository)
Note that a repository will be public if:
To check whether the current user (authenticated or not) can access the repository,
use isRepositoryAccessible(Repository) instead.
repository - the repository on which to checktrue if unauthenticated users can access the given repository, false otherwiseboolean isPubliclyAccessible(@Nonnull Project project)
Note: to check whether the current user (authenticated or not) can access the project,
use isProjectAccessible(Project) instead.
project - the project on which to checktrue if unauthenticated users can access the given project, false otherwise@Nonnull Page<ApplicationUser> getGrantedUsers(@Nonnull Permission permission, @Nonnull PageRequest request)
permission - the permission in questionrequest - a page request@Nonnull Page<String> getGrantedGroups(@Nonnull Permission permission, @Nonnull PageRequest request)
permission - the permission in questionrequest - a page request@Nonnull Set<String> getUsersWithPermission(@Nonnull Permission permission)
permission - the permission for which the users are being fetched. It must be
global.@Nullable Permission getHighestGlobalPermission(@Nullable ApplicationUser user)
user - the user@Nullable Permission getHighestGlobalPermission(@Nullable String username)
username - the user name@Nullable Permission getHighestGlobalGroupPermission(@Nullable String groupName)
groupName - the group nameCopyright © 2022 Atlassian. All rights reserved.