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]);
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations