use of org.apache.directory.fortress.core.SecurityException 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.SecurityException in project directory-fortress-core by apache.
the class AdminMgrImplTest method delRoleGrantsH.
/**
* @param msg
* @param rArray
* @param objArray
* @param opArray
*/
private void delRoleGrantsH(String msg, String[][] rArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
Role role = new Role();
try {
AdminMgr adminMgr = getManagedAdminMgr();
int i = 0;
for (String[] obj : objArray) {
role = new Role(RoleTestData.getName(rArray[i++]));
for (String[] op : opArray) {
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.revokePermission(pOp, role);
LOG.debug("delRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("delRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class AdminMgrImplTest method addPermOps.
/**
* @param objArray
* @param opArray
*/
public static void addPermOps(String msg, String[][] objArray, String[][] opArray, boolean isAdmin, boolean canFail) {
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.addPermission(pOp);
LOG.debug("addPermOp objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] successful");
}
}
} catch (SecurityException ex) {
if (!canFail) {
LOG.error("addPermOp 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.SecurityException in project directory-fortress-core by apache.
the class AdminMgrImplTest method createDsdSet.
/**
* @param sArray
*/
public static void createDsdSet(String msg, String[][] sArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] dsdle : sArray) {
SDSet dsd = RoleTestData.getSDSet(dsdle);
SDSet entity = adminMgr.createDsdSet(dsd);
LOG.debug("createDsdSet DSD [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("createDsdSet caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class AdminMgrImplTest method deleteSsdSet.
/**
* @param sArray
*/
private void deleteSsdSet(String msg, String[][] sArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] ssdle : sArray) {
SDSet ssd = RoleTestData.getSDSet(ssdle);
adminMgr.deleteSsdSet(ssd);
LOG.debug("deleteSsdSet role [" + ssd.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteSsdSet caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations