Search in sources :

Example 1 with RBACManager

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);
    }
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) RbacObjectNotFoundException(org.apache.archiva.redback.rbac.RbacObjectNotFoundException) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RbacObjectInvalidException(org.apache.archiva.redback.rbac.RbacObjectInvalidException)

Example 2 with RBACManager

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;
}
Also used : Role(org.apache.archiva.redback.rbac.Role) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) RbacObjectNotFoundException(org.apache.archiva.redback.rbac.RbacObjectNotFoundException) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RbacObjectInvalidException(org.apache.archiva.redback.rbac.RbacObjectInvalidException)

Example 3 with RBACManager

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;
}
Also used : UserAssignment(org.apache.archiva.redback.rbac.UserAssignment) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) ArrayList(java.util.ArrayList) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) RbacObjectNotFoundException(org.apache.archiva.redback.rbac.RbacObjectNotFoundException) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RbacObjectInvalidException(org.apache.archiva.redback.rbac.RbacObjectInvalidException)

Example 4 with RBACManager

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());
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Resource(org.apache.archiva.redback.rbac.Resource) ArrayList(java.util.ArrayList) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) RbacObjectNotFoundException(org.apache.archiva.redback.rbac.RbacObjectNotFoundException) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RbacObjectInvalidException(org.apache.archiva.redback.rbac.RbacObjectInvalidException)

Example 5 with RBACManager

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;
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) RbacObjectNotFoundException(org.apache.archiva.redback.rbac.RbacObjectNotFoundException) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RbacObjectInvalidException(org.apache.archiva.redback.rbac.RbacObjectInvalidException)

Aggregations

RBACManager (org.apache.archiva.redback.rbac.RBACManager)25 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)24 AbstractRBACManager (org.apache.archiva.redback.rbac.AbstractRBACManager)24 RbacManagerException (org.apache.archiva.redback.rbac.RbacManagerException)23 RbacObjectInvalidException (org.apache.archiva.redback.rbac.RbacObjectInvalidException)23 RbacObjectNotFoundException (org.apache.archiva.redback.rbac.RbacObjectNotFoundException)23 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 Role (org.apache.archiva.redback.rbac.Role)3 UserAssignment (org.apache.archiva.redback.rbac.UserAssignment)3 Operation (org.apache.archiva.redback.rbac.Operation)2 Permission (org.apache.archiva.redback.rbac.Permission)2 Resource (org.apache.archiva.redback.rbac.Resource)2 Map (java.util.Map)1 RBACManagerImplementationInformation (org.apache.archiva.rest.api.model.RBACManagerImplementationInformation)1