We are integrating with ServiceNow and need to close an open request when midPoint has performed the operation. For this purpose we are using the attached hook. In order to do this, we are storing the ServiceNow URL and credentials in the System Configuration.
Due to the fact that provisioning may take a while, we are calling midpoint.executeChangesAsynchronously in our custom REST service.
When calling synchronously, or using the same user in the UI, the call to ServiceNow works no problem. When being called from the task that gets created when being called asynchronously, the following line results in an Access Denied, even though the task owner has permission to do the following:
SystemConfigurationType systemConfigurationType = midpoint.getObject(SystemConfigurationType.class, "00000000-0000-0000-0000-000000000001");
As the user can not retrieve the stored credentials from the system configuration, the rest of the hook also fails.