use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method deleteInheritedAdminRoles.
/**
* @param msg
* @param rArray
*/
private static void deleteInheritedAdminRoles(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole role = AdminRoleTestData.getRole(rle);
Set<String> parents = RoleTestData.getRelationships(rle);
if (parents != null) {
for (String pRole : parents) {
dAdminMgr.deleteInheritance(new AdminRole(pRole), role);
LOG.debug("deleteInheritedAdminRoles child role [" + role.getName() + "] parent role [" + pRole + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("deleteInheritedAdminRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method readAdminRoles.
/**
* @param msg
* @param rArray
*/
public static void readAdminRoles(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
for (String[] rle : rArray) {
AdminRole entity = dReviewMgr.readRole(AdminRoleTestData.getRole(rle));
AdminRoleTestData.assertEquals(entity, rle);
LOG.debug("readAdminRoles [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("readAdminRoles caught SecurityException=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method addAdminRoleDescendant.
/**
* @param msg
* @param rArray
*/
public static void addAdminRoleDescendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
int ctr = 0;
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
if (ctr++ == 0 || RoleTestData.isTree(rle)) {
dAdminMgr.addRole(adminRole);
LOG.debug("addAdminRoleDescendant add role [" + adminRole.getName() + "] successful");
}
// use list because order is important for test structure:
List<String> descs = RoleTestData.getRelationshipList(rle);
if (descs != null) {
if (RoleTestData.isTree(rle)) {
AdminRole parent = adminRole;
for (String desc : descs) {
AdminRole child = new AdminRole(desc);
dAdminMgr.addDescendant(parent, new AdminRole(desc));
LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
parent = child;
}
} else {
for (String desc : descs) {
dAdminMgr.addDescendant(adminRole, new AdminRole(desc));
LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
}
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String desc : inheritances) {
dAdminMgr.addInheritance(adminRole, new AdminRole(desc));
LOG.debug("addAdminRoleDescendant asc role [" + adminRole.getName() + "] desc role [" + desc + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addAdminRoleDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method loadAdminRequired.
private static boolean loadAdminRequired(String msg, String[][] rArray) {
// default return is 'true':
boolean loadAdmin = true;
String methodName = ".loadAdminRequired";
LogUtil.logIt(msg);
try {
DelReviewMgr dReviewMgr = getDelegatedReviewMgr();
for (String[] rle : rArray) {
AdminRole entity = dReviewMgr.readRole(new AdminRole(RoleTestData.getName(rle)));
if (entity == null) {
break;
}
// AdminRoleTestData.assertEquals( entity, rle );
}
// if we get to here it means that admin role has already been loaded
loadAdmin = false;
} catch (SecurityException ex) {
// This is the expected when teardown is not required:
if (ex.getErrorId() == GlobalErrIds.ROLE_NOT_FOUND) {
// did not find so need to load admin roles
} 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 + ":" + loadAdmin);
return loadAdmin;
}
use of org.apache.directory.fortress.core.model.AdminRole 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());
}
}
Aggregations