use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class AbstractSecurityTest method assertDeleteDeny.
protected <O extends ObjectType> void assertDeleteDeny(Class<O> type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
Task task = taskManager.createTaskInstance(AbstractSecurityTest.class.getName() + ".assertDeleteDeny");
OperationResult result = task.getResult();
ObjectDelta<O> delta = ObjectDelta.createDeleteDelta(type, oid, prismContext);
try {
logAttempt("delete", type, oid, null);
modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result);
failDeny("delete", type, oid, null);
} catch (SecurityViolationException e) {
// this is expected
logDeny("delete", type, oid, null);
result.computeStatus();
TestUtil.assertFailure(result);
} catch (ObjectNotFoundException e) {
// MID-3221
// still consider OK ... for now
logError("delete", type, oid, null);
result.computeStatus();
TestUtil.assertFailure(result);
}
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class AbstractSecurityTest method assertModifyAllowOptions.
protected <O extends ObjectType> void assertModifyAllowOptions(Class<O> type, String oid, ItemPath itemPath, ModelExecuteOptions options, Object... newRealValue) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
Task task = taskManager.createTaskInstance(AbstractSecurityTest.class.getName() + ".assertModifyAllow");
OperationResult result = task.getResult();
ObjectDelta<O> objectDelta = ObjectDelta.createModificationReplaceProperty(type, oid, itemPath, prismContext, newRealValue);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
try {
logAttempt("modify", type, oid, itemPath);
modelService.executeChanges(deltas, options, task, result);
} catch (SecurityViolationException e) {
failAllow("modify", type, oid, itemPath, e);
}
result.computeStatus();
TestUtil.assertSuccess(result);
logAllow("modify", type, oid, itemPath);
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class AbstractSecurityTest method assertAddAllow.
protected <O extends ObjectType> void assertAddAllow(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException {
Task task = taskManager.createTaskInstance(AbstractSecurityTest.class.getName() + ".assertAddAllow");
OperationResult result = task.getResult();
PrismObject<O> object = PrismTestUtil.parseObject(file);
ObjectDelta<O> addDelta = object.createAddDelta();
logAttempt("add", object.getCompileTimeClass(), object.getOid(), null);
try {
modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result);
} catch (SecurityViolationException e) {
failAllow("add", object.getCompileTimeClass(), object.getOid(), null, e);
}
result.computeStatus();
TestUtil.assertSuccess(result);
logAllow("add", object.getCompileTimeClass(), object.getOid(), null);
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class AbstractSecurityTest method assertContainerSearch.
protected <C extends Containerable> void assertContainerSearch(Class<C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, int expectedResults) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
Task task = taskManager.createTaskInstance(AbstractSecurityTest.class.getName() + ".assertSearchContainers");
OperationResult result = task.getResult();
try {
logAttempt("searchContainers", type, query);
List<C> objects = modelService.searchContainers(type, query, options, task, result);
display("Search returned", objects.toString());
if (objects.size() > expectedResults) {
failDeny("search", type, query, expectedResults, objects.size());
} else if (objects.size() < expectedResults) {
failAllow("search", type, query, expectedResults, objects.size());
}
result.computeStatus();
TestUtil.assertSuccess(result);
} catch (SecurityViolationException e) {
// this should not happen
result.computeStatus();
TestUtil.assertFailure(result);
failAllow("search", type, query, e);
}
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class AbstractSecurityTest method assertDeleteAllow.
protected <O extends ObjectType> void assertDeleteAllow(Class<O> type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
Task task = taskManager.createTaskInstance(AbstractSecurityTest.class.getName() + ".assertDeleteAllow");
OperationResult result = task.getResult();
ObjectDelta<O> delta = ObjectDelta.createDeleteDelta(type, oid, prismContext);
logAttempt("delete", type, oid, null);
try {
modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result);
} catch (SecurityViolationException e) {
failAllow("delete", type, oid, null, e);
}
result.computeStatus();
TestUtil.assertSuccess(result);
logAllow("delete", type, oid, null);
}
Aggregations