Search in sources :

Example 71 with UserRole

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

the class DelAccessMgrRestImpl method canAssign.

/**
 * {@inheritDoc}
 */
@Override
public boolean canAssign(Session session, User user, Role role) throws SecurityException {
    String methodName = CLS_NM + ".canAssign";
    VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, methodName);
    VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, methodName);
    VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, methodName);
    boolean result;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    UserRole uRole = new UserRole(user.getUserId(), role.getName());
    request.setSession(session);
    request.setEntity(uRole);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_ASSIGN);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        result = response.getAuthorized();
        Session outSession = response.getSession();
        session.copy(outSession);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return result;
}
Also used : 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) Session(org.apache.directory.fortress.core.model.Session)

Example 72 with UserRole

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

the class GroupMgrRestImpl method groupRoles.

/**
 * {@inheritDoc}
 */
@Override
public List<UserRole> groupRoles(Group group) throws SecurityException {
    VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".groupRoles");
    List<UserRole> retRoles;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(group);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.GROUP_ROLE_ASGNED);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retRoles = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retRoles;
}
Also used : 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 73 with UserRole

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

the class ReviewMgrConsole method displayUsers.

/**
 * Description of the Method
 */
protected void displayUsers() {
    try {
        User ue;
        ArrayList list = (ArrayList) rm.findUsers(new User());
        int size = list.size();
        for (int i = 0; i < size; i++) {
            ue = (User) list.get(i);
            System.out.println("USER[" + i + "]");
            System.out.println("    userId      [" + ue.getUserId() + "]");
            System.out.println("    internalId  [" + ue.getInternalId() + "]");
            System.out.println("    description [" + ue.getDescription() + "]");
            System.out.println("    common name [" + ue.getCn() + "]");
            System.out.println("    surname     [" + ue.getSn() + "]");
            System.out.println("    orgUnitId   [" + ue.getOu() + "]");
            System.out.println("    pwpolicy    [" + ue.getPwPolicy() + "]");
            printTemporal(ue, "USER");
            printPosixAccount(ue, "POSIX");
            printAddress(ue.getAddress(), "ADDRESS");
            printPhone(ue.getPhones(), "PHONES");
            printPhone(ue.getMobiles(), "MOBILES");
            if (ue.getRoles() != null) {
                for (UserRole ur : ue.getRoles()) {
                    printTemporal(ur, "RBACROLE");
                }
            }
            if (ue.getAdminRoles() != null) {
                for (UserAdminRole ur : ue.getAdminRoles()) {
                    printAdminRole(ur);
                    printTemporal(ur, "ADMINROLE");
                }
            }
            System.out.println();
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("displayUsers caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : User(org.apache.directory.fortress.core.model.User) UserRole(org.apache.directory.fortress.core.model.UserRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) ArrayList(java.util.ArrayList) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 74 with UserRole

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

the class ReviewMgrConsole method assignedRoles.

/**
 */
void assignedRoles() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter UserId:");
        User user = new User();
        user.setUserId(ReaderUtil.readLn());
        List<UserRole> userRoles = rm.assignedRoles(user);
        if (userRoles != null) {
            for (UserRole userRole : userRoles) {
                System.out.println("ROLE OBJECT:");
                System.out.println("    name      [" + userRole.getName() + "]");
                printTemporal(userRole, "RBACROLE");
            }
        } else {
            System.out.println("    userId [" + user.getUserId() + "] has no roles");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("assignedRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : User(org.apache.directory.fortress.core.model.User) UserRole(org.apache.directory.fortress.core.model.UserRole)

Example 75 with UserRole

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

the class ReviewMgrConsole method findUsersByOrg.

/**
 */
void findUsersByOrg() {
    String szOu;
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter OrgUnit name");
        szOu = ReaderUtil.readLn();
        OrgUnit ou = new OrgUnit(szOu);
        ou.setType(OrgUnit.Type.USER);
        List<User> list = rm.findUsers(ou);
        int ctr = 0;
        for (User ue : list) {
            System.out.println("USER[" + ++ctr + "]");
            System.out.println("    userId      [" + ue.getUserId() + "]");
            System.out.println("    internalId  [" + ue.getInternalId() + "]");
            System.out.println("    description [" + ue.getDescription() + "]");
            System.out.println("    common name [" + ue.getCn() + "]");
            System.out.println("    surname     [" + ue.getSn() + "]");
            System.out.println("    orgUnitId   [" + ue.getOu() + "]");
            System.out.println("    pwpolicy    [" + ue.getPwPolicy() + "]");
            printTemporal(ue, "USER");
            printAddress(ue.getAddress(), "ADDRESS");
            printPhone(ue.getPhones(), "PHONES");
            printPhone(ue.getMobiles(), "MOBILES");
            if (ue.getRoles() != null) {
                for (UserRole ur : ue.getRoles()) {
                    printTemporal(ur, "RBACROLE");
                }
            }
            if (ue.getAdminRoles() != null) {
                for (UserAdminRole ur : ue.getAdminRoles()) {
                    printAdminRole(ur);
                    printTemporal(ur, "ADMINROLE");
                }
            }
            if (ue.getProperties() != null && ue.getProperties().size() > 0) {
                int pctr = 0;
                for (Enumeration e = ue.getProperties().propertyNames(); e.hasMoreElements(); ) {
                    String key = (String) e.nextElement();
                    String val = ue.getProperty(key);
                    System.out.println("prop key[" + pctr + "]=" + key);
                    System.out.println("prop value[" + pctr++ + "]=" + val);
                }
            }
            System.out.println();
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("findUsersByOrg caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) User(org.apache.directory.fortress.core.model.User) Enumeration(java.util.Enumeration) UserRole(org.apache.directory.fortress.core.model.UserRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) Constraint(org.apache.directory.fortress.core.model.Constraint)

Aggregations

UserRole (org.apache.directory.fortress.core.model.UserRole)89 User (org.apache.directory.fortress.core.model.User)55 SecurityException (org.apache.directory.fortress.core.SecurityException)48 Session (org.apache.directory.fortress.core.model.Session)28 AccessMgr (org.apache.directory.fortress.core.AccessMgr)17 ArrayList (java.util.ArrayList)16 Role (org.apache.directory.fortress.core.model.Role)16 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)16 AdminMgr (org.apache.directory.fortress.core.AdminMgr)14 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)12 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)11 Constraint (org.apache.directory.fortress.core.model.Constraint)10 AdminRole (org.apache.directory.fortress.core.model.AdminRole)9 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)7 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)7 AccelMgr (org.apache.directory.fortress.core.AccelMgr)6 FinderException (org.apache.directory.fortress.core.FinderException)6 SDSet (org.apache.directory.fortress.core.model.SDSet)6 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)6 Enumeration (java.util.Enumeration)5