Search in sources :

Example 21 with ReviewMgr

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

the class CreateUserSample method teardownRequired.

/**
 * Determines if teardown needs to occur on sample data.
 *
 * @return true if teardown is required
 */
static boolean teardownRequired() {
    // The default for this check is 'true'
    boolean tearDown = true;
    String methodName = ".teardownRequired";
    try {
        ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(TestUtils.getContext());
        User inUser = new User(TEST_USERID, TEST_PASSWORD);
        reviewMgr.readUser(inUser);
    // If we get here, the sample data needs to be removed:
    } catch (SecurityException ex) {
        if (ex.getErrorId() == GlobalErrIds.USER_NOT_FOUND) {
            // If we get here the sample data does not need to be removed:
            tearDown = false;
        } else {
            String warning = methodName + " caught SecurityException=" + ex.getMessage();
            LOG.warn(warning);
        }
    }
    LOG.info(methodName + ":" + tearDown);
    return tearDown;
}
Also used : User(org.apache.directory.fortress.core.model.User) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 22 with ReviewMgr

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

the class ReviewMgrImplTest method findUserRoleWithConstraints.

public static void findUserRoleWithConstraints(String msg, String usr, String role, RoleConstraint.RCType rcType, String paSetName) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        List<UserRole> urs = reviewMgr.assignedUsers(new Role(role), rcType, paSetName);
        assertTrue(urs.size() > 0);
        assertTrue(urs.get(0).getRoleConstraints().size() > 0);
        LOG.debug("findUserRoleWithConstraints paSetName [" + paSetName + "] successful");
    } catch (SecurityException ex) {
        LOG.error("findUserRoleWithConstraints paSetName [" + paSetName + "] 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) UserRole(org.apache.directory.fortress.core.model.UserRole) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 23 with ReviewMgr

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

the class ReviewMgrImplTest method readPermissionObjs.

/**
 * @param msg
 * @param pArray
 */
public static void readPermissionObjs(String msg, String[][] pArray) {
    PermObj pObj = new PermObj();
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] objs : pArray) {
            pObj = new PermObj();
            pObj.setObjName(PermTestData.getName(objs));
            PermObj entity = reviewMgr.readPermObj(pObj);
            assertNotNull(entity);
            PermTestData.assertEquals(entity, objs);
            LOG.debug("readPermissionObjs object name [" + pObj.getObjName() + "] successful");
        }
    } catch (SecurityException ex) {
        LOG.error("readPermissionOps object name [" + pObj.getObjName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage() + ex);
        fail(ex.getMessage());
    }
}
Also used : PermObj(org.apache.directory.fortress.core.model.PermObj) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 24 with ReviewMgr

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

the class ReviewMgrImplTest method readPermissionAttributeSet.

public static void readPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttributes) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        PermissionAttributeSet entity = reviewMgr.readPermAttributeSet(new PermissionAttributeSet(name));
        assertNotNull(entity);
        assertEquals(name, entity.getName());
        assertEquals(PermTestData.TPA_SET_TYPE, entity.getType());
        for (PermissionAttribute pa : permAttributes) {
            assertTrue(entity.getAttributes().contains(pa));
        }
        LOG.debug("readPermissionAttributeSet name [" + name + "] successful");
    } catch (SecurityException ex) {
        LOG.error("readPermissionAttributeSet name [" + name + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage() + ex);
        fail(ex.getMessage());
    }
}
Also used : PermissionAttributeSet(org.apache.directory.fortress.core.model.PermissionAttributeSet) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) PermissionAttribute(org.apache.directory.fortress.core.model.PermissionAttribute) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 25 with ReviewMgr

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

the class ReviewMgrImplTest method readUserRoleConstraint.

public static void readUserRoleConstraint(String msg, String[] usr, String[] rle, RoleConstraint rc) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        User user = UserTestData.getUser(usr);
        Role role = RoleTestData.getRole(rle);
        List<UserRole> urs = reviewMgr.assignedRoles(user);
        boolean uraFound = false;
        boolean urcFound = false;
        for (UserRole ur : urs) {
            if (ur.getName().equals(role.getName())) {
                uraFound = true;
                List<RoleConstraint> rcs = ur.getRoleConstraints();
                for (RoleConstraint r : rcs) {
                    if (r.getPaSetName().equals(rc.getPaSetName())) {
                        urcFound = true;
                        assertEquals(rc.getType(), r.getType());
                        assertEquals(rc.getValue(), r.getValue());
                        assertNotNull(r.getId());
                    }
                }
            }
        }
        if (!uraFound) {
            fail("User Role Assignment Not Found");
        }
        if (!urcFound) {
            fail("User Role Constraint Not Found");
        }
        LOG.debug("readUserRoleConstraint value [" + rc.getValue() + "] successful");
    } catch (SecurityException ex) {
        LOG.error("readUserRoleConstraint value [" + rc.getValue() + "] 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) UserRole(org.apache.directory.fortress.core.model.UserRole) SecurityException(org.apache.directory.fortress.core.SecurityException) RoleConstraint(org.apache.directory.fortress.core.model.RoleConstraint)

Aggregations

ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)75 SecurityException (org.apache.directory.fortress.core.SecurityException)65 UserRole (org.apache.directory.fortress.core.model.UserRole)32 User (org.apache.directory.fortress.core.model.User)31 Role (org.apache.directory.fortress.core.model.Role)30 AdminMgr (org.apache.directory.fortress.core.AdminMgr)27 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)22 Permission (org.apache.directory.fortress.core.model.Permission)16 SDSet (org.apache.directory.fortress.core.model.SDSet)8 PermObj (org.apache.directory.fortress.core.model.PermObj)5 ArrayList (java.util.ArrayList)3 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)3 PermAnt (org.apache.directory.fortress.core.ant.PermAnt)2 CSVWriter (au.com.bytecode.opencsv.CSVWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Map (java.util.Map)1 AccessMgr (org.apache.directory.fortress.core.AccessMgr)1