Search in sources :

Example 56 with Role

use of org.apache.directory.fortress.core.model.Role 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 57 with Role

use of org.apache.directory.fortress.core.model.Role 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 58 with Role

use of org.apache.directory.fortress.core.model.Role 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)

Example 59 with Role

use of org.apache.directory.fortress.core.model.Role 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 60 with Role

use of org.apache.directory.fortress.core.model.Role 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)

Aggregations

Role (org.apache.directory.fortress.core.model.Role)117 UserRole (org.apache.directory.fortress.core.model.UserRole)83 SecurityException (org.apache.directory.fortress.core.SecurityException)66 AdminMgr (org.apache.directory.fortress.core.AdminMgr)40 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)30 User (org.apache.directory.fortress.core.model.User)30 AdminRole (org.apache.directory.fortress.core.model.AdminRole)25 Permission (org.apache.directory.fortress.core.model.Permission)24 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)17 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)15 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)15 Relationship (org.apache.directory.fortress.core.model.Relationship)7 SDSet (org.apache.directory.fortress.core.model.SDSet)7 FinderException (org.apache.directory.fortress.core.FinderException)6 PermObj (org.apache.directory.fortress.core.model.PermObj)6 ArrayList (java.util.ArrayList)5 Group (org.apache.directory.fortress.core.model.Group)5 Constraint (org.apache.directory.fortress.core.model.Constraint)4 FortRequest (org.apache.directory.fortress.core.model.FortRequest)4 FortResponse (org.apache.directory.fortress.core.model.FortResponse)4