public interface PermissionValidationService
PermissionService
to check for a permission and will throw
AuthorisationException
for any failed permission check.Modifier and Type | Method and Description |
---|---|
void |
validateAuthenticated()
Validate that the user is logged in
|
void |
validateForGlobal(Permission permission)
Validate that the current user has the specified global permission
|
void |
validateForProject(int projectId,
Permission permission)
Validate that the current user has the specified permission for the project
|
void |
validateForProject(Project project,
Permission permission)
Validate that the current user has the specified permission for the project
|
void |
validateForRepository(int repositoryId,
Permission permission)
Validate that the current user has the specified permission for the repository
|
void |
validateForRepository(Repository repository,
Permission permission)
Validate that the current user has the specified permission for the repository
|
void |
validateForUser(ApplicationUser targetUser,
Permission permission)
Validate that the current user has the specified permission for the target user.
|
void |
validateForUser(int targetUserId,
Permission permission)
Validate that the current user has the specified permission for the target user.
|
void |
validateForUser(Permission permission)
Validate that the current user has the specified permission for itself
|
void |
validateRepositoryAccessible(int repositoryId)
Validate that the current user (authenticated or not) has access to the given repository.
|
void |
validateRepositoryAccessible(Repository repository)
Validate that the current user (authenticated or not) has access to the given repository.
|
void validateAuthenticated() throws AuthorisationException
AuthorisationException
- if anonymousAuthenticationContext.isAuthenticated()
void validateForGlobal(@Nonnull Permission permission) throws AuthorisationException
permission
- the requested permission. Must not be null
and Permission.isGlobal()
must be trueAuthorisationException
- if the current user is unauthorizedPermissionService.hasGlobalPermission(Permission)
void validateForProject(@Nonnull Project project, @Nonnull Permission permission) throws AuthorisationException
project
- the target project. Must not be null
permission
- the requested permission. Must not be null
and Permission.isGlobal()
must be falseAuthorisationException
- if the current user is unauthorizedPermissionService.hasProjectPermission(Project, Permission)
void validateForProject(int projectId, @Nonnull Permission permission)
projectId
- the ID of the target projectpermission
- the requested permission. Must not be null
and Permission.isGlobal()
must be falseAuthorisationException
- if the current user is unauthorizedPermissionService.hasProjectPermission(Project, Permission)
void validateForRepository(@Nonnull Repository repository, @Nonnull Permission permission) throws AuthorisationException
Note that anonymous users accessing a public repository do not have the Permission.REPO_READ
permission. To perform read access validation that includes public repository access by anonymous users
see validateRepositoryAccessible(Repository)
.
repository
- the target repository. Must not be null
permission
- the requested permission. Must not be null
and Permission.isGlobal()
must be falseAuthorisationException
- if the current user is unauthorizedPermissionService.hasRepositoryPermission(Repository, Permission)
void validateForRepository(int repositoryId, @Nonnull Permission permission)
Note that anonymous users accessing a public repository do not have the Permission.REPO_READ
permission. To perform read access validation that includes public repository access by anonymous users
see validateRepositoryAccessible(int)
.
repositoryId
- the ID of the target repositorypermission
- the requested permission. Must not be null
and Permission.isGlobal()
must be falseAuthorisationException
- if the current user is unauthorizedPermissionService.hasRepositoryPermission(Repository, Permission)
void validateForUser(@Nonnull ApplicationUser targetUser, @Nonnull Permission permission)
targetUser
- the target user. Must not be null
permission
- the requested permission. Must not be null
and Permission.isGlobal()
must be falseAuthorisationException
- if the current user is unauthorizedPermissionService.hasUserPermission(ApplicationUser, Permission)
void validateForUser(int targetUserId, @Nonnull Permission permission)
targetUserId
- the ID of the target userpermission
- the requested permission. Must not be null
and Permission.isGlobal()
must be falseAuthorisationException
- if the current user is unauthorizedPermissionService.hasUserPermission(ApplicationUser, Permission)
void validateForUser(@Nonnull Permission permission)
permission
- the requested permission. Must not be null
and Permission.isGlobal()
must be falseAuthorisationException
- if the current user is unauthorizedPermissionService.hasUserPermission(Permission)
void validateRepositoryAccessible(@Nonnull Repository repository)
PermissionService.isRepositoryAccessible(Repository)
for a description of what
constitutes "access".repository
- the target repository. Must not be null
AuthorisationException
- if the current user is unauthorizedPermissionService.isRepositoryAccessible(Repository)
void validateRepositoryAccessible(int repositoryId)
PermissionService.isRepositoryAccessible(int)
for a description of what constitutes
"access".repositoryId
- the ID of the target repositoryAuthorisationException
- if the current user is unauthorizedPermissionService.isRepositoryAccessible(int)
Copyright © 2019 Atlassian. All rights reserved.