Search in sources :

Example 26 with ReviewMgr

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

the class ReviewMgrImplTest method userPermissions.

/**
 * @param msg
 * @param uArray
 * @param pObjArray
 * @param pOpArray
 */
public static void userPermissions(String msg, String[][] uArray, String[][] pObjArray, String[][] pOpArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] usr : uArray) {
            User user = UserTestData.getUser(usr);
            List<Permission> perms = reviewMgr.userPermissions(user);
            assertNotNull(perms);
            assertTrue(CLS_NM + "userPermissions 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("userPermissions userId [" + user.getUserId() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] successful");
                    } else {
                        msg = "userPermissions userId [" + user.getUserId() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] failed list search";
                        LogUtil.logIt(msg);
                        fail(msg);
                    }
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("userPermissions 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) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint)

Example 27 with ReviewMgr

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

the class ReviewMgrImplTest method searchRolesNms.

/**
 * @param msg
 * @param srchValue
 * @param rArray
 */
public static void searchRolesNms(String msg, String srchValue, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        List<String> roles = reviewMgr.findRoles(srchValue, rArray.length);
        assertNotNull(roles);
        assertTrue(CLS_NM + "searchRolesNms list size check", rArray.length == roles.size());
        for (String[] rle : rArray) {
            int indx = roles.indexOf(RoleTestData.getName(rle));
            if (indx != -1) {
                String roleNm = roles.get(indx);
                assertNotNull(roleNm);
                assertEquals(CLS_NM + ".searchRolesNms failed compare role name", RoleTestData.getName(rle), roleNm);
            } else {
                msg = "searchRolesNms srchValue [" + srchValue + "] failed list search";
                LogUtil.logIt(msg);
                fail(msg);
            }
        }
    } catch (SecurityException ex) {
        LOG.error("searchRolesNms srchValue [" + srchValue + "] 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 28 with ReviewMgr

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

the class ReviewMgrImplTest method assignedUserIds.

/**
 * @param msg
 * @param rArray
 * @param uArray
 */
public static void assignedUserIds(String msg, String[][] rArray, String[][] uArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] rle : rArray) {
            List<String> users = reviewMgr.assignedUsers(new Role(RoleTestData.getName(rle)), uArray.length);
            assertNotNull(users);
            assertTrue(CLS_NM + ".assignedUserIds list size check", uArray.length == users.size());
            for (String[] usr : uArray) {
                users.indexOf(UserTestData.getUserId(usr));
            // todo - figure out how to compare userid dns with userids:
            }
        }
    } catch (SecurityException ex) {
        LOG.error("assignedUserIds 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)

Example 29 with ReviewMgr

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

the class ReviewMgrImplTest method readRoles.

/**
 * @param msg
 * @param rArray
 */
public static void readRoles(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] rle : rArray) {
            Role entity = reviewMgr.readRole(new Role(RoleTestData.getName(rle)));
            RoleTestData.assertEquals(entity, rle);
            LOG.debug("readRoles [" + entity.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("readRoles caught SecurityException=" + 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)

Example 30 with ReviewMgr

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

the class ReviewMgrImplTest method searchRoles.

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

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