Class PermissionBackend.WithUser
java.lang.Object
com.google.gerrit.server.permissions.PermissionBackend.WithUser
- Enclosing class:
- PermissionBackend
PermissionBackend scoped to a specific user.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchange
(ChangeNotes notes) Returns an instance scoped for the change, and its destination ref and project.change
(ChangeData cd) Returns an instance scoped for the change, and its destination ref and project.abstract void
Verify scoped user canperm
, throwing if denied.void
Verify scoped user can perform at least one listed permission.filter
(ProjectPermission perm, Collection<Project.NameKey> projects) Filter a set of projects usingcheck(perm)
.abstract PermissionBackend.ForProject
project
(Project.NameKey project) Returns an instance scoped for the specified project.ref
(BranchNameKey ref) Returns an instance scoped for theref
, and its parent project.boolean
test
(GlobalOrPluginPermission perm) abstract <T extends GlobalOrPluginPermission>
Set<T>test
(Collection<T> permSet) FilterpermSet
to permissions scoped user might be able to perform.abstract BooleanCondition
boolean
-
Constructor Details
-
WithUser
public WithUser()
-
-
Method Details
-
project
Returns an instance scoped for the specified project. -
ref
Returns an instance scoped for theref
, and its parent project. -
change
Returns an instance scoped for the change, and its destination ref and project. -
change
Returns an instance scoped for the change, and its destination ref and project. -
check
public abstract void check(GlobalOrPluginPermission perm) throws AuthException, PermissionBackendException Verify scoped user canperm
, throwing if denied.Should be used in REST API handlers where the thrown
AuthException
can be propagated. In business logic, where the exception would have to be caught, prefer usingtest(GlobalOrPluginPermission)
. -
checkAny
public void checkAny(Set<GlobalOrPluginPermission> any) throws PermissionBackendException, AuthException Verify scoped user can perform at least one listed permission.If
any
is empty, the method completes normally and allows the caller to continue. Since no permissions were supplied to check, its assumed no permissions are necessary to continue with the caller's operation.If the user has at least one of the permissions in
any
, the method completes normally, possibly without checking all listed permissions.If
any
is non-empty and the user has none,AuthException
is thrown for one of the failed permissions.- Parameters:
any
- set of permissions to check.- Throws:
PermissionBackendException
AuthException
-
test
public abstract <T extends GlobalOrPluginPermission> Set<T> test(Collection<T> permSet) throws PermissionBackendException FilterpermSet
to permissions scoped user might be able to perform.- Throws:
PermissionBackendException
-
test
- Throws:
PermissionBackendException
-
testOrFalse
-
testCond
-
filter
public Set<Project.NameKey> filter(ProjectPermission perm, Collection<Project.NameKey> projects) throws PermissionBackendException Filter a set of projects usingcheck(perm)
.- Parameters:
perm
- required permission in a project to be included in result.projects
- candidate set of projects; may be empty.- Returns:
- filtered set of
projects
wherecheck(perm)
was successful. - Throws:
PermissionBackendException
- backend cannot access its internal state.
-