Search in sources :

Example 6 with ReviewMgr

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

the class AdminMgrImplTest method delRoleAscendant.

/**
 * @param msg
 * @param rArray
 */
private void delRoleAscendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] rle : rArray) {
            Role role = RoleTestData.getRole(rle);
            Set<String> ascs = RoleTestData.getRelationships(rle);
            if (ascs != null) {
                for (String asc : ascs) {
                    adminMgr.deleteInheritance(new Role(asc), role);
                    LOG.debug("delRoleAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String asc : inheritances) {
                    adminMgr.deleteInheritance(new Role(asc), role);
                    LOG.debug("delRoleAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
                }
            }
            adminMgr.deleteRole(role);
            LOG.debug("delRoleAscendant remove desc role [" + role.getName() + "] successful");
        }
        // cleanup the top ascendant from roles data set.
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        String roleSrchVal = RoleTestData.getName(rArray[0]);
        roleSrchVal = roleSrchVal.substring(0, roleSrchVal.length() - 8);
        List<Role> cleanup = reviewMgr.findRoles(roleSrchVal);
        for (Role re : cleanup) {
            adminMgr.deleteRole(re);
            LOG.debug("delRoleAscendant cleanup role [" + re.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delRoleAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 7 with ReviewMgr

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

the class AdminMgrImplTest method deassignUsers.

/**
 * @param msg
 * @param uArray
 * @param rArray
 */
void deassignUsers(String msg, String[][] uArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        int i = 0;
        for (String[] usr : uArray) {
            i++;
            for (String[] rle : rArray) {
                UserRole uRole = new UserRole(UserTestData.getUserId(usr), RoleTestData.getName(rle));
                adminMgr.deassignUser(uRole);
                LOG.debug("deassignUsers user [" + uRole.getUserId() + "] role [" + uRole.getName() + "] successful");
                // Double check the number of users associated with role:
                // This one retrieves the collection of all "roleOccupant" attributes associated with the role node:
                List<String> users = reviewMgr.assignedUsers(RoleTestData.getRole(rle), rArray.length);
                // This one searches across all Users and pull back list of type "User":
                List<User> users2 = reviewMgr.authorizedUsers(RoleTestData.getRole(rle));
                assertNotNull(users);
                assertNotNull(users2);
                // If this is the last user deassigned from role, both lists will be returned empty:
                if (i == uArray.length) {
                    assertTrue(users.size() == 0);
                    assertTrue(users2.size() == 0);
                } else {
                    assertTrue(CLS_NM + "deassignUsers list size check", (rArray.length - i) == users.size());
                    assertTrue(CLS_NM + "deassignUsers list2 size check", (rArray.length - i) == users2.size());
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("deassignUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) UserRole(org.apache.directory.fortress.core.model.UserRole) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 8 with ReviewMgr

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

the class AdminMgrImplTest method deleteDsdRoleMember.

/**
 * @param sArray
 */
private void deleteDsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] dsdle : sArray) {
            SDSet dsd = RoleTestData.getSDSet(dsdle);
            // first add all of the roles as members of SSD entity:
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                dsd.addMember(role.getName());
            }
            // now iterate over roles and remove from DSD set one at a time.
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.deleteDsdRoleMember(dsd, role);
                List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
                assertTrue(CLS_NM + "deleteDsdRoleMember list size check", dsdSets.size() == 0);
            }
            adminMgr.deleteDsdSet(dsd);
            LOG.debug("deletedsdRoleMember DSD [" + dsd.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("deleteDsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 9 with ReviewMgr

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

the class AdminMgrImplTest method addDsdRoleMember.

/**
 * @param sArray
 */
public static void addDsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] dsdle : sArray) {
            SDSet dsd = RoleTestData.getSDSet(dsdle);
            SDSet entity = adminMgr.createDsdSet(dsd);
            LOG.debug("addDsdRoleMember DSD [" + entity.getName() + "] successful");
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.addDsdRoleMember(dsd, role);
                List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
                assertNotNull(dsdSets);
                assertTrue(CLS_NM + "addDsdRoleMember list size check", dsdSets.size() == 1);
                SDSet dsd2 = dsdSets.get(0);
                assertTrue(CLS_NM + "addDsdRoleMember DSD name check", dsd.getName().equals(dsd2.getName()));
                assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().contains(role.getName()));
            // assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().containsKey(role.getName()));
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addDsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 10 with ReviewMgr

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

the class FortressAntLoadTest method permissionRoles.

private static void permissionRoles(String msg, List<PermGrant> permGrants) {
    LogUtil.logIt(msg);
    Permission pOp;
    try {
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (PermGrant permGrant : permGrants) {
            pOp = new Permission();
            pOp.setObjName(permGrant.getObjName());
            pOp.setOpName(permGrant.getOpName());
            pOp.setObjId(permGrant.getObjId());
            List<String> roles = reviewMgr.permissionRoles(pOp);
            assertNotNull(roles);
            int indx = roles.indexOf(permGrant.getRoleNm());
            assertTrue("Failed to find roleNm: " + permGrant.getRoleNm(), indx != -1);
        }
    } catch (SecurityException ex) {
        LOG.error("permissionRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : PermGrant(org.apache.directory.fortress.core.model.PermGrant) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException)

Aggregations

ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)75 SecurityException (org.apache.directory.fortress.core.SecurityException)65 UserRole (org.apache.directory.fortress.core.model.UserRole)32 User (org.apache.directory.fortress.core.model.User)31 Role (org.apache.directory.fortress.core.model.Role)30 AdminMgr (org.apache.directory.fortress.core.AdminMgr)27 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)22 Permission (org.apache.directory.fortress.core.model.Permission)16 SDSet (org.apache.directory.fortress.core.model.SDSet)8 PermObj (org.apache.directory.fortress.core.model.PermObj)5 ArrayList (java.util.ArrayList)3 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)3 PermAnt (org.apache.directory.fortress.core.ant.PermAnt)2 CSVWriter (au.com.bytecode.opencsv.CSVWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Map (java.util.Map)1 AccessMgr (org.apache.directory.fortress.core.AccessMgr)1