use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method updatePermOps.
/**
* @param objArray
* @param opArray
*/
public static void updatePermOps(String msg, String[][] objArray, String[][] opArray, boolean isAdmin) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] obj : objArray) {
for (String[] op : opArray) {
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.updatePermission(pOp);
LOG.debug("updatePermOps objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("updatePermOps objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.AdminMgr 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.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method assignUsersSSD.
/**
* @param msg
* @param uArray
* @param sArray
*/
public static void assignUsersSSD(String msg, String[][] uArray, String[][] sArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
int i = 0;
for (String[] usr : uArray) {
SDSet ssd = RoleTestData.getSDSet(sArray[i++]);
// Set<String> roles = ssd.getMembers().keySet();
Set<String> roles = ssd.getMembers();
User user = UserTestData.getUser(usr);
int j = 0;
for (String role : roles) {
j++;
try {
UserRole uRole = new UserRole(user.getUserId(), role);
adminMgr.assignUser(uRole);
if (j >= ssd.getCardinality()) {
fail(CLS_NM + ".assignUsersSSD user [" + user.getUserId() + "] role [" + role + "] ssd [" + ssd.getName() + "] cardinality [" + ssd.getCardinality() + "] count [" + j + "] failed");
}
} catch (SecurityException ex) {
assertTrue(CLS_NM + ".assignUsersSSD cardinality test failed user [" + user.getUserId() + "] role [" + role + "] ssd [" + ssd.getName() + "] cardinality [" + ssd.getCardinality() + "] count [" + j + "]", j >= (ssd.getCardinality()));
assertTrue(CLS_NM + ".assignUsersSSD cardinality test failed [" + UserTestData.getUserId(usr) + "]", ex.getErrorId() == GlobalErrIds.SSD_VALIDATION_FAILED);
// still good, break from loop, we're done here
break;
}
}
}
} catch (SecurityException ex) {
LOG.error("assignUsersSSD caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.AdminMgr 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.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method addUsers.
/**
* @param uArray
*/
public static void addUsers(String msg, String[][] uArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
adminMgr.addUser(user);
LOG.debug("addUsers user [" + user.getUserId() + "] successful");
// Does User have Role assignments?
Set<String> asgnRoles = UserTestData.getAssignedRoles(usr);
if (asgnRoles != null) {
for (String name : asgnRoles) {
adminMgr.assignUser(new UserRole(user.getUserId(), name));
}
}
}
} catch (SecurityException ex) {
ex.printStackTrace();
LOG.error("addUsers: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations