Search in sources :

Example 16 with PermObj

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

the class PropertyMgrImplTest method testCrudProperties.

public void testCrudProperties() {
    Role role = RoleTestData.getRole(RoleTestData.ROLES_TR1[0]);
    AdminRole adminRole = AdminRoleTestData.getRole(AdminRoleTestData.AROLES_TR1[0]);
    PermObj permObj = PermTestData.getObj(PermTestData.OBJS_TOB1[0]);
    Permission permOp = PermTestData.getOp(permObj.getObjName(), PermTestData.OPS_TOP1[0]);
    Group group = GroupTestData.TEST_GROUP1;
    addProperties("ADD-PROP-RLE", role, PROPS);
    addProperties("ADD-PROP-ADMRLE", adminRole, PROPS);
    addProperties("ADD-PROP-POBJ", permObj, PROPS);
    addProperties("ADD-PROP-POP", permOp, PROPS);
    addProperties("ADD-PROP-GRP", group, PROPS);
    updateProperties("UPD-PROP-RLE", role, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POBJ", permObj, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POP", permOp, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POP", group, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-RLE", role, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POBJ", permObj, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POP", permOp, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POP", group, PROPS_UPDATED[0]);
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) Group(org.apache.directory.fortress.core.model.Group) PermObj(org.apache.directory.fortress.core.model.PermObj) Permission(org.apache.directory.fortress.core.model.Permission) AdminRole(org.apache.directory.fortress.core.model.AdminRole)

Example 17 with PermObj

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

the class CreatePermSample method testDelPermObjects.

/**
 * Removal of Permission Object node from ldap will also remove any child Operation nodes that are located
 * directly below.
 */
public static void testDelPermObjects() {
    String szLocation = ".testDelPermObjects";
    if (AllSamplesJUnitTest.isFirstRun()) {
        return;
    }
    try {
        // Instantiate the AdminMgr implementation which is used to provision RBAC policies.
        AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        // this will remove the object along with any operations associated with it:
        adminMgr.deletePermObj(new PermObj(TEST_PERM_OBJECT, CreatePermOrgSample.TEST_PERM_OU_NM));
        // Instantiate the ReviewMgr implementation which is used to interrogate policy information.
        ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(TestUtils.getContext());
        try {
            // this should fail:
            reviewMgr.readPermObj(new PermObj(TEST_PERM_OBJECT));
            fail(szLocation + " permission object delete failed");
        } catch (SecurityException se) {
            assertTrue(szLocation + " excep id check", se.getErrorId() == GlobalErrIds.PERM_OBJ_NOT_FOUND);
        // pass
        }
        LOG.info(szLocation + " permission object [" + TEST_PERM_OBJECT + "] success");
    } catch (SecurityException ex) {
        LOG.error(szLocation + " 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) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 18 with PermObj

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

the class CreatePermSample method testAddPermObjects.

/**
 * The Fortress object entity must be created before operations may be granted.  There is a one-to-many
 * relationship between objects and operations.
 */
public static void testAddPermObjects() {
    String szLocation = ".testAddPermObjects";
    try {
        // Instantiate the AdminMgr implementation which is used to provision RBAC policies.
        AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        // Add the PermObj entity to ldap.  The PermObj entity must have a name and an OrgUnit affiliation.
        adminMgr.addPermObj(new PermObj(TEST_PERM_OBJECT, CreatePermOrgSample.TEST_PERM_OU_NM));
        // Instantiate the ReviewMgr implementation which is used to interrogate policy information.
        ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(TestUtils.getContext());
        // now read the newly created Object entity back:
        PermObj outObj = reviewMgr.readPermObj(new PermObj(TEST_PERM_OBJECT));
        // Do some validations.
        assertNotNull(outObj);
        assertTrue(szLocation + " failed obj name check", TEST_PERM_OBJECT.equals(outObj.getObjName()));
        assertTrue(szLocation + " failed obj ou check", CreatePermOrgSample.TEST_PERM_OU_NM.equals(outObj.getOu()));
        LOG.info(szLocation + " permission object [" + outObj.getObjName() + "] success");
    } catch (SecurityException ex) {
        LOG.error(szLocation + " 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) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 19 with PermObj

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

the class CreatePermSample method testDeleteShoppingCartObjects.

public static void testDeleteShoppingCartObjects() {
    String szLocation = ".testDeleteShoppingCartObjects";
    if (AllSamplesJUnitTest.isFirstRun()) {
        return;
    }
    try {
        // Instantiate the AdminMgr first
        AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
        // Now Instantiate the Object
        PermObj shoppingCart = new PermObj("ShoppingCart", "KillerBikes.com");
        // Add it to the directory
        adminMgr.deletePermObj(shoppingCart);
    } catch (SecurityException ex) {
        LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : PermObj(org.apache.directory.fortress.core.model.PermObj) SecurityException(org.apache.directory.fortress.core.SecurityException) AdminMgr(org.apache.directory.fortress.core.AdminMgr)

Example 20 with PermObj

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

Aggregations

PermObj (org.apache.directory.fortress.core.model.PermObj)33 SecurityException (org.apache.directory.fortress.core.SecurityException)22 AdminMgr (org.apache.directory.fortress.core.AdminMgr)7 FortRequest (org.apache.directory.fortress.core.model.FortRequest)7 FortResponse (org.apache.directory.fortress.core.model.FortResponse)7 Permission (org.apache.directory.fortress.core.model.Permission)6 Role (org.apache.directory.fortress.core.model.Role)6 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)5 AdminRole (org.apache.directory.fortress.core.model.AdminRole)5 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)5 User (org.apache.directory.fortress.core.model.User)4 ArrayList (java.util.ArrayList)3 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)3 FinderException (org.apache.directory.fortress.core.FinderException)3 Relationship (org.apache.directory.fortress.core.model.Relationship)3 UserRole (org.apache.directory.fortress.core.model.UserRole)3 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)3 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)2 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)2 Constraint (org.apache.directory.fortress.core.model.Constraint)2