use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class AdminMgrImplTest method deleteDsdRoleMember.
/**
* @param sArray
*/
private void deleteDsdRoleMember(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);
// first add all of the roles as members of SSD entity:
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
dsd.addMember(role.getName());
}
// now iterate over roles and remove from DSD set one at a time.
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.deleteDsdRoleMember(dsd, role);
List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
assertTrue(CLS_NM + "deleteDsdRoleMember list size check", dsdSets.size() == 0);
}
adminMgr.deleteDsdSet(dsd);
LOG.debug("deletedsdRoleMember DSD [" + dsd.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteDsdRoleMember 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 addDsdRoleMember.
/**
* @param sArray
*/
public static void addDsdRoleMember(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("addDsdRoleMember DSD [" + entity.getName() + "] successful");
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.addDsdRoleMember(dsd, role);
List<SDSet> dsdSets = reviewMgr.dsdRoleSets(role);
assertNotNull(dsdSets);
assertTrue(CLS_NM + "addDsdRoleMember list size check", dsdSets.size() == 1);
SDSet dsd2 = dsdSets.get(0);
assertTrue(CLS_NM + "addDsdRoleMember DSD name check", dsd.getName().equals(dsd2.getName()));
assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().contains(role.getName()));
// assertTrue(CLS_NM + "addDsdRoleMember DSD role check", dsd2.getMembers().containsKey(role.getName()));
}
}
} catch (SecurityException ex) {
LOG.error("addDsdRoleMember 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 addRoleAscendant.
/**
* @param msg
* @param rArray
*/
public static void addRoleAscendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
if (RoleTestData.isCreate(rle)) {
adminMgr.addRole(role);
LOG.debug("addAscendant add role [" + role.getName() + "] successful");
}
Set<String> ascs = RoleTestData.getRelationships(rle);
if (ascs != null) {
for (String asc : ascs) {
adminMgr.addAscendant(role, new Role(asc));
LOG.debug("addAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String asc : inheritances) {
adminMgr.addInheritance(new Role(asc), role);
LOG.debug("addAscendant desc role [" + role.getName() + "] asc role [" + asc + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addDescendant 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 addRoleGrantsH.
/**
* @param msg
* @param rArray
* @param objArray
* @param opArray
*/
public static void addRoleGrantsH(String msg, String[][] rArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
Role role = new Role();
try {
AdminMgr adminMgr = getManagedAdminMgr();
int i = 0;
for (String[] obj : objArray) {
role = new Role(RoleTestData.getName(rArray[i++]));
for (String[] op : opArray) {
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.grantPermission(pOp, role);
LOG.debug("addRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("addRoleGrantsH 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 addRoles.
/**
* @param rArray
*/
public static void addRoles(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
Role entity = adminMgr.addRole(role);
LOG.debug("addRoles role [" + entity.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("addRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations