Search in sources :

Example 66 with AdminMgr

use of org.apache.directory.fortress.core.AdminMgr 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 67 with AdminMgr

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

the class AdminMgrImplTest method addPermissionAttributeSet.

public static void addPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttr) {
    LogUtil.logIt(msg);
    PermissionAttributeSet paSet = new PermissionAttributeSet(name);
    paSet.setType(PermTestData.TPA_SET_TYPE);
    try {
        paSet.setAttributes(permAttr);
        AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        adminMgr.addPermissionAttributeSet(paSet);
        LOG.debug("addPermissionAttributeSet name [" + paSet.getName() + "] successful");
    } catch (SecurityException ex) {
        LOG.error("addPermissionAttributeSet name [" + paSet.getName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 68 with AdminMgr

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

the class AdminMgrImplTest method delPermOps.

/**
 * @param objArray
 * @param opArray
 */
public static void delPermOps(String msg, String[][] objArray, String[][] opArray, boolean isAdmin, boolean canFail) {
    LogUtil.logIt(msg);
    Permission pOp = new Permission();
    try {
        AdminMgr adminMgr;
        if (isAdmin) {
            adminMgr = getManagedAdminMgr();
        } else {
            adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        }
        for (String[] obj : objArray) {
            for (String[] op : opArray) {
                pOp = PermTestData.getOp(PermTestData.getName(obj), op);
                adminMgr.deletePermission(pOp);
                LOG.debug("delPermOps objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "]  objectId [" + pOp.getObjId() + "] successful");
            }
        }
    } catch (SecurityException ex) {
        if (!canFail) {
            LOG.error("delPermOps objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "]  objectId [" + pOp.getObjId() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
            fail(ex.getMessage());
        }
    }
}
Also used : Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 69 with AdminMgr

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

Example 70 with AdminMgr

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

the class AdminMgrImplTest method updateUsers.

/**
 * @param uArray
 */
public static void updateUsers(String msg, String[][] uArray) {
    LogUtil.logIt(msg);
    try {
        AdminMgr adminMgr = getManagedAdminMgr();
        for (String[] usr : uArray) {
            User user = UserTestData.getUser(usr);
            adminMgr.updateUser(user);
            LOG.debug("updateUsers user [" + user.getUserId() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("updateUsers: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Aggregations

AdminMgr (org.apache.directory.fortress.core.AdminMgr)104 SecurityException (org.apache.directory.fortress.core.SecurityException)89 Role (org.apache.directory.fortress.core.model.Role)40 User (org.apache.directory.fortress.core.model.User)39 UserRole (org.apache.directory.fortress.core.model.UserRole)35 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)27 Permission (org.apache.directory.fortress.core.model.Permission)18 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)16 SDSet (org.apache.directory.fortress.core.model.SDSet)12 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)11 PwPolicyMgr (org.apache.directory.fortress.core.PwPolicyMgr)7 PermObj (org.apache.directory.fortress.core.model.PermObj)7 AccessMgr (org.apache.directory.fortress.core.AccessMgr)6 PermissionAttributeSet (org.apache.directory.fortress.core.model.PermissionAttributeSet)3 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)1 FinderException (org.apache.directory.fortress.core.FinderException)1 AdminRole (org.apache.directory.fortress.core.model.AdminRole)1 Session (org.apache.directory.fortress.core.model.Session)1 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)1