use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class AdminMgrImplTest method deleteSsdRoleMember.
/**
* @param sArray
*/
private void deleteSsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] ssdle : sArray) {
SDSet ssd = RoleTestData.getSDSet(ssdle);
// first add all of the roles as members of SSD entity:
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
ssd.addMember(role.getName());
}
// now iterate over roles and remove from SSD set one at a time.
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.deleteSsdRoleMember(ssd, role);
List<SDSet> ssdSets = reviewMgr.ssdRoleSets(role);
assertTrue(CLS_NM + "deleteSsdRoleMember list size check ssdSets size [" + ssdSets.size() + "]", ssdSets.size() == 0);
}
adminMgr.deleteSsdSet(ssd);
LOG.debug("deleteSsdRoleMember SSD [" + ssd.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteSsdRoleMember 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 AdminMgrImplTest method setSsdCardinality.
/**
* @param msg
* @param sArray
* @param rArray
*/
public static void setSsdCardinality(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] ssdle : sArray) {
SDSet ssd = RoleTestData.getSDSet(ssdle);
SDSet entity = adminMgr.createSsdSet(ssd);
LOG.debug("setSsdCardinality SSD [" + entity.getName() + "] successful");
int cardinality = 1;
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.addSsdRoleMember(ssd, role);
adminMgr.setSsdSetCardinality(ssd, cardinality);
int currentCardinality = reviewMgr.ssdRoleSetCardinality(ssd);
assertTrue(CLS_NM + "setSsdCardinality cardinality check", currentCardinality == cardinality++);
}
}
} catch (SecurityException ex) {
LOG.error("setSsdCardinality 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 AdminMgrImplTest method assignUsers.
/**
* @param msg
* @param uArray
* @param rArray
* @param setTemporal
*/
public static void assignUsers(String msg, String[][] uArray, String[][] rArray, boolean setTemporal) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
int i = 0;
for (String[] usr : uArray) {
i++;
for (String[] rle : rArray) {
User user = UserTestData.getUser(usr);
Role role = RoleTestData.getRole(rle);
UserRole uRole = new UserRole();
ConstraintUtil.copy(role, uRole);
if (!setTemporal) {
// test the default constraints for role
uRole = new UserRole(role.getName());
}
uRole.setUserId(user.getUserId());
adminMgr.assignUser(uRole);
LOG.debug("assignUsers user [" + user.getUserId() + "] role [" + uRole.getName() + "] successful");
// Let's double check the number of users not 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);
assertTrue(CLS_NM + ".assignUsers list size check", i == users.size());
assertTrue(CLS_NM + ".assignUsers list2 size check", i == users2.size());
}
}
} catch (SecurityException ex) {
LOG.error("assignUsers user 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 AdminMgrImplTest method addRoleGrantsHB.
/**
* @param msg
* @param rArray
* @param objArray
* @param opArray
*/
public static void addRoleGrantsHB(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.grantPermission(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.grantPermission(pOp, user);
i++;
LOG.debug("addRoleGrantsHB userId [" + user.getUserId() + "] role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("addRoleGrantsHB 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 AdminMgrImplTest method assignUserRoleConstraint.
public static RoleConstraint assignUserRoleConstraint(String msg, String[] usr, String[] rle, RoleConstraint rc) throws SecurityException {
LogUtil.logIt(msg);
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
User user = UserTestData.getUser(usr);
Role role = RoleTestData.getRole(rle);
RoleConstraint createdRoleConstraint = adminMgr.addRoleConstraint(new UserRole(user.getUserId(), role.getName()), rc);
LOG.debug("assignUserRoleConstraint user [" + user.getUserId() + "] role [" + role.getName() + "] " + " rcvalue [" + rc.getValue() + "]");
// get user with consratint filter
List<User> usersWithRc = reviewMgr.assignedUsers(role, rc);
assertTrue(usersWithRc.size() == 1);
assertEquals(user.getUserId(), usersWithRc.get(0).getUserId());
return createdRoleConstraint;
}
Aggregations