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);
}
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);
}
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());
}
}
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());
}
}
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());
}
}
Aggregations