Search in sources :

Example 56 with ReviewMgr

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

the class ReviewMgrImplTest method readPASetFromPermission.

public static void readPASetFromPermission(String msg, String paSetName, String obj, String[] op) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        Permission pop = PermTestData.getOp(obj, op);
        Permission entity = reviewMgr.readPermission(pop);
        assertTrue(paSetName, entity.getPaSets().contains(paSetName));
        LOG.debug("readPASetFromPermission name [" + paSetName + "] successful");
    } catch (SecurityException ex) {
        LOG.error("readPASetFromPermission name [" + paSetName + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) Permission(org.apache.directory.fortress.core.model.Permission) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 57 with ReviewMgr

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

the class ReviewMgrImplTest method teardownRequired.

/**
 * Determine if old fortress regression test cases are loaded in this directory and must be torn down.
 *
 * @param msg
 * @param rArray
 */
public static boolean teardownRequired(String msg, String[][] rArray) {
    // default return is 'true':
    boolean tearDown = true;
    String methodName = ".teardownRequired";
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        for (String[] rle : rArray) {
            Role entity = reviewMgr.readRole(new Role(RoleTestData.getName(rle)));
            RoleTestData.assertEquals(entity, rle);
        }
    // if we get to here it means that old test data must be removed from directory.
    } catch (SecurityException ex) {
        // This is the expected when teardown is not required:
        if (ex.getErrorId() == GlobalErrIds.ROLE_NOT_FOUND) {
            // did not find old test data no need to teardown
            tearDown = false;
        } else {
            // Something unexpected occurred here, Report as warning to the logger:
            String warning = methodName + " caught SecurityException=" + ex.getMessage();
            LOG.warn(warning);
        // TODO: Determine if it would be better to throw a SecurityException here.
        }
    }
    LOG.info(methodName + ":" + tearDown);
    return tearDown;
}
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 58 with ReviewMgr

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

the class ReviewMgrImplTest method testDeassignRoleWithRoleConstraint.

public void testDeassignRoleWithRoleConstraint() throws SecurityException {
    AdminMgr adminMgr = AdminMgrImplTest.getManagedAdminMgr();
    adminMgr.deassignUser(new UserRole(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0]));
    ReviewMgr reviewMgr = getManagedReviewMgr();
    reviewMgr.assignedRoles(new User(UserTestData.USERS_TU1[0][0]));
    adminMgr.assignUser(new UserRole(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0]));
}
Also used : User(org.apache.directory.fortress.core.model.User) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) UserRole(org.apache.directory.fortress.core.model.UserRole) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 59 with ReviewMgr

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

the class ReviewMgrImplTest method searchSsdSets.

/**
 * @param msg
 * @param srchValue
 * @param sArray
 */
public static void searchSsdSets(String msg, String srchValue, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        SDSet sdSet = new SDSet();
        sdSet.setName(srchValue);
        List<SDSet> sdSetList = reviewMgr.ssdSets(sdSet);
        assertNotNull(sdSetList);
    } catch (SecurityException ex) {
        LOG.error("searchRoles searchSsdSets [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 60 with ReviewMgr

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

the class ReviewMgrImplTest method searchDsdSets.

/**
 * @param msg
 * @param srchValue
 * @param sArray
 */
public static void searchDsdSets(String msg, String srchValue, String[][] sArray) {
    LogUtil.logIt(msg);
    try {
        ReviewMgr reviewMgr = getManagedReviewMgr();
        SDSet sdSet = new SDSet();
        sdSet.setName(srchValue);
        List<SDSet> sdSetList = reviewMgr.ssdSets(sdSet);
        assertNotNull(sdSetList);
    } catch (SecurityException ex) {
        LOG.error("searchRoles searchDsdSets [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) ReviewMgr(org.apache.directory.fortress.core.ReviewMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

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