use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method setDsdCardinality.
/**
* @param msg
* @param sArray
* @param rArray
*/
public static void setDsdCardinality(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] dsdle : sArray) {
SDSet dsd = RoleTestData.getSDSet(dsdle);
SDSet entity = adminMgr.createDsdSet(dsd);
LOG.debug("setDsdCardinality DSD [" + entity.getName() + "] successful");
int cardinality = 1;
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.addDsdRoleMember(dsd, role);
adminMgr.setDsdSetCardinality(dsd, cardinality);
int currentCardinality = reviewMgr.dsdRoleSetCardinality(dsd);
assertTrue(CLS_NM + "setDsdCardinality cardinality check", currentCardinality == cardinality++);
}
}
} catch (SecurityException ex) {
LOG.error("setDsdCardinality 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 addPermissionAttributeSet.
public static void addPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttr) {
LogUtil.logIt(msg);
PermissionAttributeSet paSet = new PermissionAttributeSet(name);
paSet.setType(PermTestData.TPA_SET_TYPE);
try {
paSet.setAttributes(permAttr);
AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
adminMgr.addPermissionAttributeSet(paSet);
LOG.debug("addPermissionAttributeSet name [" + paSet.getName() + "] successful");
} catch (SecurityException ex) {
LOG.error("addPermissionAttributeSet 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 delPermOps.
/**
* @param objArray
* @param opArray
*/
public static void delPermOps(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.deletePermission(pOp);
LOG.debug("delPermOps objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] successful");
}
}
} catch (SecurityException ex) {
if (!canFail) {
LOG.error("delPermOps 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.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method delRoleDescendant.
/**
* @param msg
*/
private void delRoleDescendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
// use list because order is important for test structure:
List<String> descs = RoleTestData.getRelationshipList(rle);
if (descs != null) {
if (RoleTestData.isTree(rle)) {
Role parent = role;
for (String desc : descs) {
Role child = new Role(desc);
adminMgr.deleteInheritance(parent, new Role(desc));
LOG.debug("delRoleDescendant asc role [" + role.getName() + "] desc role [" + desc + "] successful");
parent = child;
}
} else {
for (String desc : descs) {
adminMgr.deleteInheritance(role, new Role(desc));
LOG.debug("delRoleDescendant asc role [" + role.getName() + "] desc role [" + desc + "] successful");
}
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String desc : inheritances) {
adminMgr.deleteInheritance(role, new Role(desc));
LOG.debug("delRoleDescendant asc role [" + role.getName() + "] desc role [" + desc + "] successful");
}
}
adminMgr.deleteRole(role);
LOG.debug("delRoleDescendant remove asc role [" + role.getName() + "] successful");
}
// cleanup the last row of descendants from roles data set.
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
String roleSrchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
List<Role> cleanup = reviewMgr.findRoles(roleSrchVal);
for (Role re : cleanup) {
adminMgr.deleteRole(re);
LOG.debug("delRoleDescendant cleanup role [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delRoleDescendant 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 updateUsers.
/**
* @param uArray
*/
public static void updateUsers(String msg, String[][] uArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
adminMgr.updateUser(user);
LOG.debug("updateUsers user [" + user.getUserId() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("updateUsers: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations