Interface PermissionValidationService
public interface PermissionValidationService
A utility service for plugin developer to validate that the current user has a specific permission.
 This service uses the 
PermissionService to check for a permission and will throw
 AuthorisationException for any failed permission check.- 
Method SummaryModifier and TypeMethodDescriptionvoidValidate that the user is logged invoidvalidateForGlobal(Permission permission) Validate that the current user has the specified global permissionvoidvalidateForProject(int projectId, Permission permission) Validate that the current user has the specified permission for the projectvoidvalidateForProject(Project project, Permission permission) Validate that the current user has the specified permission for the projectvoidvalidateForRepository(int repositoryId, Permission permission) Validate that the current user has the specified permission for the repositoryvoidvalidateForRepository(Repository repository, Permission permission) Validate that the current user has the specified permission for the repositoryvoidvalidateForUser(int targetUserId, Permission permission) Validate that the current user has the specified permission for the target user.voidvalidateForUser(Permission permission) Validate that the current user has the specified permission for itselfvoidvalidateForUser(ApplicationUser targetUser, Permission permission) Validate that the current user has the specified permission for the target user.voidvalidateRepositoryAccessible(int repositoryId) Validate that the current user (authenticated or not) has access to the given repository.voidvalidateRepositoryAccessible(Repository repository) Validate that the current user (authenticated or not) has access to the given repository.
- 
Method Details- 
validateAuthenticatedValidate that the user is logged in- Throws:
- AuthorisationException- if anonymous
- See Also:
 
- 
validateForGlobalValidate that the current user has the specified global permission- Parameters:
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be true
- Throws:
- AuthorisationException- if the current user is unauthorized
- See Also:
 
- 
validateForProjectvoid validateForProject(@Nonnull Project project, @Nonnull Permission permission) throws AuthorisationException Validate that the current user has the specified permission for the project- Parameters:
- project- the target project. Must not be- null
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be false
- Throws:
- AuthorisationException- if the current user is unauthorized
- See Also:
 
- 
validateForProjectValidate that the current user has the specified permission for the project- Parameters:
- projectId- the ID of the target project
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be false
- Throws:
- AuthorisationException- if the current user is unauthorized
- Since:
- 4.1
- See Also:
 
- 
validateForRepositoryvoid validateForRepository(@Nonnull Repository repository, @Nonnull Permission permission) throws AuthorisationException Validate that the current user has the specified permission for the repositoryNote that anonymous users accessing a public repository do not have the Permission.REPO_READpermission. To perform read access validation that includes public repository access by anonymous users seevalidateRepositoryAccessible(Repository).- Parameters:
- repository- the target repository. Must not be- null
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be false
- Throws:
- AuthorisationException- if the current user is unauthorized
- See Also:
 
- 
validateForRepositoryValidate that the current user has the specified permission for the repositoryNote that anonymous users accessing a public repository do not have the Permission.REPO_READpermission. To perform read access validation that includes public repository access by anonymous users seevalidateRepositoryAccessible(int).- Parameters:
- repositoryId- the ID of the target repository
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be false
- Throws:
- AuthorisationException- if the current user is unauthorized
- Since:
- 4.1
- See Also:
 
- 
validateForUserValidate that the current user has the specified permission for the target user.- Parameters:
- targetUser- the target user. Must not be- null
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be false
- Throws:
- AuthorisationException- if the current user is unauthorized
- Since:
- 5.5
- See Also:
 
- 
validateForUserValidate that the current user has the specified permission for the target user.- Parameters:
- targetUserId- the ID of the target user
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be false
- Throws:
- AuthorisationException- if the current user is unauthorized
- Since:
- 5.5
- See Also:
 
- 
validateForUserValidate that the current user has the specified permission for itself- Parameters:
- permission- the requested permission. Must not be- nulland- Permission.isGlobal()must be false
- Throws:
- AuthorisationException- if the current user is unauthorized
- Since:
- 5.5
- See Also:
 
- 
validateRepositoryAccessibleValidate that the current user (authenticated or not) has access to the given repository. SeePermissionService.isRepositoryAccessible(Repository)for a description of what constitutes "access".- Parameters:
- repository- the target repository. Must not be- null
- Throws:
- AuthorisationException- if the current user is unauthorized
- Since:
- 4.3
- See Also:
 
- 
validateRepositoryAccessiblevoid validateRepositoryAccessible(int repositoryId) Validate that the current user (authenticated or not) has access to the given repository. SeePermissionService.isRepositoryAccessible(int)for a description of what constitutes "access".- Parameters:
- repositoryId- the ID of the target repository
- Throws:
- AuthorisationException- if the current user is unauthorized
- Since:
- 4.3
- See Also:
 
 
-