Search in sources :

Example 41 with SecurityViolationException

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);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 42 with SecurityViolationException

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);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 43 with SecurityViolationException

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 44 with SecurityViolationException

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);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 45 with SecurityViolationException

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)131 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)109 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)93 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)84 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)66 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)64 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)57 Task (com.evolveum.midpoint.task.api.Task)53 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)35 SystemException (com.evolveum.midpoint.util.exception.SystemException)29 PrismObject (com.evolveum.midpoint.prism.PrismObject)24 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)19 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)17 ArrayList (java.util.ArrayList)17 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)15 QName (javax.xml.namespace.QName)13 Test (org.testng.annotations.Test)12 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)11