use of org.apache.directory.fortress.core.model.PermObj in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method canGrantPerms.
/**
* @param msg
* @param op
* @param uraArray
* @param uaArray
* @param pArray
* @param rArray
*/
public static void canGrantPerms(String msg, GRANT_OP op, String[][] uraArray, String[][] uaArray, String[][] pArray, String[][] rArray) {
LogUtil.logIt(msg);
Role role;
Map<PRA, PRA> praTestResults = PRATestData.getPRAs(uraArray);
try {
DelAccessMgr delAccessMgr = DelAccessMgrFactory.createInstance(TestUtils.getContext());
AccessMgr accessMgr = (AccessMgr) delAccessMgr;
int i = 0;
for (String[] aUsr : uaArray) {
User aUser = UserTestData.getUser(aUsr);
Session session = accessMgr.createSession(aUser, false);
assertNotNull(session);
for (String[] prm : pArray) {
PermObj pObj = PermTestData.getObj(prm);
i++;
for (String[] rle : rArray) {
role = RoleTestData.getRole(rle);
String methodName;
boolean result;
if (op == GRANT_OP.GRANT) {
result = delAccessMgr.canGrant(session, role, new Permission(pObj.getObjName(), ""));
methodName = ".canGrantPerms";
} else {
result = delAccessMgr.canRevoke(session, role, new Permission(pObj.getObjName(), ""));
methodName = ".canRevokePerms";
}
List<UserAdminRole> aRoles = session.getAdminRoles();
assertNotNull(aRoles);
assertTrue(CLS_NM + methodName + " Admin User invalid number of roles", aRoles.size() == 1);
UserAdminRole aRole = aRoles.get(0);
PRA sourceUra = new PRA(aRole.getName(), pObj.getOu(), role.getName(), result);
PRA targetUra = praTestResults.get(sourceUra);
assertTrue(CLS_NM + methodName + " cannot find target PRA admin role [" + sourceUra.getArole() + " pou [" + sourceUra.getPou() + "] role [" + sourceUra.getUrole() + "] Result [" + sourceUra.isCanAssign() + "] actual result [" + result + "]", targetUra != null);
LOG.debug(methodName + " failed target PRA admin role [" + targetUra.getArole() + " pou [" + targetUra.getPou() + "] role [" + targetUra.getUrole() + "] target result [" + targetUra.isCanAssign() + "] actual result [" + result + "]");
}
}
}
} catch (SecurityException ex) {
LOG.error("canGrantPerms op [" + op + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.PermObj in project directory-fortress-core by apache.
the class FortressAntLoadTest method testReadPermissionObj.
@Test
public void testReadPermissionObj() {
// gather permission object input data:
List<AddpermObj> addpermObjs = fortressAntTask.getAddpermObjs();
for (AddpermObj addpermObj : addpermObjs) {
List<PermObj> permObjs = addpermObj.getPermObjs();
readPermissionObjs("RD-PRM-OBJS", permObjs);
}
}
use of org.apache.directory.fortress.core.model.PermObj in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method findPermObjs.
/**
* {@inheritDoc}
*/
@Override
public List<PermObj> findPermObjs(PermObj permObj) throws SecurityException {
VUtil.assertNotNull(permObj, GlobalErrIds.PERM_OBJECT_NULL, CLS_NM + ".findPermObjs");
List<PermObj> retObjs;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(permObj);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retObjs = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retObjs;
}
use of org.apache.directory.fortress.core.model.PermObj in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method readPermObj.
/**
* {@inheritDoc}
*/
@Override
public PermObj readPermObj(PermObj permObj) throws SecurityException {
VUtil.assertNotNull(permObj, GlobalErrIds.PERM_OBJECT_NULL, CLS_NM + ".readPermObj");
PermObj retObj;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(permObj);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retObj = (PermObj) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retObj;
}
use of org.apache.directory.fortress.core.model.PermObj in project directory-fortress-core by apache.
the class AdminMgrConsole method deletePermission.
/**
* Description of the Method
*/
void deletePermission() {
try {
ReaderUtil.clearScreen();
System.out.println("Enter object name");
String name = ReaderUtil.readLn();
// System.out.println("Enter object id (or enter for NULL)");
// String object = ReaderUtil.readLn();
PermObj pObj = new PermObj();
pObj.setObjName(name);
am.deletePermObj(pObj);
System.out.println("perm object deleted: [" + name + "]");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("deletePermission caught SecurityException rc=" + e.getErrorId() + " msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations