use of com.google.gerrit.extensions.api.access.GlobalOrPluginPermission in project gerrit by GerritCodeReview.
the class GetCapabilities method apply.
@Override
public Object apply(AccountResource rsrc) throws AuthException, PermissionBackendException {
PermissionBackend.WithUser perm = permissionBackend.user(self);
if (self.get() != rsrc.getUser()) {
perm.check(GlobalPermission.ADMINISTRATE_SERVER);
perm = permissionBackend.user(rsrc.getUser());
}
Map<String, Object> have = new LinkedHashMap<>();
for (GlobalOrPluginPermission p : perm.test(permissionsToTest())) {
have.put(p.permissionName(), true);
}
addRanges(have, rsrc);
addPriority(have, rsrc);
return OutputFormat.JSON.newGson().toJsonTree(have, new TypeToken<Map<String, Object>>() {
}.getType());
}
use of com.google.gerrit.extensions.api.access.GlobalOrPluginPermission in project gerrit by GerritCodeReview.
the class Capabilities method parse.
@Override
public Capability parse(AccountResource parent, IdString id) throws ResourceNotFoundException, AuthException, PermissionBackendException {
permissionBackend.checkUsesDefaultCapabilities();
IdentifiedUser target = parent.getUser();
if (!self.get().hasSameAccountId(target)) {
permissionBackend.currentUser().check(GlobalPermission.ADMINISTRATE_SERVER);
}
GlobalOrPluginPermission perm = parse(id);
if (permissionBackend.absentUser(target.getAccountId()).test(perm)) {
return new AccountResource.Capability(target, globalOrPluginPermissionName(perm));
}
throw new ResourceNotFoundException(id);
}
Aggregations