Search in sources :

Example 31 with ReviewMgr

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

the class ReviewMgrImplTest method assignedRoleNms.

/**
 * @param msg
 * @param uArray
 * @param rArray
 */
public static void assignedRoleNms(String msg, String[][] uArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] usr : uArray) {
            List<String> uRoles = reviewMgr.assignedRoles(UserTestData.getUserId(usr));
            assertNotNull(uRoles);
            assertTrue(CLS_NM + "assignedRoleNms list size check", rArray.length == uRoles.size());
            for (String[] url : rArray) {
                int indx = uRoles.indexOf(RoleTestData.getName(url));
                if (indx != -1) {
                    String uRole = uRoles.get(indx);
                    assertNotNull(uRole);
                    assertEquals(CLS_NM + ".assignedRoleNms failed compare role name", RoleTestData.getName(url), uRole);
                } else {
                    msg = "assignedRoleNms userId [" + UserTestData.getUserId(usr) + "] role [" + RoleTestData.getName(url) + "] failed list search";
                    LogUtil.logIt(msg);
                    fail(msg);
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("assignedRoleNms caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint)

Example 32 with ReviewMgr

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

the class ReviewMgrImplTest method rolePermissions.

/**
 * @param msg
 * @param rArray
 * @param pObjArray
 * @param pOpArray
 */
public static void rolePermissions(String msg, String[][] rArray, String[][] pObjArray, String[][] pOpArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] rle : rArray) {
            Role role = RoleTestData.getRole(rle);
            List<Permission> perms = reviewMgr.rolePermissions(role);
            assertNotNull(perms);
            assertTrue(CLS_NM + "rolePermissions list size check", pOpArray.length * pObjArray.length == perms.size());
            for (String[] obj : pObjArray) {
                for (String[] op : pOpArray) {
                    int indx = perms.indexOf(new Permission(PermTestData.getName(obj), PermTestData.getName(op), PermTestData.getObjId(op)));
                    if (indx != -1) {
                        Permission pOp = perms.get(indx);
                        assertNotNull(pOp);
                        PermTestData.assertEquals(PermTestData.getName(obj), pOp, op);
                        LOG.debug("rolePermissions role name [" + role.getName() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] successful");
                    } else {
                        msg = "rolePermissions role name [" + role.getName() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] failed list search";
                        LogUtil.logIt(msg);
                        fail(msg);
                    }
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("rolePermissions 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) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint)

Example 33 with ReviewMgr

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

the class ReviewMgrImplTest method authorizedUsers.

/**
 * @param msg
 * @param rArray
 * @param uArray
 */
public static void authorizedUsers(String msg, String[][] rArray, String[][] uArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] rle : rArray) {
            List<User> users = reviewMgr.authorizedUsers(new Role(RoleTestData.getName(rle)));
            assertNotNull(users);
            // LOG.debug("authorizedUsers list source size=" + uArray.length + " ldap size="  + users.size());
            assertTrue(CLS_NM + "authorizedUsers list size check", uArray.length == users.size());
            for (String[] usr : uArray) {
                int indx = users.indexOf(UserTestData.getUser(usr));
                if (indx != -1) {
                    User user = users.get(indx);
                    assertNotNull(user);
                    UserTestData.assertEquals(user, usr);
                    LOG.debug("authorizedUsers role name [" + RoleTestData.getName(rle) + "] userId [" + user.getUserId() + "] successful");
                } else {
                    msg = "authorizedUsers role [" + RoleTestData.getName(rle) + "] user [" + UserTestData.getUserId(usr) + "] failed list search";
                    LogUtil.logIt(msg);
                    fail(msg);
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("authorizedUsers 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) User(org.apache.directory.fortress.core.model.User) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint)

Example 34 with ReviewMgr

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

the class AdminMgrImplTest method addSsdRoleMember.

/**
 * @param sArray
 */
public static void addSsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] ssdle : sArray) {
            SDSet ssd = RoleTestData.getSDSet(ssdle);
            SDSet entity = adminMgr.createSsdSet(ssd);
            LOG.debug("addSsdRoleMember SSD [" + entity.getName() + "] successful");
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.addSsdRoleMember(ssd, role);
                List<SDSet> ssdSets = reviewMgr.ssdRoleSets(role);
                assertNotNull(ssdSets);
                assertTrue(CLS_NM + "addSsdRoleMember list size check", ssdSets.size() == 1);
                SDSet ssd2 = ssdSets.get(0);
                assertTrue(CLS_NM + "addSsdRoleMember SSD name check", ssd.getName().equals(ssd2.getName()));
                assertTrue(CLS_NM + "addSsdRoleMember SSD role check", ssd2.getMembers().contains(role.getName()));
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addSsdRoleMember 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 35 with ReviewMgr

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

the class AdminMgrImplTest method deleteSsdRoleMember.

/**
 * @param sArray
 */
private void deleteSsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] ssdle : sArray) {
            SDSet ssd = RoleTestData.getSDSet(ssdle);
            // first add all of the roles as members of SSD entity:
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                ssd.addMember(role.getName());
            }
            // now iterate over roles and remove from SSD set one at a time.
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.deleteSsdRoleMember(ssd, role);
                List<SDSet> ssdSets = reviewMgr.ssdRoleSets(role);
                assertTrue(CLS_NM + "deleteSsdRoleMember list size check ssdSets size [" + ssdSets.size() + "]", ssdSets.size() == 0);
            }
            adminMgr.deleteSsdSet(ssd);
            LOG.debug("deleteSsdRoleMember SSD [" + ssd.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("deleteSsdRoleMember 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)

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