Search in sources :

Example 6 with RbacObjectNotFoundException

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

the class ArchivaRbacManager method getUserAssignment.

@Override
public UserAssignment getUserAssignment(String principal) throws RbacObjectNotFoundException, RbacManagerException {
    UserAssignment el = userAssignmentsCache.get(principal);
    if (el != null) {
        return el;
    }
    UserAssignment ua = null;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            if (ua == null) {
                ua = rbacManager.getUserAssignment(principal);
            } else {
                UserAssignment userAssignment = rbacManager.getUserAssignment(principal);
                if (userAssignment != null) {
                    for (String roleName : userAssignment.getRoleNames()) {
                        ua.addRoleName(roleName);
                    }
                }
            }
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (ua != null) {
        userAssignmentsCache.put(principal, ua);
        return ua;
    }
    if (lastException != null) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return null;
}
Also used : UserAssignment(org.apache.archiva.redback.rbac.UserAssignment) 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 RbacObjectNotFoundException

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

the class ArchivaRbacManager method removeOperation.

@Override
public void removeOperation(Operation operation) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            rbacManager.removeOperation(operation);
            operationsCache.remove(operation.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 8 with RbacObjectNotFoundException

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

the class ArchivaRbacManager method removeRole.

@Override
public void removeRole(Role role) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            rbacManager.removeRole(role);
            rolesCache.remove(role.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 9 with RbacObjectNotFoundException

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

the class ArchivaRbacManager method removeUserAssignment.

@Override
public void removeUserAssignment(UserAssignment userAssignment) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            rbacManager.removeUserAssignment(userAssignment);
            userAssignmentsCache.remove(userAssignment.getPrincipal());
            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 10 with RbacObjectNotFoundException

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

the class ArchivaRbacManager method getPermission.

@Override
public Permission getPermission(String permissionName) throws RbacObjectNotFoundException, RbacManagerException {
    Permission el = permissionsCache.get(permissionName);
    if (el != null) {
        return el;
    }
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            Permission p = rbacManager.getPermission(permissionName);
            if (p != null) {
                permissionsCache.put(permissionName, p);
                return p;
            }
        } 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) Permission(org.apache.archiva.redback.rbac.Permission) 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

RbacObjectNotFoundException (org.apache.archiva.redback.rbac.RbacObjectNotFoundException)11 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)10 AbstractRBACManager (org.apache.archiva.redback.rbac.AbstractRBACManager)10 RBACManager (org.apache.archiva.redback.rbac.RBACManager)10 RbacManagerException (org.apache.archiva.redback.rbac.RbacManagerException)10 RbacObjectInvalidException (org.apache.archiva.redback.rbac.RbacObjectInvalidException)10 UserAssignment (org.apache.archiva.redback.rbac.UserAssignment)2 Operation (org.apache.archiva.redback.rbac.Operation)1 Permission (org.apache.archiva.redback.rbac.Permission)1 Resource (org.apache.archiva.redback.rbac.Resource)1 Role (org.apache.archiva.redback.rbac.Role)1