use of org.apache.directory.fortress.core.model.User 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.getKey().equals(rc.getKey())) {
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());
}
}
use of org.apache.directory.fortress.core.model.User in project directory-fortress-core by apache.
the class ReviewMgrImplTest method assignUserRoleConstraints.
private void assignUserRoleConstraints(String msg, String[][] urArray) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] urConstraint : urArray) {
UserRole uRole = RoleTestData.getUserRoleConstraintAbac(urConstraint);
RoleConstraint constraint = uRole.getConstraints().get(0);
List<User> users = reviewMgr.assignedUsers(new Role(uRole.getName()), constraint);
assertTrue(users.size() > 0);
}
} catch (SecurityException ex) {
LOG.error("assignUserRoleConstraints caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.User in project directory-fortress-core by apache.
the class ReviewMgrImplTest method userPermissions.
/**
* @param msg
* @param uArray
* @param pObjArray
* @param pOpArray
*/
public static void userPermissions(String msg, String[][] uArray, String[][] pObjArray, String[][] pOpArray) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
List<Permission> perms = reviewMgr.userPermissions(user);
assertNotNull(perms);
assertTrue(CLS_NM + "userPermissions list size check", pOpArray.length * pObjArray.length == perms.size());
for (String[] obj : pObjArray) {
for (String[] op : pOpArray) {
int indx = perms.indexOf(new Permission(PermTestData.getName(obj), PermTestData.getName(op), PermTestData.getObjId(op)));
if (indx != -1) {
Permission pOp = perms.get(indx);
assertNotNull(pOp);
PermTestData.assertEquals(PermTestData.getName(obj), pOp, op);
LOG.debug("userPermissions userId [" + user.getUserId() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] successful");
} else {
msg = "userPermissions userId [" + user.getUserId() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
}
} catch (SecurityException ex) {
LOG.error("userPermissions caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.User in project directory-fortress-core by apache.
the class AdminMgrImplTest method assignUsersDSD.
/**
* @param msg
* @param uArray
* @param sArray
*/
public static void assignUsersDSD(String msg, String[][] uArray, String[][] sArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
int i = 0;
for (String[] usr : uArray) {
SDSet dsd = RoleTestData.getSDSet(sArray[i++]);
Set<String> roles = dsd.getMembers();
User user = UserTestData.getUser(usr);
int j = 0;
for (String role : roles) {
j++;
UserRole uRole = new UserRole(user.getUserId(), role);
try {
adminMgr.assignUser(uRole);
} catch (SecurityException ex) {
LOG.error("assignUsersDSD caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(CLS_NM + "assignUsersDSD user [" + user.getUserId() + "] role [" + role + "] dsd [" + dsd.getName() + "] failed");
}
}
}
} catch (SecurityException ex) {
LOG.error("assignUsersDSD caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.User in project directory-fortress-core by apache.
the class AdminMgrImplTest method addUserGrants.
/**
* @param uArray
* @param objArray
* @param opArray
*/
public static void addUserGrants(String msg, String[][] uArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
User user = new User();
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] usr : uArray) {
for (String[] obj : objArray) {
for (String[] op : opArray) {
user = new User(UserTestData.getUserId(usr));
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.grantPermission(pOp, user);
LOG.debug("addUserGrants userId [" + user.getUserId() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addUserGrants userId [" + user.getUserId() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations