Search in sources :

Example 16 with UserAdminRole

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

the class DelegatedAdminMgrConsole method assignUser.

protected void assignUser() {
    try {
        ReaderUtil.clearScreen();
        UserAdminRole uAdminRole = new UserAdminRole();
        System.out.println("Enter userId");
        uAdminRole.setUserId(ReaderUtil.readLn());
        System.out.println("Enter role name");
        uAdminRole.setName(ReaderUtil.readLn());
        dAmgr.assignUser(uAdminRole);
        System.out.println("userId [" + uAdminRole.getUserId() + "] name [" + uAdminRole.getName() + "]");
        System.out.println("has been assigned");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("assignUser caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Example 17 with UserAdminRole

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

the class DelegatedReviewMgrConsole method assignedRoles.

/**
 */
void assignedRoles() {
    String userId;
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter UserId to read admin roles:");
        userId = ReaderUtil.readLn();
        User user = new User();
        user.setUserId(userId);
        List<UserAdminRole> roles = rm.assignedRoles(user);
        for (UserAdminRole re : roles) {
            System.out.println("USER OBJECT:");
            System.out.println("    admin role  [" + re.getName() + "]");
            System.out.println("    OsU         [" + re.getOsUSet() + "]");
            System.out.println("    OsP         [" + re.getOsPSet() + "]");
            ReviewMgrConsole.printTemporal(re, "ADMINROLE");
        }
        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) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Example 18 with UserAdminRole

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

the class ReviewMgrConsole method findUsers.

/**
 * Description of the Method
 */
void findUsers() {
    String userVal;
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter User Search Value");
        userVal = ReaderUtil.readLn();
        User ue = new User();
        ue.setUserId(userVal);
        ArrayList list = (ArrayList) rm.findUsers(ue);
        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() + "]");
            System.out.println("    seqId       [" + ue.getSequenceId() + "]");
            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");
                }
            }
            if (ue.getProperties() != null && ue.getProperties().size() > 0) {
                int ctr = 0;
                for (Enumeration e = ue.getProperties().propertyNames(); e.hasMoreElements(); ) {
                    String key = (String) e.nextElement();
                    String val = ue.getProperty(key);
                    System.out.println("prop key[" + ctr + "]=" + key);
                    System.out.println("prop value[" + ctr++ + "]=" + val);
                }
            }
            System.out.println();
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("findUsers caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : 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) ArrayList(java.util.ArrayList) Constraint(org.apache.directory.fortress.core.model.Constraint)

Example 19 with UserAdminRole

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

the class ReviewMgrConsole method readUser.

/**
 * Description of the Method
 */
void readUser() {
    String userId;
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter UserId to read:");
        userId = ReaderUtil.readLn();
        User user = new User();
        user.setUserId(userId);
        User ue = rm.readUser(user);
        if (ue != null) {
            System.out.println("USER OBJECT:");
            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() + "]");
            printPosixAccount(ue, "POSIX");
            printTemporal(ue, "USER");
            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 ctr = 0;
                for (Enumeration e = ue.getProperties().propertyNames(); e.hasMoreElements(); ) {
                    String key = (String) e.nextElement();
                    String val = ue.getProperty(key);
                    System.out.println("prop key[" + ctr + "]=" + key);
                    System.out.println("prop value[" + ctr++ + "]=" + val);
                }
            }
        } else {
            System.out.println("    user [" + userId + "] was not found");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("readUser caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : 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)

Example 20 with UserAdminRole

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

the class AccessMgrSample method testDisplayUserSession.

/**
 * This test will display all of the User Session attributes to the System out of test machine.  It is intended
 * to demonstrate what data is carried within a User's Fortress Session object.
 */
public static void testDisplayUserSession() {
    String szLocation = ".testDisplayUserSession";
    try {
        // Instantiate the AccessMgr implementation.
        AccessMgr accessMgr = AccessMgrFactory.createInstance(TestUtils.getContext());
        // utility function will create an Fortress Session.  The Session contains the user's activated
        // roles along with other related attributes and status information (i.e. password status)
        Session session = createSession(CreateUserSample.TEST_USERID, CreateUserSample.TEST_PASSWORD, accessMgr);
        assertNotNull(session);
        User user = accessMgr.getUser(session);
        assertNotNull(user);
        LOG.info(szLocation);
        LOG.info("S   UID  [" + session.getUserId() + "]:");
        LOG.info("S   IID  [" + session.getInternalUserId() + "]");
        LOG.info("S   ERR  [" + session.getErrorId() + "]");
        LOG.info("S   WARN [" + session.getWarnings() + "]");
        LOG.info("S   MSG  [" + session.getMsg() + "]");
        LOG.info("S   EXP  [" + session.getExpirationSeconds() + "]");
        LOG.info("S   GRAC [" + session.getGraceLogins() + "]");
        LOG.info("S   AUTH [" + session.isAuthenticated() + "]");
        LOG.info("S   LAST [" + session.getLastAccess() + "]");
        LOG.info("S   SID  [" + session.getSessionId() + "]");
        LOG.info("------------------------------------------");
        LOG.info("U   UID  [" + user.getUserId() + "]");
        LOG.info("U   IID  [" + user.getInternalId() + "]");
        LOG.info("U   CN   [" + user.getCn() + "]");
        LOG.info("U   DESC [" + user.getDescription() + "]");
        LOG.info("U   OU   [" + user.getOu() + "]");
        LOG.info("U   SN   [" + user.getSn() + "]");
        LOG.info("U   BDTE [" + user.getBeginDate() + "]");
        LOG.info("U   EDTE [" + user.getEndDate() + "]");
        LOG.info("U   BLDT [" + user.getBeginLockDate() + "]");
        LOG.info("U   ELDT [" + user.getEndLockDate() + "]");
        LOG.info("U   DMSK [" + user.getDayMask() + "]");
        LOG.info("U   TO   [" + user.getTimeout() + "]");
        LOG.info("U   REST [" + user.isReset() + "]");
        if (user.getProperties() != null && user.getProperties().size() > 0) {
            int ctr = 0;
            for (Enumeration e = user.getProperties().propertyNames(); e.hasMoreElements(); ) {
                String key = (String) e.nextElement();
                String val = user.getProperty(key);
                LOG.info("U   PROP[" + ctr++ + "]=" + key + " VAL=" + val);
            }
        }
        List<UserRole> roles = session.getRoles();
        if (roles != null) {
            for (int i = 0; i < roles.size(); i++) {
                UserRole ur = roles.get(i);
                LOG.info("    USER ROLE[" + i + "]:");
                LOG.info("        role name [" + ur.getName() + "]");
                LOG.info("        begin time [" + ur.getBeginTime() + "]");
                LOG.info("        end time [" + ur.getEndTime() + "]");
                LOG.info("        begin date [" + ur.getBeginDate() + "]");
                LOG.info("        end date [" + ur.getEndDate() + "]");
                LOG.info("        begin lock [" + ur.getBeginLockDate() + "]");
                LOG.info("        end lock [" + ur.getEndLockDate() + "]");
                LOG.info("        day mask [" + ur.getDayMask() + "]");
                LOG.info("        time out [" + ur.getTimeout() + "]");
            }
        }
        List<UserAdminRole> aRoles = session.getAdminRoles();
        if (aRoles != null) {
            for (int i = 0; i < aRoles.size(); i++) {
                UserAdminRole ur = aRoles.get(i);
                LOG.info("    USER ADMIN ROLE[" + i + "]:");
                LOG.info("        admin role name [" + ur.getName() + "]");
                LOG.info("        OsU [" + ur.getOsUSet() + "]");
                LOG.info("        OsP [" + ur.getOsPSet() + "]");
                LOG.info("        begin range [" + ur.getBeginRange() + "]");
                LOG.info("        end range [" + ur.getEndRange() + "]");
                LOG.info("        begin time [" + ur.getBeginTime() + "]");
                LOG.info("        end time [" + ur.getEndTime() + "]");
                LOG.info("        begin date [" + ur.getBeginDate() + "]");
                LOG.info("        end date [" + ur.getEndDate() + "]");
                LOG.info("        begin lock [" + ur.getBeginLockDate() + "]");
                LOG.info("        end lock [" + ur.getEndLockDate() + "]");
                LOG.info("        day mask [" + ur.getDayMask() + "]");
                LOG.info("        time out [" + ur.getTimeout() + "]");
            }
        }
        java.util.Properties jProps = System.getProperties();
        if (jProps != null && jProps.size() > 0) {
            int ctr = 0;
            for (Enumeration e = jProps.propertyNames(); e.hasMoreElements(); ) {
                String key = (String) e.nextElement();
                String val = jProps.getProperty(key);
                LOG.info("J   PROP[" + ctr++ + "]=" + key + " VAL=" + val);
            }
        }
    } catch (SecurityException ex) {
        LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) Enumeration(java.util.Enumeration) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) SecurityException(org.apache.directory.fortress.core.SecurityException) AccessMgr(org.apache.directory.fortress.core.AccessMgr) UserRole(org.apache.directory.fortress.core.model.UserRole) Session(org.apache.directory.fortress.core.model.Session)

Aggregations

UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)34 User (org.apache.directory.fortress.core.model.User)16 SecurityException (org.apache.directory.fortress.core.SecurityException)12 UserRole (org.apache.directory.fortress.core.model.UserRole)10 AdminRole (org.apache.directory.fortress.core.model.AdminRole)8 Constraint (org.apache.directory.fortress.core.model.Constraint)6 Enumeration (java.util.Enumeration)5 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)5 ArrayList (java.util.ArrayList)4 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)4 Role (org.apache.directory.fortress.core.model.Role)4 Session (org.apache.directory.fortress.core.model.Session)4 TreeSet (java.util.TreeSet)3 AccessMgr (org.apache.directory.fortress.core.AccessMgr)3 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)3 PermObj (org.apache.directory.fortress.core.model.PermObj)3 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)2 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)2 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2