use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class CreateUserSample method teardownRequired.
/**
* Determines if teardown needs to occur on sample data.
*
* @return true if teardown is required
*/
static boolean teardownRequired() {
// The default for this check is 'true'
boolean tearDown = true;
String methodName = ".teardownRequired";
try {
ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(TestUtils.getContext());
User inUser = new User(TEST_USERID, TEST_PASSWORD);
reviewMgr.readUser(inUser);
// If we get here, the sample data needs to be removed:
} catch (SecurityException ex) {
if (ex.getErrorId() == GlobalErrIds.USER_NOT_FOUND) {
// If we get here the sample data does not need to be removed:
tearDown = false;
} else {
String warning = methodName + " caught SecurityException=" + ex.getMessage();
LOG.warn(warning);
}
}
LOG.info(methodName + ":" + tearDown);
return tearDown;
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method findUserRoleWithConstraints.
public static void findUserRoleWithConstraints(String msg, String usr, String role, RoleConstraint.RCType rcType, String paSetName) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
List<UserRole> urs = reviewMgr.assignedUsers(new Role(role), rcType, paSetName);
assertTrue(urs.size() > 0);
assertTrue(urs.get(0).getRoleConstraints().size() > 0);
LOG.debug("findUserRoleWithConstraints paSetName [" + paSetName + "] successful");
} catch (SecurityException ex) {
LOG.error("findUserRoleWithConstraints paSetName [" + paSetName + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method readPermissionObjs.
/**
* @param msg
* @param pArray
*/
public static void readPermissionObjs(String msg, String[][] pArray) {
PermObj pObj = new PermObj();
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] objs : pArray) {
pObj = new PermObj();
pObj.setObjName(PermTestData.getName(objs));
PermObj entity = reviewMgr.readPermObj(pObj);
assertNotNull(entity);
PermTestData.assertEquals(entity, objs);
LOG.debug("readPermissionObjs object name [" + pObj.getObjName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("readPermissionOps object name [" + pObj.getObjName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage() + ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method readPermissionAttributeSet.
public static void readPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttributes) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
PermissionAttributeSet entity = reviewMgr.readPermAttributeSet(new PermissionAttributeSet(name));
assertNotNull(entity);
assertEquals(name, entity.getName());
assertEquals(PermTestData.TPA_SET_TYPE, entity.getType());
for (PermissionAttribute pa : permAttributes) {
assertTrue(entity.getAttributes().contains(pa));
}
LOG.debug("readPermissionAttributeSet name [" + name + "] successful");
} catch (SecurityException ex) {
LOG.error("readPermissionAttributeSet name [" + name + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage() + ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method readUserRoleConstraint.
public static void readUserRoleConstraint(String msg, String[] usr, String[] rle, RoleConstraint rc) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
User user = UserTestData.getUser(usr);
Role role = RoleTestData.getRole(rle);
List<UserRole> urs = reviewMgr.assignedRoles(user);
boolean uraFound = false;
boolean urcFound = false;
for (UserRole ur : urs) {
if (ur.getName().equals(role.getName())) {
uraFound = true;
List<RoleConstraint> rcs = ur.getRoleConstraints();
for (RoleConstraint r : rcs) {
if (r.getPaSetName().equals(rc.getPaSetName())) {
urcFound = true;
assertEquals(rc.getType(), r.getType());
assertEquals(rc.getValue(), r.getValue());
assertNotNull(r.getId());
}
}
}
}
if (!uraFound) {
fail("User Role Assignment Not Found");
}
if (!urcFound) {
fail("User Role Constraint Not Found");
}
LOG.debug("readUserRoleConstraint value [" + rc.getValue() + "] successful");
} catch (SecurityException ex) {
LOG.error("readUserRoleConstraint value [" + rc.getValue() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations