Search in sources :

Example 81 with Permission

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

the class DelegatedAccessMgrConsole method checkAccess.

void checkAccess() {
    try {
        VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, ".checkAccess");
        ReaderUtil.clearScreen();
        System.out.println("Enter object name:");
        String objName = ReaderUtil.readLn();
        System.out.println("Enter operation name:");
        String opName = ReaderUtil.readLn();
        boolean result = dAmgr.checkAccess(session, new Permission(objName, opName));
        System.out.println("CheckAccess return [" + result + "] for user [" + session.getUserId() + "] objName [" + objName + "] operationName [" + opName + "]");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("checkAccess caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission)

Example 82 with Permission

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

the class DelegatedAccessMgrConsole method canGrant.

void canGrant() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter role name:");
        Role role = new Role(ReaderUtil.readLn());
        System.out.println("Enter perm object name:");
        String objName = ReaderUtil.readLn();
        boolean result = dAmgr.canGrant(session, role, new Permission(objName));
        System.out.println("Can Assign Role [" + role.getName() + "] Object name [" + objName + "] return [" + result + "]");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("canGrant caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Role(org.apache.directory.fortress.core.model.Role) Permission(org.apache.directory.fortress.core.model.Permission)

Example 83 with Permission

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

the class DelegatedAccessMgrConsole method canRevoke.

void canRevoke() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter role name:");
        Role role = new Role(ReaderUtil.readLn());
        System.out.println("Enter perm object name:");
        String objName = ReaderUtil.readLn();
        boolean result = dAmgr.canRevoke(session, role, new Permission(objName));
        System.out.println("Can Revoke Role [" + role.getName() + "] Object name [" + objName + "] return [" + result + "]");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("canRevoke caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Role(org.apache.directory.fortress.core.model.Role) Permission(org.apache.directory.fortress.core.model.Permission)

Example 84 with Permission

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

the class ReviewMgrRestImpl method findAnyPermissions.

/**
 * {@inheritDoc}
 */
@Override
public List<Permission> findAnyPermissions(Permission permission) throws SecurityException {
    VUtil.assertNotNull(permission, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".findAnyPermissions");
    List<Permission> retPerms;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(permission);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_SEARCH_ANY);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retPerms = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retPerms;
}
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 85 with Permission

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

the class ReviewMgrRestImpl method userPermissions.

/**
 * {@inheritDoc}
 */
@Override
public List<Permission> userPermissions(User user) throws SecurityException {
    VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".userPermissions");
    List<Permission> retPerms;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(user);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_PERMS);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retPerms = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retPerms;
}
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)

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