Search in sources :

Example 26 with Role

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

the class AdminMgrImplTest method deleteDsdRoleMember.

/**
 * @param sArray
 */
private void deleteDsdRoleMember(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);
            // first add all of the roles as members of SSD entity:
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                dsd.addMember(role.getName());
            }
            // now iterate over roles and remove from DSD set one at a time.
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.deleteDsdRoleMember(dsd, role);
                List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
                assertTrue(CLS_NM + "deleteDsdRoleMember list size check", dsdSets.size() == 0);
            }
            adminMgr.deleteDsdSet(dsd);
            LOG.debug("deletedsdRoleMember DSD [" + dsd.getName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("deleteDsdRoleMember 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) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 27 with Role

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

the class AdminMgrImplTest method addDsdRoleMember.

/**
 * @param sArray
 */
public static void addDsdRoleMember(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("addDsdRoleMember DSD [" + entity.getName() + "] successful");
            for (String[] rle : rArray) {
                Role role = RoleTestData.getRole(rle);
                adminMgr.addDsdRoleMember(dsd, role);
                List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
                assertNotNull(dsdSets);
                assertTrue(CLS_NM + "addDsdRoleMember list size check", dsdSets.size() == 1);
                SDSet dsd2 = dsdSets.get(0);
                assertTrue(CLS_NM + "addDsdRoleMember DSD name check", dsd.getName().equals(dsd2.getName()));
                assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().contains(role.getName()));
            // assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().containsKey(role.getName()));
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addDsdRoleMember 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) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 28 with Role

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

the class AdminMgrImplTest method addRoleAscendant.

/**
 * @param msg
 * @param rArray
 */
public static void addRoleAscendant(String msg, String[][] rArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] rle : rArray) {
            Role role = RoleTestData.getRole(rle);
            if (RoleTestData.isCreate(rle)) {
                adminMgr.addRole(role);
                LOG.debug("addAscendant add role [" + role.getName() + "] successful");
            }
            Set<String> ascs = RoleTestData.getRelationships(rle);
            if (ascs != null) {
                for (String asc : ascs) {
                    adminMgr.addAscendant(role, new Role(asc));
                    LOG.debug("addAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
                }
            }
            Set<String> inheritances = RoleTestData.getInheritances(rle);
            if (inheritances != null) {
                for (String asc : inheritances) {
                    adminMgr.addInheritance(new Role(asc), role);
                    LOG.debug("addAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
                }
            }
        }
    } catch (SecurityException ex) {
        LOG.error("addDescendant 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 29 with Role

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

the class AdminMgrImplTest method addRoleGrantsH.

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

Example 30 with Role

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

the class AdminMgrImplTest method addRoles.

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

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