Search in sources :

Example 16 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class ReviewMgrImpl method permissionRoles.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public List<String> permissionRoles(Permission perm) throws SecurityException {
    String methodName = "permissionRoles";
    assertContext(CLS_NM, methodName, perm, GlobalErrIds.PERM_OBJECT_NULL);
    checkAccess(CLS_NM, methodName);
    Permission pe = permP.read(perm);
    List<String> retVals;
    if (pe != null && CollectionUtils.isNotEmpty(pe.getRoles())) {
        retVals = new ArrayList<>(pe.getRoles());
    } else {
        retVals = new ArrayList<>();
    }
    return retVals;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 17 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class ReviewMgrImpl method findRoleConstraints.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public List<RoleConstraint> findRoleConstraints(User user, Permission permission, RoleConstraint.RCType rcType) throws SecurityException {
    String methodName = "findRoleConstraints";
    assertContext(CLS_NM, methodName, user, GlobalErrIds.USER_NULL);
    assertContext(CLS_NM, methodName, permission, GlobalErrIds.PERM_NULL);
    checkAccess(CLS_NM, methodName);
    // find roles this permission is authorized for
    Permission pe = permP.read(permission);
    Set<String> authorizedRoles = authorizeRoles(pe.getRoles());
    // find role constraints for the user and the permission's pa set
    return userP.findRoleConstraints(authorizedRoles, user, rcType, pe.getPaSets());
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 18 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class ReviewMgrImpl method permissionUsers.

/**
 * {@inheritDoc}
 */
@Override
@AdminPermissionOperation
public List<String> permissionUsers(Permission perm) throws SecurityException {
    String methodName = "permissionUsers";
    assertContext(CLS_NM, methodName, perm, GlobalErrIds.PERM_OPERATION_NULL);
    checkAccess(CLS_NM, methodName);
    Permission pe = permP.read(perm);
    List<String> retVals;
    if (pe != null && CollectionUtils.isNotEmpty(pe.getUsers())) {
        retVals = new ArrayList<>(pe.getUsers());
    } else {
        retVals = new ArrayList<>();
    }
    return retVals;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) AdminPermissionOperation(org.apache.directory.fortress.annotation.AdminPermissionOperation)

Example 19 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class AdminMgrRestImpl method updatePermission.

/**
 * {@inheritDoc}
 */
@Override
public Permission updatePermission(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".updatePermission");
    Permission retPerm;
    FortRequest request = RestUtils.getRequest(this.contextId);
    request.setEntity(perm);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_UPDATE);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retPerm = (Permission) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retPerm;
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 20 with Permission

use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.

the class AdminMgrImplTest method addPASetToPermission.

public static void addPASetToPermission(String msg, String paSetName, String obj, String[] op) throws SecurityException {
    LogUtil.logIt(msg);
    AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
    Permission pop = PermTestData.getOp(obj, op);
    pop.setPaSetName(paSetName);
    adminMgr.updatePermission(pop);
    LOG.debug("addPASetToPermission name [" + paSetName + "] successful");
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Aggregations

Permission (org.apache.directory.fortress.core.model.Permission)99 SecurityException (org.apache.directory.fortress.core.SecurityException)58 Role (org.apache.directory.fortress.core.model.Role)24 User (org.apache.directory.fortress.core.model.User)24 AdminMgr (org.apache.directory.fortress.core.AdminMgr)18 UserRole (org.apache.directory.fortress.core.model.UserRole)17 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)16 Session (org.apache.directory.fortress.core.model.Session)12 FortRequest (org.apache.directory.fortress.core.model.FortRequest)11 FortResponse (org.apache.directory.fortress.core.model.FortResponse)11 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)11 ArrayList (java.util.ArrayList)10 FinderException (org.apache.directory.fortress.core.FinderException)10 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)9 AdminRole (org.apache.directory.fortress.core.model.AdminRole)9 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)9 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)9 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)7 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)7 AccessMgr (org.apache.directory.fortress.core.AccessMgr)7