use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method addPermissionAttributeToSet.
public static void addPermissionAttributeToSet(String msg, String name, PermissionAttribute permAttr) {
LogUtil.logIt(msg);
PermissionAttributeSet paSet = new PermissionAttributeSet(name);
try {
AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
adminMgr.addPermissionAttributeToSet(permAttr, name);
LOG.debug("addPermissionAttributeToSet name [" + paSet.getName() + "] successful");
} catch (SecurityException ex) {
LOG.error("addPermissionAttributeToSet name [" + paSet.getName() + "] 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 delPermAttrSet.
public static void delPermAttrSet(String msg, String name) {
LogUtil.logIt(msg);
PermissionAttributeSet paSet = new PermissionAttributeSet(name);
try {
AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
adminMgr.deletePermissionAttributeSet(paSet);
LOG.debug("delPermAttrSet name [" + paSet.getName() + "] successful");
} catch (SecurityException ex) {
LOG.error("delPermAttrSet name [" + paSet.getName() + "] 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 deleteUsers.
/**
* @param uArray
*/
public static void deleteUsers(String msg, String[][] uArray, boolean force, boolean isAdmin) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] usr : uArray) {
User user = new User();
user.setUserId(UserTestData.getUserId(usr));
try {
if (force) {
adminMgr.deleteUser(user);
LOG.debug("deleteUsers force user [" + user.getUserId() + "] successful");
} else {
adminMgr.disableUser(user);
LOG.debug("deleteUsers user [" + user.getUserId() + "] successful");
}
} catch (SecurityException ex) {
// don't fail test if user was a system user:
if (ex.getErrorId() != GlobalErrIds.USER_PLCY_VIOLATION) {
LOG.error("deleteUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
}
} catch (SecurityException ex) {
LOG.error("deleteUsers 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 delRoleGrantsHB.
/**
* @param msg
* @param rArray
* @param objArray
* @param opArray
*/
private void delRoleGrantsHB(String msg, String[][] uArray, String[][] rArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] obj : objArray) {
int i = 0;
for (String[] rle : rArray) {
// Get Role[i] from test data:
Role role = RoleTestData.getRole(rle);
// Get Permission[i] from test data:
String[] op = opArray[i];
// Load the permission entity with data:
Permission pOp = PermTestData.getOp(PermTestData.getName(obj), op);
// Grant Permission[i] to Role[i]:
adminMgr.revokePermission(pOp, role);
// Get User[i] from test data:
String[] usr = uArray[i];
// Load the User entity with data:
User user = UserTestData.getUser(usr);
// Grant Permission[i] to User[i]:
adminMgr.revokePermission(pOp, user);
i++;
LOG.debug("delRoleGrantsHB userId [" + user.getUserId() + "] role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("delRoleGrantsHB 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 testRemoveUserRoleConstraint.
public void testRemoveUserRoleConstraint() throws SecurityException {
this.assertRoleConstraintSize(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0], 1);
RoleConstraint rc1 = assignUserRoleConstraint("ASGN-URC-VALID TU1 TR1", UserTestData.USERS_TU1[0], RoleTestData.ROLES_TR1[1], URATestData.getRC(URATestData.URC_T2));
RoleConstraint rc2 = assignUserRoleConstraint("ASGN-URC-VALID TU1 TR1", UserTestData.USERS_TU1[0], RoleTestData.ROLES_TR1[1], URATestData.getRC(URATestData.URC_T3));
this.assertRoleConstraintSize(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0], 3);
AdminMgr adminMgr = getManagedAdminMgr();
adminMgr.removeRoleConstraint(new UserRole(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0]), rc1);
this.assertRoleConstraintSize(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0], 2);
adminMgr.removeRoleConstraint(new UserRole(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0]), rc2.getId());
this.assertRoleConstraintSize(UserTestData.USERS_TU1[0][0], RoleTestData.ROLES_TR1[1][0], 1);
}
Aggregations