use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class FortressAntLoadTest method readPermissionOps.
/**
* @param msg
* @param permissions
*/
private static void readPermissionOps(String msg, List<PermAnt> permissions) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (PermAnt permAnt : permissions) {
Permission entity = reviewMgr.readPermission(permAnt);
assertNotNull(entity);
assertTrue("Failed objName value compare", entity.getObjName().equals(permAnt.getObjName()));
assertTrue("Failed opName value compare", entity.getOpName().equals(permAnt.getOpName()));
}
} catch (SecurityException ex) {
LOG.error("readPermissionOps caught SecurityException rc=" + ex.getErrorId() + ", " + "msg=" + ex.getMessage() + ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImplTest method authorizedPermissionUsers.
/**
* @param msg
* @param pObjArray
* @param pOpArray
* @param uArray
*/
public static void authorizedPermissionUsers(String msg, String[][] pObjArray, String[][] pOpArray, String[][] uArray) {
LogUtil.logIt(msg);
Permission pOp;
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] obj : pObjArray) {
int i = 0;
for (String[] op : pOpArray) {
pOp = new Permission();
pOp.setObjName(PermTestData.getName(obj));
pOp.setOpName(PermTestData.getName(op));
pOp.setObjId(PermTestData.getObjId(op));
Set<String> users = reviewMgr.authorizedPermissionUsers(pOp);
assertNotNull(users);
int expectedAuthZedUsers = i + 1;
assertTrue(CLS_NM + "authorizedPermissionUsers permission object [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", expectedAuthZedUsers == users.size());
int j = 1;
for (String[] usr : uArray) {
String userId = UserTestData.getUserId(usr);
if (j++ <= expectedAuthZedUsers) {
assertTrue(CLS_NM + "authorizedPermissionUsers userId [" + userId + "] should be authorized for operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", users.contains(userId));
} else {
assertTrue(CLS_NM + "authorizedPermissionUsers userId [" + userId + "] should not be authorized for operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", !users.contains(userId));
}
}
i++;
}
}
} catch (SecurityException ex) {
LOG.error("authorizedPermissionUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImplTest method authorizedPermissionRoles.
/**
* @param msg
* @param pObjArray
* @param pOpArray
* @param rArray
*/
public static void authorizedPermissionRoles(String msg, String[][] pObjArray, String[][] pOpArray, String[][] rArray) {
LogUtil.logIt(msg);
Permission pOp;
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] obj : pObjArray) {
int i = 0;
for (String[] op : pOpArray) {
pOp = new Permission();
pOp.setObjName(PermTestData.getName(obj));
pOp.setOpName(PermTestData.getName(op));
pOp.setObjId(PermTestData.getObjId(op));
Set<String> roles = reviewMgr.authorizedPermissionRoles(pOp);
assertNotNull(roles);
int expectedAuthZedRoles = i + 1;
assertTrue(CLS_NM + "authorizedPermissionRoles permission object [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", expectedAuthZedRoles == roles.size());
int j = 1;
for (String[] rle : rArray) {
String roleName = RoleTestData.getName(rle);
if (j++ <= expectedAuthZedRoles) {
assertTrue(CLS_NM + "authorizedPermissionRoles roleName [" + roleName + "] should be authorized for operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", roles.contains(roleName));
} else {
assertTrue(CLS_NM + "authorizedPermissionRoles roleName [" + roleName + "] should not be authorized for operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", !roles.contains(roleName));
}
}
i++;
}
}
} catch (SecurityException ex) {
LOG.error("authorizedPermissionRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImplTest method readPASetFromPermission.
public static void readPASetFromPermission(String msg, String paSetName, String obj, String[] op) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
Permission pop = PermTestData.getOp(obj, op);
Permission entity = reviewMgr.readPermission(pop);
assertTrue(paSetName, entity.getPaSets().contains(paSetName));
LOG.debug("readPASetFromPermission name [" + paSetName + "] successful");
} catch (SecurityException ex) {
LOG.error("readPASetFromPermission name [" + paSetName + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImplTest method searchPermissionOps.
/**
* @param msg
* @param srchValue
* @param pObjArray
*/
public static void searchPermissionOps(String msg, String srchValue, String[][] pObjArray, String[][] pOpArray) {
LogUtil.logIt(msg);
Permission pOp;
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] obj : pObjArray) {
for (String[] op : pOpArray) {
pOp = new Permission();
pOp.setObjName(PermTestData.getName(obj));
pOp.setOpName(srchValue);
List<Permission> ops = reviewMgr.findPermissions(pOp);
assertNotNull(ops);
assertTrue(CLS_NM + "searchPermissionOps srchValue [" + srchValue + "] list size check", pOpArray.length == ops.size());
int indx = ops.indexOf(new Permission(PermTestData.getName(obj), PermTestData.getName(op), PermTestData.getObjId(op)));
if (indx != -1) {
Permission entity = ops.get(indx);
assertNotNull(entity);
PermTestData.assertEquals(PermTestData.getName(obj), entity, op);
LOG.debug("searchPermissionOps objName [" + entity.getObjName() + "] operation name [" + entity.getOpName() + "] successful");
} else {
msg = "searchPermissionOps srchValue [" + srchValue + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
} catch (SecurityException ex) {
LOG.error("searchPermissionOps srchValue [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations