use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class AdminMgrImplTest method delRoleGrantsHB.
/**
* @param msg
* @param rArray
* @param objArray
* @param opArray
*/
private void delRoleGrantsHB(String msg, String[][] uArray, String[][] rArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] obj : objArray) {
int i = 0;
for (String[] rle : rArray) {
// Get Role[i] from test data:
Role role = RoleTestData.getRole(rle);
// Get Permission[i] from test data:
String[] op = opArray[i];
// Load the permission entity with data:
Permission pOp = PermTestData.getOp(PermTestData.getName(obj), op);
// Grant Permission[i] to Role[i]:
adminMgr.revokePermission(pOp, role);
// Get User[i] from test data:
String[] usr = uArray[i];
// Load the User entity with data:
User user = UserTestData.getUser(usr);
// Grant Permission[i] to User[i]:
adminMgr.revokePermission(pOp, user);
i++;
LOG.debug("delRoleGrantsHB userId [" + user.getUserId() + "] role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("delRoleGrantsHB caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method delAdminRoleDescendant.
private void delAdminRoleDescendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
// 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.deleteInheritance(parent, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
parent = child;
}
} else {
for (String desc : descs) {
dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
}
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String desc : inheritances) {
dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
}
}
dAdminMgr.deleteRole(adminRole);
LOG.debug("delAdminRoleDescendant remove asc adminRole [" + adminRole.getName() + "] successful");
}
// cleanup the last row of descendants from orgUnit data set.
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
String srchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
List<AdminRole> cleanup = dReviewMgr.findRoles(srchVal);
for (Role re : cleanup) {
dAdminMgr.deleteRole((AdminRole) re);
LOG.debug("delAdminRoleDescendant cleanup adminRole [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class FortressAntLoadTest method readRoles.
private static void readRoles(String msg, List<Role> roles) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (Role role : roles) {
Role entity = reviewMgr.readRole(role);
assertNotNull(entity);
assertTrue("Failed role name", entity.getName().equals(role.getName()));
TestUtils.assertTemporal(CLS_NM + ".assertEquals", role, entity);
}
} catch (SecurityException ex) {
LOG.error("readRoles caught SecurityException=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class GroupMgrImplTest method deassignRoleMember.
private void deassignRoleMember(String message, Group group, String[][] roles) {
LogUtil.logIt(message);
try {
groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
for (String[] roleArray : roles) {
Role role = RoleTestData.getRole(roleArray);
groupMgr.deassign(group, role.getName());
}
LOG.debug("deassignRoleMember group [" + group.getName() + "] successful");
int countOfOldRoles = group.getMembers().size();
// read from LDAP and get count of members
Group groupFromLdap = groupMgr.read(group);
int actualAmountOfMembers = groupFromLdap.getMembers().size();
assertEquals(CLS_NM + ".deassignRoleMember failed members size check", countOfOldRoles, actualAmountOfMembers);
} catch (SecurityException ex) {
ex.printStackTrace();
LOG.error("deassignRoleMember: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class GroupMgrImplTest method assignRoleMember.
private void assignRoleMember(String message, Group group, String[][] roles) {
LogUtil.logIt(message);
try {
groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
for (String[] roleArray : roles) {
Role role = RoleTestData.getRole(roleArray);
groupMgr.assign(group, role.getName());
}
LOG.debug("assignRoleMember group [" + group.getName() + "] successful");
int countOfOldRoles = group.getMembers().size();
int countOfNewRoles = roles.length;
// read from LDAP and get count of members
Group groupFromLdap = groupMgr.read(group);
int actualAmountOfMembers = groupFromLdap.getMembers().size();
assertEquals(CLS_NM + ".assignRoleMember failed members size check", countOfOldRoles + countOfNewRoles, actualAmountOfMembers);
} catch (SecurityException ex) {
ex.printStackTrace();
LOG.error("assignRoleMember: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations