use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method delRoleAscendant.
/**
* @param msg
* @param rArray
*/
private void delRoleAscendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
Set<String> ascs = RoleTestData.getRelationships(rle);
if (ascs != null) {
for (String asc : ascs) {
adminMgr.deleteInheritance(new Role(asc), role);
LOG.debug("delRoleAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String asc : inheritances) {
adminMgr.deleteInheritance(new Role(asc), role);
LOG.debug("delRoleAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
}
}
adminMgr.deleteRole(role);
LOG.debug("delRoleAscendant remove desc role [" + role.getName() + "] successful");
}
// cleanup the top ascendant from roles data set.
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
String roleSrchVal = RoleTestData.getName(rArray[0]);
roleSrchVal = roleSrchVal.substring(0, roleSrchVal.length() - 8);
List<Role> cleanup = reviewMgr.findRoles(roleSrchVal);
for (Role re : cleanup) {
adminMgr.deleteRole(re);
LOG.debug("delRoleAscendant cleanup role [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delRoleAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method deassignUsers.
/**
* @param msg
* @param uArray
* @param rArray
*/
void deassignUsers(String msg, String[][] uArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
int i = 0;
for (String[] usr : uArray) {
i++;
for (String[] rle : rArray) {
UserRole uRole = new UserRole(UserTestData.getUserId(usr), RoleTestData.getName(rle));
adminMgr.deassignUser(uRole);
LOG.debug("deassignUsers user [" + uRole.getUserId() + "] role [" + uRole.getName() + "] successful");
// Double check the number of users associated with role:
// This one retrieves the collection of all "roleOccupant" attributes associated with the role node:
List<String> users = reviewMgr.assignedUsers(RoleTestData.getRole(rle), rArray.length);
// This one searches across all Users and pull back list of type "User":
List<User> users2 = reviewMgr.authorizedUsers(RoleTestData.getRole(rle));
assertNotNull(users);
assertNotNull(users2);
// If this is the last user deassigned from role, both lists will be returned empty:
if (i == uArray.length) {
assertTrue(users.size() == 0);
assertTrue(users2.size() == 0);
} else {
assertTrue(CLS_NM + "deassignUsers list size check", (rArray.length - i) == users.size());
assertTrue(CLS_NM + "deassignUsers list2 size check", (rArray.length - i) == users2.size());
}
}
}
} catch (SecurityException ex) {
LOG.error("deassignUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method deleteDsdRoleMember.
/**
* @param sArray
*/
private void deleteDsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] dsdle : sArray) {
SDSet dsd = RoleTestData.getSDSet(dsdle);
// first add all of the roles as members of SSD entity:
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
dsd.addMember(role.getName());
}
// now iterate over roles and remove from DSD set one at a time.
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.deleteDsdRoleMember(dsd, role);
List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
assertTrue(CLS_NM + "deleteDsdRoleMember list size check", dsdSets.size() == 0);
}
adminMgr.deleteDsdSet(dsd);
LOG.debug("deletedsdRoleMember DSD [" + dsd.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteDsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method addDsdRoleMember.
/**
* @param sArray
*/
public static void addDsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] dsdle : sArray) {
SDSet dsd = RoleTestData.getSDSet(dsdle);
SDSet entity = adminMgr.createDsdSet(dsd);
LOG.debug("addDsdRoleMember DSD [" + entity.getName() + "] successful");
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.addDsdRoleMember(dsd, role);
List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
assertNotNull(dsdSets);
assertTrue(CLS_NM + "addDsdRoleMember list size check", dsdSets.size() == 1);
SDSet dsd2 = dsdSets.get(0);
assertTrue(CLS_NM + "addDsdRoleMember DSD name check", dsd.getName().equals(dsd2.getName()));
assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().contains(role.getName()));
// assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().containsKey(role.getName()));
}
}
} catch (SecurityException ex) {
LOG.error("addDsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class FortressAntLoadTest method permissionRoles.
private static void permissionRoles(String msg, List<PermGrant> permGrants) {
LogUtil.logIt(msg);
Permission pOp;
try {
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (PermGrant permGrant : permGrants) {
pOp = new Permission();
pOp.setObjName(permGrant.getObjName());
pOp.setOpName(permGrant.getOpName());
pOp.setObjId(permGrant.getObjId());
List<String> roles = reviewMgr.permissionRoles(pOp);
assertNotNull(roles);
int indx = roles.indexOf(permGrant.getRoleNm());
assertTrue("Failed to find roleNm: " + permGrant.getRoleNm(), indx != -1);
}
} catch (SecurityException ex) {
LOG.error("permissionRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations