Search in sources :

Example 21 with DelAdminMgr

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

the class DelegatedMgrImplTest method deleteAdminRoles.

/**
 * @param rArray
 */
private void deleteAdminRoles(String msg, String[][] rArray, boolean isAdmin) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr;
        if (isAdmin) {
            dAdminMgr = getManagedDelegatedMgr();
        } else {
            dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
        }
        for (String[] rle : rArray) {
            AdminRole role = new AdminRole();
            role.setName(RoleTestData.getName(rle));
            dAdminMgr.deleteRole(role);
            LOG.debug("deleteAdminRoles role [" + role.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("deleteAdminRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole)

Example 22 with DelAdminMgr

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

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

the class DelegatedMgrImplTest method deleteOrgUnits.

/**
 * @param msg
 * @param oArray
 */
private void deleteOrgUnits(String msg, String[][] oArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit ou = OrgUnitTestData.getOrgUnit(ole);
            dAdminMgr.delete(ou);
            LOG.debug("deleteOrgUnits ou [" + ou.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("deleteOrgUnits caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 24 with DelAdminMgr

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

the class DelegatedMgrImplTest method delAdminRoleAscendant.

/**
 * @param msg
 * @param rArray
 */
private void delAdminRoleAscendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            Set<String> ascs = RoleTestData.getRelationships(rle);
            if (ascs != null) {
                for (String asc : ascs) {
                    dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
                    LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc adminRole [" + asc + "] successful");
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String asc : inheritances) {
                    dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
                    LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc orgUnit [" + asc + "] successful");
                }
            }
            dAdminMgr.deleteRole(adminRole);
            LOG.debug("delAdminRoleAscendant remove desc adminRole [" + adminRole.getName() + "] successful");
        }
        // cleanup the top ascendant from orgUnit data set.
        DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
        String adminRoleSrchVal = RoleTestData.getName(rArray[0]);
        // stip off prefix and search:
        adminRoleSrchVal = adminRoleSrchVal.substring(0, 3);
        List<AdminRole> cleanup = dReviewMgr.findRoles(adminRoleSrchVal);
        for (AdminRole re : cleanup) {
            dAdminMgr.deleteRole(re);
            LOG.debug("delAdminRoleAscendant cleanup adminRole [" + re.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delAdminRoleAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 25 with DelAdminMgr

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

the class DelegatedMgrImplTest method delAdminRoleDescendant.

private void delAdminRoleDescendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            // use list because order is important for test structure:
            List<String> descs = RoleTestData.getRelationshipList(rle);
            if (descs != null) {
                if (RoleTestData.isTree(rle)) {
                    AdminRole parent = adminRole;
                    for (String desc : descs) {
                        AdminRole child = new AdminRole(desc);
                        dAdminMgr.deleteInheritance(parent, new AdminRole(desc));
                        LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                        parent = child;
                    }
                } else {
                    for (String desc : descs) {
                        dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
                        LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                    }
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String desc : inheritances) {
                    dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
                    LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                }
            }
            dAdminMgr.deleteRole(adminRole);
            LOG.debug("delAdminRoleDescendant remove asc adminRole [" + adminRole.getName() + "] successful");
        }
        // cleanup the last row of descendants from orgUnit data set.
        DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
        String srchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
        List<AdminRole> cleanup = dReviewMgr.findRoles(srchVal);
        for (Role re : cleanup) {
            dAdminMgr.deleteRole((AdminRole) re);
            LOG.debug("delAdminRoleDescendant cleanup adminRole [" + re.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Aggregations

DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)39 SecurityException (org.apache.directory.fortress.core.SecurityException)39 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)26 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)13 DelReviewMgr (org.apache.directory.fortress.core.DelReviewMgr)9 AdminRole (org.apache.directory.fortress.core.model.AdminRole)9 HashSet (java.util.HashSet)4 FinderException (org.apache.directory.fortress.core.FinderException)3 ArrayList (java.util.ArrayList)2 User (org.apache.directory.fortress.core.model.User)2 Role (org.apache.directory.fortress.core.model.Role)1