Search in sources :

Example 81 with SecurityViolationException

use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.

the class ExpressionUtil method addActorVariable.

public static void addActorVariable(ExpressionVariables scriptVariables, SecurityEnforcer securityEnforcer) {
    // There can already be a value, because for mappings, we create the
    // variable before parsing sources.
    // For other scripts we do it just before the execution, to catch all
    // possible places where scripts can be executed.
    UserType oldActor = (UserType) scriptVariables.get(ExpressionConstants.VAR_ACTOR);
    if (oldActor != null) {
        return;
    }
    UserType actor = null;
    try {
        if (securityEnforcer != null) {
            if (!securityEnforcer.isAuthenticated()) {
                // This is most likely evaluation of role
                // condition before
                // the authentication is complete.
                scriptVariables.addVariableDefinition(ExpressionConstants.VAR_ACTOR, null);
                return;
            }
            MidPointPrincipal principal = securityEnforcer.getPrincipal();
            if (principal != null) {
                actor = principal.getUser();
            }
        }
        if (actor == null) {
            LOGGER.debug("Couldn't get principal information - the 'actor' variable is set to null");
        }
    } catch (SecurityViolationException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get principal information - the 'actor' variable is set to null", e);
    }
    scriptVariables.addVariableDefinition(ExpressionConstants.VAR_ACTOR, actor);
}
Also used : SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 82 with SecurityViolationException

use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.

the class AbstractLdapHierarchyTest method reconcileAllUsers.

protected void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    final Task task = createTask("reconcileAllUsers");
    OperationResult result = task.getResult();
    ResultHandler<UserType> handler = new ResultHandler<UserType>() {

        @Override
        public boolean handle(PrismObject<UserType> object, OperationResult parentResult) {
            try {
                display("reconciling " + object);
                reconcileUser(object.getOid(), task, parentResult);
            } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException | ConfigurationException | SecurityViolationException e) {
                throw new SystemException(e.getMessage(), e);
            }
            return true;
        }
    };
    display("Reconciling all users");
    modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismObject(com.evolveum.midpoint.prism.PrismObject) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 83 with SecurityViolationException

use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.

the class TestCertificationBasic method test150CloseFirstStageDeny.

@Test
public void test150CloseFirstStageDeny() throws Exception {
    final String TEST_NAME = "test150CloseFirstStageDeny";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(getUserFromRepo(USER_ELAINE_OID));
    // GIVEN
    Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN+THEN
    TestUtil.displayWhen(TEST_NAME);
    try {
        certificationService.closeCurrentStage(campaignOid, 1, task, result);
        fail("Unexpected success");
    } catch (SecurityViolationException e) {
        System.out.println("Got expected deny exception: " + e.getMessage());
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 84 with SecurityViolationException

use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.

the class TestCertificationBasic method test151CloseCampaignDeny.

@Test
public void test151CloseCampaignDeny() throws Exception {
    final String TEST_NAME = "test151CloseCampaignDeny";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(getUserFromRepo(USER_ELAINE_OID));
    // GIVEN
    Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN+THEN
    TestUtil.displayWhen(TEST_NAME);
    try {
        certificationService.closeCampaign(campaignOid, task, result);
        fail("Unexpected success");
    } catch (SecurityViolationException e) {
        System.out.println("Got expected deny exception: " + e.getMessage());
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 85 with SecurityViolationException

use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.

the class TestCertificationBasic method test200StartRemediationDeny.

@Test
public void test200StartRemediationDeny() throws Exception {
    final String TEST_NAME = "test200StartRemediationDeny";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(getUserFromRepo(USER_ELAINE_OID));
    // GIVEN
    Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
    task.setOwner(userAdministrator.asPrismObject());
    OperationResult result = task.getResult();
    // WHEN+THEN
    TestUtil.displayWhen(TEST_NAME);
    try {
        certificationService.startRemediation(campaignOid, task, result);
    } catch (SecurityViolationException e) {
        System.out.println("Got expected deny exception: " + e.getMessage());
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

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