use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class AdminMgrImplTest method addInheritedRoles.
/**
* @param rArray
*/
public static void addInheritedRoles(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
Set<String> parents = RoleTestData.getRelationships(rle);
if (parents != null) {
for (String pRole : parents) {
adminMgr.addInheritance(new Role(pRole), role);
LOG.debug("addInheritedRoles child role [" + role.getName() + "] parent role [" + pRole + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addInheritedRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class AdminMgrImplTest method delRoleGrants.
/**
* @param rArray
* @param objArray
* @param opArray
*/
public static void delRoleGrants(String msg, String[][] rArray, String[][] objArray, String[][] opArray, boolean isAdmin) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
Role role = new Role();
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] rle : rArray) {
for (String[] obj : objArray) {
for (String[] op : opArray) {
role = new Role(RoleTestData.getName(rle));
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.revokePermission(pOp, role);
LOG.debug("delRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("delRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class AdminMgrImplTest method updateRoles.
/**
* @param msg
* @param rArray
*/
public static void updateRoles(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
Role entity = adminMgr.updateRole(role);
LOG.debug("updateRoles role [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("updateRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Role 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.model.Role 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());
}
}
Aggregations