Search in sources :

Example 66 with UserRole

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

the class AdminManagerTest method addUsers.

/**
 * @param uArray
 */
private void addUsers(String msg, String[][] uArray, boolean isAdmin) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr;
        if (isAdmin) {
            adminMgr = getManagedAdminMgr();
        } else {
            adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        }
        for (String[] usr : uArray) {
            User user = UserTestData.getUser(usr);
            adminMgr.addUser(user);
            LOG.debug("addUsers user [" + user.getUserId() + "] successful");
            // Does User have Role assignments?
            Set<String> asgnRoles = UserTestData.getAssignedRoles(usr);
            if (asgnRoles != null) {
                for (String name : asgnRoles) {
                    adminMgr.assignUser(new UserRole(user.getUserId(), name));
                }
            }
        }
    } catch (SecurityException ex) {
        ex.printStackTrace();
        LOG.error("addUsers: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) UserRole(org.apache.directory.fortress.core.model.UserRole) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 67 with UserRole

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

the class AccelMgrConsole method addActiveRole.

void addActiveRole() {
    try {
        VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, "AccelMgrConsole.addActiveRole");
        ReaderUtil.clearScreen();
        System.out.println("Enter userId");
        String userId = ReaderUtil.readLn();
        ReaderUtil.clearScreen();
        System.out.println("Enter role name");
        String role = ReaderUtil.readLn();
        am.addActiveRole(session, new UserRole(userId, role));
        System.out.println("addActiveRole successful");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addActiveRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : UserRole(org.apache.directory.fortress.core.model.UserRole)

Example 68 with UserRole

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

the class AccelMgrConsole method sessionRoles.

void sessionRoles() {
    try {
        VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, "AccelMgrConsole.sessionRoles");
        ReaderUtil.clearScreen();
        List<UserRole> roles = am.sessionRoles(session);
        // System.out.println("    USER [" + session.getUserId() + "]:");
        if (roles != null) {
            for (int i = 0; i < roles.size(); i++) {
                UserRole ur = roles.get(i);
                System.out.println("    USER ROLE[" + i + "]:");
                System.out.println("        role name [" + ur.getName() + "]");
                System.out.println("        begin time [" + ur.getBeginTime() + "]");
                System.out.println("        end time [" + ur.getEndTime() + "]");
                System.out.println("        begin date [" + ur.getBeginDate() + "]");
                System.out.println("        end date [" + ur.getEndDate() + "]");
                System.out.println("        begin lock [" + ur.getBeginLockDate() + "]");
                System.out.println("        end lock [" + ur.getEndLockDate() + "]");
                System.out.println("        day mask [" + ur.getDayMask() + "]");
                System.out.println("        time out [" + ur.getTimeout() + "]");
            }
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("sessionRoles caught SecurityException=" + e, e);
    }
    ReaderUtil.readChar();
}
Also used : UserRole(org.apache.directory.fortress.core.model.UserRole)

Example 69 with UserRole

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

the class AccelMgrConsole method dropActiveRole.

void dropActiveRole() {
    try {
        VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, "AccelMgrConsole.dropActiveRole");
        ReaderUtil.clearScreen();
        System.out.println("Enter userId");
        String userId = ReaderUtil.readLn();
        ReaderUtil.clearScreen();
        System.out.println("Enter role name");
        String role = ReaderUtil.readLn();
        am.dropActiveRole(session, new UserRole(userId, role));
        System.out.println("dropActiveRole successful");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("dropActiveRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : UserRole(org.apache.directory.fortress.core.model.UserRole)

Example 70 with UserRole

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

the class AdminMgrConsole method deassignUser.

void deassignUser() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter userId");
        String userId = ReaderUtil.readLn();
        UserRole uRole = new UserRole();
        uRole.setUserId(userId);
        System.out.println("Enter role name");
        String roleNm = ReaderUtil.readLn();
        uRole.setName(roleNm);
        am.deassignUser(uRole);
        System.out.println("userId [" + userId + "] name [" + roleNm + "]");
        System.out.println("has been deassigned");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("deassignUser caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : UserRole(org.apache.directory.fortress.core.model.UserRole)

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