Search in sources :

Example 6 with RbacManagerException

use of org.apache.archiva.redback.rbac.RbacManagerException 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)

Example 7 with RbacManagerException

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

the class ArchivaRbacManager method getAllUserAssignments.

@Override
public List<UserAssignment> getAllUserAssignments() throws RbacManagerException {
    Map<String, UserAssignment> allUserAssignments = new HashMap<>();
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            List<UserAssignment> userAssignments = rbacManager.getAllUserAssignments();
            for (UserAssignment ua : userAssignments) {
                UserAssignment userAssignment = allUserAssignments.get(ua.getPrincipal());
                if (userAssignment != null) {
                    for (String roleName : ua.getRoleNames()) {
                        userAssignment.addRoleName(roleName);
                    }
                }
                allUserAssignments.put(ua.getPrincipal(), ua);
            }
            allFailed = false;
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return new ArrayList<>(allUserAssignments.values());
}
Also used : UserAssignment(org.apache.archiva.redback.rbac.UserAssignment) 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 8 with RbacManagerException

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

use of org.apache.archiva.redback.rbac.RbacManagerException 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)

Example 10 with RbacManagerException

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

the class ArchivaRbacManager method getResource.

@Override
public Resource getResource(String resourceIdentifier) throws RbacObjectNotFoundException, RbacManagerException {
    Resource el = resourcesCache.get(resourceIdentifier);
    if (el != null) {
        return el;
    }
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            Resource r = rbacManager.getResource(resourceIdentifier);
            if (r != null) {
                resourcesCache.put(resourceIdentifier, r);
                return r;
            }
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return null;
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) Resource(org.apache.archiva.redback.rbac.Resource) 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

RbacManagerException (org.apache.archiva.redback.rbac.RbacManagerException)25 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)23 AbstractRBACManager (org.apache.archiva.redback.rbac.AbstractRBACManager)23 RBACManager (org.apache.archiva.redback.rbac.RBACManager)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 UserAssignment (org.apache.archiva.redback.rbac.UserAssignment)5 Role (org.apache.archiva.redback.rbac.Role)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 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)1 User (org.apache.archiva.redback.users.User)1 UserManager (org.apache.archiva.redback.users.UserManager)1 UserManagerException (org.apache.archiva.redback.users.UserManagerException)1 UserNotFoundException (org.apache.archiva.redback.users.UserNotFoundException)1