Search in sources :

Example 21 with UserAdminRole

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

the class DelegatedMgrImplTest method deassignAdminUserRole.

void deassignAdminUserRole(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr;
        if (isAdmin) {
            dAdminMgr = getManagedDelegatedMgr();
        } else {
            dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
        }
        int i = 0;
        for (String[] usr : uArray) {
            UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rArray[i]).getName());
            dAdminMgr.deassignUser(uAdminRole);
            i++;
        }
    } catch (SecurityException ex) {
        LOG.error("deassignAdminUserRole caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 22 with UserAdminRole

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

the class DelegatedMgrImplTest method deassignAdminUsers.

/**
 * @param msg
 * @param uArray
 * @param rArray
 */
void deassignAdminUsers(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr;
        DelReviewMgr dReviewMgr;
        if (isAdmin) {
            dAdminMgr = getManagedDelegatedMgr();
            dReviewMgr = getManagedDelegatedReviewMgr();
        } else {
            dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
            dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
        }
        int i = 0;
        for (String[] usr : uArray) {
            i++;
            for (String[] rle : rArray) {
                UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rle).getName());
                AdminRoleTestData.getRole(rle);
                dAdminMgr.deassignUser(uAdminRole);
                LOG.debug("deassignAdminUsers user [" + uAdminRole.getUserId() + "] role [" + uAdminRole.getName() + "] successful");
                // Let's double check the number of users associated with role:
                List<User> users = dReviewMgr.assignedUsers(AdminRoleTestData.getRole(rle));
                assertNotNull(users);
                // If this is the last user deassigned from role, both lists will be returned empty:
                if (i == uArray.length) {
                    assertTrue(users.size() == 0);
                } else {
                    assertTrue(CLS_NM + "deassignAdminUsers list size check", (rArray.length - i) == users.size());
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("deassignAdminUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 23 with UserAdminRole

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

the class DelegatedMgrImplTest method assignAdminUserRole.

public static void assignAdminUserRole(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr;
        if (isAdmin) {
            dAdminMgr = getManagedDelegatedMgr();
        } else {
            dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
        }
        int i = 0;
        for (String[] usr : uArray) {
            UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rArray[i]).getName());
            dAdminMgr.assignUser(uAdminRole);
            i++;
        }
    } catch (SecurityException ex) {
        LOG.error("assignAdminUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 24 with UserAdminRole

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

the class DelAccessMgrRestImpl method sessionAdminRoles.

/**
 * {@inheritDoc}
 */
@Override
public List<UserAdminRole> sessionAdminRoles(Session session) throws SecurityException {
    VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, CLS_NM + ".sessionAdminRoles");
    List<UserAdminRole> roles;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setSession(session);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_ROLES);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        roles = response.getEntities();
        Session outSession = response.getSession();
        session.copy(outSession);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return roles;
}
Also used : UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) 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 25 with UserAdminRole

use of org.apache.directory.fortress.core.model.UserAdminRole 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)

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