Search in sources :

Example 76 with Role

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

the class AdminMgrImplTest method delRoleGrantsHB.

/**
 * @param msg
 * @param rArray
 * @param objArray
 * @param opArray
 */
private void delRoleGrantsHB(String msg, String[][] uArray, String[][] rArray, String[][] objArray, String[][] opArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] obj : objArray) {
            int i = 0;
            for (String[] rle : rArray) {
                // Get Role[i] from test data:
                Role role = RoleTestData.getRole(rle);
                // Get Permission[i] from test data:
                String[] op = opArray[i];
                // Load the permission entity with data:
                Permission pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                // Grant Permission[i] to Role[i]:
                adminMgr.revokePermission(pOp, role);
                // Get User[i] from test data:
                String[] usr = uArray[i];
                // Load the User entity with data:
                User user = UserTestData.getUser(usr);
                // Grant Permission[i] to User[i]:
                adminMgr.revokePermission(pOp, user);
                i++;
                LOG.debug("delRoleGrantsHB userId [" + user.getUserId() + "] role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
            }
        }
    } catch (SecurityException ex) {
        LOG.error("delRoleGrantsHB 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) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 77 with Role

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

the class DelegatedMgrImplTest method delAdminRoleDescendant.

private void delAdminRoleDescendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
        for (String[] rle : rArray) {
            AdminRole adminRole = AdminRoleTestData.getRole(rle);
            // use list because order is important for test structure:
            List<String> descs = RoleTestData.getRelationshipList(rle);
            if (descs != null) {
                if (RoleTestData.isTree(rle)) {
                    AdminRole parent = adminRole;
                    for (String desc : descs) {
                        AdminRole child = new AdminRole(desc);
                        dAdminMgr.deleteInheritance(parent, new AdminRole(desc));
                        LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                        parent = child;
                    }
                } else {
                    for (String desc : descs) {
                        dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
                        LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                    }
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String desc : inheritances) {
                    dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
                    LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
                }
            }
            dAdminMgr.deleteRole(adminRole);
            LOG.debug("delAdminRoleDescendant remove asc adminRole [" + adminRole.getName() + "] successful");
        }
        // cleanup the last row of descendants from orgUnit data set.
        DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
        String srchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
        List<AdminRole> cleanup = dReviewMgr.findRoles(srchVal);
        for (Role re : cleanup) {
            dAdminMgr.deleteRole((AdminRole) re);
            LOG.debug("delAdminRoleDescendant cleanup adminRole [" + re.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("delOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelAdminMgr(org.apache.directory.fortress.core.DelAdminMgr) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminRole(org.apache.directory.fortress.core.model.AdminRole) UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) DelReviewMgr(org.apache.directory.fortress.core.DelReviewMgr)

Example 78 with Role

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

the class FortressAntLoadTest method readRoles.

private static void readRoles(String msg, List<Role> roles) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (Role role : roles) {
            Role entity = reviewMgr.readRole(role);
            assertNotNull(entity);
            assertTrue("Failed role name", entity.getName().equals(role.getName()));
            TestUtils.assertTemporal(CLS_NM + ".assertEquals", role, entity);
        }
    } 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 79 with Role

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

the class GroupMgrImplTest method deassignRoleMember.

private void deassignRoleMember(String message, Group group, String[][] roles) {
    LogUtil.logIt(message);
    try {
        groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
        for (String[] roleArray : roles) {
            Role role = RoleTestData.getRole(roleArray);
            groupMgr.deassign(group, role.getName());
        }
        LOG.debug("deassignRoleMember group [" + group.getName() + "] successful");
        int countOfOldRoles = group.getMembers().size();
        // read from LDAP and get count of members
        Group groupFromLdap = groupMgr.read(group);
        int actualAmountOfMembers = groupFromLdap.getMembers().size();
        assertEquals(CLS_NM + ".deassignRoleMember failed members size check", countOfOldRoles, actualAmountOfMembers);
    } catch (SecurityException ex) {
        ex.printStackTrace();
        LOG.error("deassignRoleMember: 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) Group(org.apache.directory.fortress.core.model.Group) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 80 with Role

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

the class GroupMgrImplTest method assignRoleMember.

private void assignRoleMember(String message, Group group, String[][] roles) {
    LogUtil.logIt(message);
    try {
        groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
        for (String[] roleArray : roles) {
            Role role = RoleTestData.getRole(roleArray);
            groupMgr.assign(group, role.getName());
        }
        LOG.debug("assignRoleMember group [" + group.getName() + "] successful");
        int countOfOldRoles = group.getMembers().size();
        int countOfNewRoles = roles.length;
        // read from LDAP and get count of members
        Group groupFromLdap = groupMgr.read(group);
        int actualAmountOfMembers = groupFromLdap.getMembers().size();
        assertEquals(CLS_NM + ".assignRoleMember failed members size check", countOfOldRoles + countOfNewRoles, actualAmountOfMembers);
    } catch (SecurityException ex) {
        ex.printStackTrace();
        LOG.error("assignRoleMember: 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) Group(org.apache.directory.fortress.core.model.Group) SecurityException(org.apache.directory.fortress.core.SecurityException)

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