use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class TestDummySecurity method test210ModifyAccountQuote.
@Test
public void test210ModifyAccountQuote() throws Exception {
final String TEST_NAME = "test210ModifyAccountQuote";
TestUtil.displayTestTile(TEST_NAME);
Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME), prismContext, "eh?");
display("ObjectDelta", delta);
delta.checkConsistence();
try {
// WHEN
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
AssertJUnit.fail("Unexpected success");
} catch (SecurityViolationException e) {
// This is expected
display("Expected exception", e);
}
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class TestDummySecurity method test100AddAccountDrink.
@Test
public void test100AddAccountDrink() throws Exception {
final String TEST_NAME = "test100AddAccountDrink";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task syncTask = taskManager.createTaskInstance(TestDummySecurity.class.getName() + "." + TEST_NAME);
OperationResult result = new OperationResult(TestDummySecurity.class.getName() + "." + TEST_NAME);
syncServiceMock.reset();
PrismObject<ShadowType> account = prismContext.parseObject(ACCOUNT_WILL_FILE);
account.checkConsistence();
setAttribute(account, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water");
display("Adding shadow", account);
try {
// WHEN
provisioningService.addObject(account, null, null, syncTask, result);
AssertJUnit.fail("Unexpected success");
} catch (SecurityViolationException e) {
// This is expected
display("Expected exception", e);
}
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method fetchConnectorObject.
/**
* Returns null if nothing is found.
*/
private ConnectorObject fetchConnectorObject(StateReporter reporter, ObjectClassComplexTypeDefinition objectClassDefinition, ObjectClass icfObjectClass, Uid uid, OperationOptions options, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SecurityViolationException, SchemaException, ConfigurationException {
// Connector operation cannot create result for itself, so we need to
// create result for it
OperationResult icfResult = parentResult.createMinorSubresult(ConnectorFacade.class.getName() + ".getObject");
icfResult.addParam("objectClass", icfObjectClass.toString());
icfResult.addParam("uid", uid.getUidValue());
icfResult.addArbitraryObjectAsParam("options", options);
icfResult.addContext("connector", connIdConnectorFacade.getClass());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Fetching connector object ObjectClass={}, UID={}, options={}", new Object[] { icfObjectClass, uid, ConnIdUtil.dumpOptions(options) });
}
ConnectorObject co = null;
try {
// Invoke the ICF connector
InternalMonitor.recordConnectorOperation("getObject");
recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
co = connIdConnectorFacade.getObject(icfObjectClass, uid, options);
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
icfResult.recordSuccess();
} catch (Throwable ex) {
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, ex, uid);
String desc = this.getHumanReadableName() + " while getting object identified by ICF UID '" + uid.getUidValue() + "'";
Throwable midpointEx = processIcfException(ex, desc, icfResult);
icfResult.computeStatus("Add object failed");
// exception
if (midpointEx instanceof CommunicationException) {
icfResult.muteError();
throw (CommunicationException) midpointEx;
} else if (midpointEx instanceof GenericFrameworkException) {
throw (GenericFrameworkException) midpointEx;
} else if (midpointEx instanceof ConfigurationException) {
throw (ConfigurationException) midpointEx;
} else if (midpointEx instanceof SecurityViolationException) {
throw (SecurityViolationException) midpointEx;
} else if (midpointEx instanceof ObjectNotFoundException) {
LOGGER.trace("Got ObjectNotFoundException while looking for resource object ConnId UID: {}", uid);
return null;
} else if (midpointEx instanceof RuntimeException) {
throw (RuntimeException) midpointEx;
} else if (midpointEx instanceof Error) {
// This should not happen. But some connectors are very strange.
throw new SystemException("ERROR: " + midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
} else {
throw new SystemException(midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
}
}
return co;
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class PageTaskController method stopApprovalProcessPerformed.
void stopApprovalProcessPerformed(AjaxRequestTarget target) {
String instanceId = parentPage.getTaskDto().getProcessInstanceId();
if (instanceId == null) {
return;
}
OperationResult result = new OperationResult(PageProcessInstances.OPERATION_STOP_PROCESS_INSTANCE);
try {
parentPage.getWorkflowService().stopProcessInstance(instanceId, WebComponentUtil.getOrigStringFromPoly(SecurityUtils.getPrincipalUser().getName()), result);
result.computeStatusIfUnknown();
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't stop approval process instance {}", e, instanceId);
result.recordFatalError("Couldn't stop approval process instance " + instanceId + ": " + e.getMessage(), e);
}
afterStateChangingOperation(target, result);
}
use of com.evolveum.midpoint.util.exception.SecurityViolationException in project midpoint by Evolveum.
the class PageTasks method resumeTasksPerformed.
private void resumeTasksPerformed(AjaxRequestTarget target, List<String> oids) {
OperationResult result = new OperationResult(OPERATION_RESUME_TASKS);
try {
getTaskService().resumeTasks(oids, result);
result.computeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "The task(s) have been successfully resumed.");
}
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | RuntimeException e) {
result.recordFatalError("Couldn't resume the task(s)", e);
}
showResult(result);
//refresh feedback and table
refreshTables(target);
}
Aggregations