use of org.apache.directory.fortress.core.DelReviewMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method searchAdminRoles.
/**
* @param msg
* @param srchValue
* @param rArray
*/
public static void searchAdminRoles(String msg, String srchValue, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
List<AdminRole> roles = dReviewMgr.findRoles(srchValue);
assertNotNull(roles);
assertTrue(CLS_NM + "searchAdminRoles list size check", rArray.length == roles.size());
for (String[] rle : rArray) {
int indx = roles.indexOf(AdminRoleTestData.getRole(rle));
if (indx != -1) {
AdminRole entity = roles.get(indx);
assertNotNull(entity);
AdminRoleTestData.assertEquals(entity, rle);
LOG.debug("searchAdminRoles [" + entity.getName() + "] successful");
} else {
msg = "searchAdminRoles srchValue [" + srchValue + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
} catch (SecurityException ex) {
LOG.error("searchAdminRoles srchValue [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelReviewMgr 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.DelReviewMgr in project directory-fortress-core by apache.
the class CreatePermOrgSample method testCreatePermOrg.
/**
* Create a new Permission OrgUnit entity in LDAP. The Permission OrgUnit entity must have the
* OrgUnit name and the OrgUnit type set before being added.
*/
public static void testCreatePermOrg() {
String szLocation = ".testCreatePermOrg";
try {
DelReviewMgr dRevAdminMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
// The OrgUnit requires name and type to be set before use.
OrgUnit inOU = new OrgUnit(TEST_PERM_OU_NM, OrgUnit.Type.PERM);
try {
dRevAdminMgr.read(inOU);
// if org is found, return.
return;
} catch (FinderException fe) {
assertTrue(szLocation + " excep id check", fe.getErrorId() == GlobalErrIds.ORG_NOT_FOUND_PERM);
// 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.DelReviewMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method deassignAdminUsers.
/**
* @param msg
* @param uArray
* @param rArray
*/
void deassignAdminUsers(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
DelReviewMgr dReviewMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
dReviewMgr = getManagedDelegatedReviewMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
}
int i = 0;
for (String[] usr : uArray) {
i++;
for (String[] rle : rArray) {
UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rle).getName());
AdminRoleTestData.getRole(rle);
dAdminMgr.deassignUser(uAdminRole);
LOG.debug("deassignAdminUsers user [" + uAdminRole.getUserId() + "] role [" + uAdminRole.getName() + "] successful");
// Let's double check the number of users associated with role:
List<User> users = dReviewMgr.assignedUsers(AdminRoleTestData.getRole(rle));
assertNotNull(users);
// If this is the last user deassigned from role, both lists will be returned empty:
if (i == uArray.length) {
assertTrue(users.size() == 0);
} else {
assertTrue(CLS_NM + "deassignAdminUsers list size check", (rArray.length - i) == users.size());
}
}
}
} catch (SecurityException ex) {
LOG.error("deassignAdminUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelReviewMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method delAdminRoleAscendant.
/**
* @param msg
* @param rArray
*/
private void delAdminRoleAscendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
Set<String> ascs = RoleTestData.getRelationships(rle);
if (ascs != null) {
for (String asc : ascs) {
dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc adminRole [" + asc + "] successful");
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String asc : inheritances) {
dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc orgUnit [" + asc + "] successful");
}
}
dAdminMgr.deleteRole(adminRole);
LOG.debug("delAdminRoleAscendant remove desc adminRole [" + adminRole.getName() + "] successful");
}
// cleanup the top ascendant from orgUnit data set.
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
String adminRoleSrchVal = RoleTestData.getName(rArray[0]);
// stip off prefix and search:
adminRoleSrchVal = adminRoleSrchVal.substring(0, 3);
List<AdminRole> cleanup = dReviewMgr.findRoles(adminRoleSrchVal);
for (AdminRole re : cleanup) {
dAdminMgr.deleteRole(re);
LOG.debug("delAdminRoleAscendant cleanup adminRole [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delAdminRoleAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations