Search in sources :

Example 1 with Role

use of org.apache.archiva.redback.rbac.Role 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 2 with Role

use of org.apache.archiva.redback.rbac.Role in project archiva by apache.

the class ArchivaRbacManager method getAllRoles.

@Override
public List<Role> getAllRoles() throws RbacManagerException {
    Map<String, Role> allRoles = new HashMap<>();
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            List<Role> roles = rbacManager.getAllRoles();
            for (Role role : roles) {
                allRoles.put(role.getName(), role);
            }
            allFailed = false;
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return new ArrayList<>(allRoles.values());
}
Also used : Role(org.apache.archiva.redback.rbac.Role) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) 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 3 with Role

use of org.apache.archiva.redback.rbac.Role in project archiva by apache.

the class ArchivaRbacManager method roleExists.

@Override
public boolean roleExists(String name) throws RbacManagerException {
    Role r = rolesCache.get(name);
    if (r != null) {
        return true;
    }
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            boolean exists = rbacManager.roleExists(name);
            if (exists) {
                return true;
            }
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return false;
}
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)

Aggregations

RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)3 AbstractRBACManager (org.apache.archiva.redback.rbac.AbstractRBACManager)3 RBACManager (org.apache.archiva.redback.rbac.RBACManager)3 RbacManagerException (org.apache.archiva.redback.rbac.RbacManagerException)3 RbacObjectInvalidException (org.apache.archiva.redback.rbac.RbacObjectInvalidException)3 RbacObjectNotFoundException (org.apache.archiva.redback.rbac.RbacObjectNotFoundException)3 Role (org.apache.archiva.redback.rbac.Role)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1