use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method addAdminRoles.
/**
* @param rArray
*/
public static void addAdminRoles(String msg, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] rle : rArray) {
AdminRole role = AdminRoleTestData.getRole(rle);
AdminRole entity = dAdminMgr.addRole(role);
LOG.debug("addAdminRoles role [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("addAdminRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class CreateUserOrgHierarchySample method testCreateAscendantUserOrgs.
/**
* Demonstrate a child to parent OrgUnit structure of one-to-many. To use this API, the child OrgUnit must be created before
* the call to addAscendant which will Add a new OrgUnit node and set a OrgUnit relationship with child node.
* <p>
* <img src="./doc-files/HierUserOrgAscendants.png" alt="">
*/
public static void testCreateAscendantUserOrgs() {
String szLocation = ".testCreateAscendantUserOrgs";
try {
// Instantiate the DelAdminMgr implementation which is used to provision ARBAC policies.
DelAdminMgr delAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
// Instantiate the child OrgUnit. This needs a name and type.
OrgUnit childOrgUnit = new OrgUnit(TEST_HIER_ASC_USERORG_PREFIX + 1, OrgUnit.Type.USER);
// This child will have many parents:
delAdminMgr.add(childOrgUnit);
// Create OrgUnits, 'sampleHierUserOrgA2' - 'sampleHierUserOrgA6'.
for (int i = 1; i < TEST_NUMBER; i++) {
// Instantiate the parent OrgUnit. This needs a name and type before it can be added to ldap.
OrgUnit parentOrgUnit = new OrgUnit(TEST_HIER_ASC_USERORG_PREFIX + (i + 1), OrgUnit.Type.USER);
// Now add parent OrgUnit entity to directory and add relationship with existing child OrgUnit.
delAdminMgr.addAscendant(childOrgUnit, parentOrgUnit);
}
} 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.DelAdminMgr in project directory-fortress-core by apache.
the class CreateUserOrgHierarchySample method testCreateDescendantUserOrgs.
/**
* Demonstrate a parent to child OrgUnit structure of one-to-many. The parent OrgUnit must be created before
* the call to addDescendant which will Add a new OrgUnit node and set a OrgUnit relationship with parent node.
* <p>
* <img src="./doc-files/HierUserOrgDescendants.png" alt="">
*/
public static void testCreateDescendantUserOrgs() {
String szLocation = ".testCreateDescendantUserOrgs";
try {
// Instantiate the DelAdminMgr implementation which is used to provision ARBAC policies.
DelAdminMgr delAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
// Instantiate the parent User OrgUnit entity. This needs a name and type before it can be added to ldap.
OrgUnit parentOrgUnit = new OrgUnit(TEST_HIER_DESC_USERORG_PREFIX + 1, OrgUnit.Type.USER);
// This parent will have many children:
delAdminMgr.add(parentOrgUnit);
// Create User OrgUnits, 'sampleHierUserOrgD2' - 'sampleHierUserOrgD6'.
for (int i = 1; i < TEST_NUMBER; i++) {
// Now add relationship to the directory between parent and child User OrgUnits.
OrgUnit childOrgUnit = new OrgUnit(TEST_HIER_DESC_USERORG_PREFIX + (i + 1), OrgUnit.Type.USER);
// Now add child OrgUnit entity to directory and add relationship with existing parent OrgUnit.
delAdminMgr.addDescendant(parentOrgUnit, childOrgUnit);
}
LOG.info(szLocation + " 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.DelAdminMgr in project directory-fortress-core by apache.
the class CreateUserOrgSample method testCreateUserOrg.
/**
* Before a User can be added to ldap directory an OrgUnit must be created. The User OrgUnit entity
* supports general hierarchies meaning an OrgUnit can have zero or more parents. The User OrgUnit
* organizational structure is represented logically as a simple directional graph though that
* functionality is not demonstrated here.
*/
public static void testCreateUserOrg() {
String szLocation = ".testCreateUserOrg";
try {
DelReviewMgr dRevAdminMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
// The OrgUnit requires name and type to be set before use.
OrgUnit inOU = new OrgUnit(TEST_USER_OU_NM, OrgUnit.Type.USER);
try {
dRevAdminMgr.read(inOU);
// if org is found, return.
return;
} catch (FinderException fe) {
assertTrue(szLocation + " excep id check", fe.getErrorId() == GlobalErrIds.ORG_NOT_FOUND_USER);
// pass
}
// Instantiate the Delegated AdminMgr implementation object which provisions OrgUnits and AdminRoles to the system.
DelAdminMgr dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
// Add the OrgUnit to the directory.
dAdminMgr.add(inOU);
// Instantiate the Delegated RevewMgr implementation which interrogates the OrgUnit and AdminRole data.
DelReviewMgr dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
// Now read the OrgUnit back to make sure it got added OK.
OrgUnit outOU = dReviewMgr.read(inOU);
assertTrue(szLocation + " failed read", inOU.equals(outOU));
LOG.info(szLocation + " [" + outOU.getName() + "] 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.DelAdminMgr in project directory-fortress-core by apache.
the class CreatePermOrgHierarchySample method testDeleteHierPermOrgs.
/**
* Remove the simple hierarchical OrgUnits from the directory. Before removal call the API to move the relationship
* between the parent and child OrgUnits. Once the relationship is removed the parent OrgUnit can be removed.
* Perm OrgUnit removal is not allowed (SecurityException will be thrown) if ou is assigned to PermObjs in ldap.
* <p>
* <img src="./doc-files/HierPermOrgSimple.png" alt="">
*/
public static void testDeleteHierPermOrgs() {
String szLocation = ".testDeleteHierPermOrgs";
if (AllSamplesJUnitTest.isFirstRun()) {
return;
}
try {
// Instantiate the DelAdminMgr implementation which is used to provision ARBAC policies.
DelAdminMgr delAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
for (int i = 1; i < TEST_NUMBER; i++) {
// The key that must be set to locate any OrgUnit is simply the name and type.
OrgUnit parentOrgUnit = new OrgUnit(TEST_HIER_PERMORG_PREFIX + i, OrgUnit.Type.PERM);
OrgUnit childOrgUnit = new OrgUnit(TEST_HIER_PERMORG_PREFIX + (i + 1), OrgUnit.Type.PERM);
// Remove the relationship from the parent and child OrgUnit:
delAdminMgr.deleteInheritance(parentOrgUnit, childOrgUnit);
// Remove the parent OrgUnit from directory:
delAdminMgr.delete(parentOrgUnit);
}
// Remove the child OrgUnit from directory:
delAdminMgr.delete(new OrgUnit(TEST_HIER_PERMORG_PREFIX + TEST_NUMBER, OrgUnit.Type.PERM));
LOG.info(szLocation + " success");
} catch (SecurityException ex) {
LOG.error(szLocation + " caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations