Search in sources :

Example 6 with DelAdminMgr

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

the class DelegatedMgrImplTest method addOrgUnitAscendant.

/**
 * @param msg
 * @param oArray
 * @param type
 */
public static void addOrgUnitAscendant(String msg, String[][] oArray, OrgUnit.Type type) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit orgUnit = OrgUnitTestData.getOrgUnit(ole);
            if (OrgUnitTestData.isCreate(ole)) {
                dAdminMgr.add(orgUnit);
                LOG.debug("addOrgUnitAscendant add orgUnit [" + orgUnit.getName() + "] successful");
            }
            Set<String> ascs = new HashSet<String>();
            OrgUnitTestData.getRelationship(ascs, ole);
            for (String asc : ascs) {
                dAdminMgr.addAscendant(orgUnit, new OrgUnit(asc, type));
                LOG.debug("addOrgUnitAscendant desc role [" + orgUnit.getName() + "] asc role [" + asc + "] successful");
            }
            Set<String> inheritances = OrgUnitTestData.getInheritances(ole);
            if (inheritances != null) {
                for (String asc : inheritances) {
                    dAdminMgr.addInheritance(new OrgUnit(asc, type), orgUnit);
                    LOG.debug("addOrgUnitAscendant desc role [" + orgUnit.getName() + "] asc role [" + asc + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addOrgUnitAscendant 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) HashSet(java.util.HashSet)

Example 7 with DelAdminMgr

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

the class DelegatedMgrImplTest method deleteInheritedOrgUnits.

/**
 * @param msg
 * @param oArray
 */
private void deleteInheritedOrgUnits(String msg, String[][] oArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit child = OrgUnitTestData.getOrgUnit(ole);
            Set<String> parents = new HashSet<String>();
            OrgUnitTestData.getRelationship(parents, ole);
            for (String pOrg : parents) {
                OrgUnit parent = new OrgUnit(pOrg);
                parent.setType(child.getType());
                // public void deleteInheritance(OrgUnit parent, OrgUnit child)
                dAdminMgr.deleteInheritance(parent, child);
                LOG.debug("deleteInheritedOrgUnits child org [" + child.getName() + "] parent org [" + pOrg + "] successful");
            }
        }
    } catch (SecurityException ex) {
        LOG.error("deleteInheritedOrgUnits 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) HashSet(java.util.HashSet)

Example 8 with DelAdminMgr

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

the class DelegatedMgrImplTest method addAdminRoleDescendant.

/**
 * @param msg
 * @param rArray
 */
public static void addAdminRoleDescendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        int ctr = 0;
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            if (ctr++ == 0 || RoleTestData.isTree(rle)) {
                dAdminMgr.addRole(adminRole);
                LOG.debug("addAdminRoleDescendant add role [" + adminRole.getName() + "] successful");
            }
            // 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.addDescendant(parent, new AdminRole(desc));
                        LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
                        parent = child;
                    }
                } else {
                    for (String desc : descs) {
                        dAdminMgr.addDescendant(adminRole, new AdminRole(desc));
                        LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
                    }
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String desc : inheritances) {
                    dAdminMgr.addInheritance(adminRole, new AdminRole(desc));
                    LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addAdminRoleDescendant 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 9 with DelAdminMgr

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

the class DelegatedMgrImplTest method assignAdminUsers.

/**
 * @param msg
 * @param uArray
 * @param rArray
 */
public static void assignAdminUsers(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());
                dAdminMgr.assignUser(uAdminRole);
                LOG.debug("assignAdminUsers user [" + uAdminRole.getUserId() + "] role [" + uAdminRole.getName() + "] successful");
                // Let's double check the number of users not associated with role:
                // This one retrieves the collection of all "roleOccupant" attributes associated with the role node:
                List<User> users = dReviewMgr.assignedUsers(AdminRoleTestData.getRole(rle));
                assertNotNull(users);
                assertTrue(CLS_NM + "assignAdminUsers list size check", i == users.size());
            }
        }
    } catch (SecurityException ex) {
        LOG.error("assignAdminUsers 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 10 with DelAdminMgr

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

the class DelegatedMgrImplTest method updateOrgUnits.

/**
 * @param msg
 * @param oArray
 */
public static void updateOrgUnits(String msg, String[][] oArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] ole : oArray) {
            OrgUnit ou = OrgUnitTestData.getOrgUnit(ole);
            dAdminMgr.update(ou);
            LOG.debug("updateOrgUnits ou [" + ou.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("updateOrgUnits 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)

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