Search in sources :

Example 71 with Role

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

the class AdminMgrImplTest method addInheritedRoles.

/**
 * @param rArray
 */
public static void addInheritedRoles(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] rle : rArray) {
            Role role = RoleTestData.getRole(rle);
            Set<String> parents = RoleTestData.getRelationships(rle);
            if (parents != null) {
                for (String pRole : parents) {
                    adminMgr.addInheritance(new Role(pRole), role);
                    LOG.debug("addInheritedRoles child role [" + role.getName() + "] parent role [" + pRole + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addInheritedRoles 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) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 72 with Role

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

the class AdminMgrImplTest method delRoleGrants.

/**
 * @param rArray
 * @param objArray
 * @param opArray
 */
public static void delRoleGrants(String msg, String[][] rArray, String[][] objArray, String[][] opArray, boolean isAdmin) {
    LogUtil.logIt(msg);
    Permission pOp = new Permission();
    Role role = new Role();
    try {
        AdminMgr adminMgr;
        if (isAdmin) {
            adminMgr = getManagedAdminMgr();
        } else {
            adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        }
        for (String[] rle : rArray) {
            for (String[] obj : objArray) {
                for (String[] op : opArray) {
                    role = new Role(RoleTestData.getName(rle));
                    pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                    adminMgr.revokePermission(pOp, role);
                    LOG.debug("delRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("delRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] 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) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 73 with Role

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

the class AdminMgrImplTest method updateRoles.

/**
 * @param msg
 * @param rArray
 */
public static void updateRoles(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] rle : rArray) {
            Role role = RoleTestData.getRole(rle);
            Role entity = adminMgr.updateRole(role);
            LOG.debug("updateRoles role [" + entity.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("updateRoles 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) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 74 with Role

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

the class AdminMgrImplTest method setDsdCardinality.

/**
 * @param msg
 * @param sArray
 * @param rArray
 */
public static void setDsdCardinality(String msg, String[][] sArray, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
        for (String[] dsdle : sArray) {
            SDSet dsd = RoleTestData.getSDSet(dsdle);
            SDSet entity = adminMgr.createDsdSet(dsd);
            LOG.debug("setDsdCardinality DSD [" + entity.getName() + "] successful");
            int cardinality = 1;
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.addDsdRoleMember(dsd, role);
                adminMgr.setDsdSetCardinality(dsd, cardinality);
                int currentCardinality = reviewMgr.dsdRoleSetCardinality(dsd);
                assertTrue(CLS_NM + "setDsdCardinality cardinality check", currentCardinality == cardinality++);
            }
        }
    } catch (SecurityException ex) {
        LOG.error("setDsdCardinality 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) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 75 with Role

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

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