use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method removePermission.
@Override
public void removePermission(Permission permission) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
rbacManager.removePermission(permission);
permissionsCache.remove(permission.getName());
allFailed = false;
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method getRole.
@Override
public Role getRole(String roleName) throws RbacObjectNotFoundException, RbacManagerException {
Role el = rolesCache.get(roleName);
if (el != null) {
return el;
}
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
Role role = rbacManager.getRole(roleName);
if (role != null) {
rolesCache.put(role.getName(), role);
return role;
}
} catch (Exception e) {
lastException = e;
}
}
log.debug("cannot find role for name: ‘{}", roleName);
if (lastException != null) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return null;
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method getUserAssignmentsForRoles.
@Override
public List<UserAssignment> getUserAssignmentsForRoles(Collection<String> roleNames) throws RbacManagerException {
List<UserAssignment> allUserAssignments = new ArrayList<>();
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
List<UserAssignment> userAssignments = rbacManager.getUserAssignmentsForRoles(roleNames);
allUserAssignments.addAll(userAssignments);
allFailed = false;
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return allUserAssignments;
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method getAllResources.
@Override
public List<Resource> getAllResources() throws RbacManagerException {
Map<String, Resource> allResources = new HashMap<>();
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
List<Resource> resources = rbacManager.getAllResources();
for (Resource r : resources) {
allResources.put(r.getIdentifier(), r);
}
allFailed = false;
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return new ArrayList<>(allResources.values());
}
use of org.apache.archiva.redback.rbac.RBACManager in project archiva by apache.
the class ArchivaRbacManager method savePermission.
@Override
public Permission savePermission(Permission permission) throws RbacObjectInvalidException, RbacManagerException {
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
if (rbacManager.isReadOnly()) {
permission = rbacManager.savePermission(permission);
allFailed = false;
}
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return permission;
}
Aggregations