Search in sources :

Example 41 with ReviewMgr

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

the class AdminMgrImplTest method delRoleDescendant.

/**
 * @param msg
 */
private void delRoleDescendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] rle : rArray) {
            Role role = RoleTestData.getRole(rle);
            // use list because order is important for test structure:
            List<String> descs = RoleTestData.getRelationshipList(rle);
            if (descs != null) {
                if (RoleTestData.isTree(rle)) {
                    Role parent = role;
                    for (String desc : descs) {
                        Role child = new Role(desc);
                        adminMgr.deleteInheritance(parent, new Role(desc));
                        LOG.debug("delRoleDescendant asc role [" + role.getName() + "] desc role [" + desc + "] successful");
                        parent = child;
                    }
                } else {
                    for (String desc : descs) {
                        adminMgr.deleteInheritance(role, new Role(desc));
                        LOG.debug("delRoleDescendant asc role [" + role.getName() + "] desc role [" + desc + "] successful");
                    }
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String desc : inheritances) {
                    adminMgr.deleteInheritance(role, new Role(desc));
                    LOG.debug("delRoleDescendant asc role [" + role.getName() + "] desc role [" + desc + "] successful");
                }
            }
            adminMgr.deleteRole(role);
            LOG.debug("delRoleDescendant remove asc role [" + role.getName() + "] successful");
        }
        // cleanup the last row of descendants from roles data set.
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        String roleSrchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
        List<Role> cleanup = reviewMgr.findRoles(roleSrchVal);
        for (Role re : cleanup) {
            adminMgr.deleteRole(re);
            LOG.debug("delRoleDescendant cleanup role [" + re.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delRoleDescendant 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 42 with ReviewMgr

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

the class DelegatedMgrImplTest method loadAdminPolicy.

/**
 * @return
 */
public static boolean loadAdminPolicy() {
    boolean result = true;
    try {
        ReviewMgr rMgr = ReviewMgrFactory.createInstance(TestUtils.getContext());
        User admin = UserTestData.getUser(UserTestData.USERS_TU0[0]);
        rMgr.readUser(admin);
        result = false;
    } catch (SecurityException se) {
        String info = " loadAdminPolicy detected admin policy not loaded";
        LOG.debug(info);
    }
    return result;
}
Also used : User(org.apache.directory.fortress.core.model.User) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 43 with ReviewMgr

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

the class FortressAntLoadTest method readUsers.

private static void readUsers(String msg, List<UserAnt> users) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (User user : users) {
            User entity = reviewMgr.readUser(user);
            assertNotNull(entity);
            UserTestData.assertEquals(entity, user);
        }
    } catch (SecurityException ex) {
        LOG.error("readUsers 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) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 44 with ReviewMgr

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

the class FortressAntLoadTest method assignedRoles.

private static void assignedRoles(String msg, List<UserRole> userroles) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (UserRole userrole : userroles) {
            List<UserRole> assignedRoles = reviewMgr.assignedRoles(new User(userrole.getUserId()));
            assertNotNull(assignedRoles);
            int indx = assignedRoles.indexOf(userrole);
            assertTrue("Failed userrole name", indx != -1);
            UserRole assignedRole = assignedRoles.get(indx);
            TestUtils.assertTemporal(CLS_NM + ".assertEquals", userrole, assignedRole);
        }
    } catch (SecurityException ex) {
        LOG.error("assignedRoles 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)

Example 45 with ReviewMgr

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

the class FortressAntLoadTest method readPermissionOps.

/**
 * @param msg
 * @param permissions
 */
private static void readPermissionOps(String msg, List<PermAnt> permissions) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (PermAnt permAnt : permissions) {
            Permission entity = reviewMgr.readPermission(permAnt);
            assertNotNull(entity);
            assertTrue("Failed objName value compare", entity.getObjName().equals(permAnt.getObjName()));
            assertTrue("Failed opName value compare", entity.getOpName().equals(permAnt.getOpName()));
        }
    } catch (SecurityException ex) {
        LOG.error("readPermissionOps caught SecurityException rc=" + ex.getErrorId() + ", " + "msg=" + ex.getMessage() + ex);
        fail(ex.getMessage());
    }
}
Also used : PermAnt(org.apache.directory.fortress.core.ant.PermAnt) 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