Search in sources :

Example 96 with Role

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

the class DelegatedAccessMgrConsole method canDeassign.

void canDeassign() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter userId:");
        User user = new User(ReaderUtil.readLn());
        System.out.println("Enter role name:");
        Role role = new Role(ReaderUtil.readLn());
        boolean result = dAmgr.canDeassign(session, user, role);
        System.out.println("Can Deassign User [" + user.getUserId() + "] Role [" + role.getName() + "] return [" + result + "]");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("canDeassign caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Role(org.apache.directory.fortress.core.model.Role) User(org.apache.directory.fortress.core.model.User)

Example 97 with Role

use of org.apache.directory.fortress.core.model.Role 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 98 with Role

use of org.apache.directory.fortress.core.model.Role 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 99 with Role

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

the class ReviewMgrRestImpl method readRole.

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

Example 100 with Role

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

the class ReviewMgrRestImpl method findRoles.

/**
 * {@inheritDoc}
 */
@Override
public List<Role> findRoles(String searchVal) throws SecurityException {
    VUtil.assertNotNull(searchVal, GlobalErrIds.ROLE_NM_NULL, CLS_NM + ".findRoles");
    List<Role> retRoles;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setValue(searchVal);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_SEARCH);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retRoles = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retRoles;
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Aggregations

Role (org.apache.directory.fortress.core.model.Role)117 UserRole (org.apache.directory.fortress.core.model.UserRole)83 SecurityException (org.apache.directory.fortress.core.SecurityException)66 AdminMgr (org.apache.directory.fortress.core.AdminMgr)40 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)30 User (org.apache.directory.fortress.core.model.User)30 AdminRole (org.apache.directory.fortress.core.model.AdminRole)25 Permission (org.apache.directory.fortress.core.model.Permission)24 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)17 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)15 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)15 Relationship (org.apache.directory.fortress.core.model.Relationship)7 SDSet (org.apache.directory.fortress.core.model.SDSet)7 FinderException (org.apache.directory.fortress.core.FinderException)6 PermObj (org.apache.directory.fortress.core.model.PermObj)6 ArrayList (java.util.ArrayList)5 Group (org.apache.directory.fortress.core.model.Group)5 Constraint (org.apache.directory.fortress.core.model.Constraint)4 FortRequest (org.apache.directory.fortress.core.model.FortRequest)4 FortResponse (org.apache.directory.fortress.core.model.FortResponse)4