use of org.wso2.carbon.identity.application.authentication.framework.AsyncCaller in project carbon-identity-framework by wso2.
the class AsyncSequenceExecutor method exec.
public void exec(AsyncCaller caller, AsyncReturn returnFunction, AuthenticationContext authenticationContext) throws FrameworkException {
if (returnFunction == null) {
throw new FrameworkException("Can not execute the async process, as no callback function registered on " + "returnFunction.");
}
AsyncReturn wrappedReturn = (ctx, m, r) -> {
this.execReturn(returnFunction, ctx, m, r);
};
executorService.submit(new AsyncCallerTask(new ObservingAsyncProcess(caller, wrappedReturn, authenticationContext)));
}
use of org.wso2.carbon.identity.application.authentication.framework.AsyncCaller in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method callExternalSystem.
private boolean callExternalSystem(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context, SequenceConfig sequenceConfig, LongWaitNode longWaitNode) throws FrameworkException {
AsyncProcess asyncProcess = longWaitNode.getAsyncProcess();
if (asyncProcess == null) {
return false;
}
AsyncCaller caller = asyncProcess.getAsyncCaller();
AsyncReturn asyncReturn = rethrowTriConsumer((authenticationContext, data, result) -> {
authenticationContext.setProperty(FrameworkConstants.JSAttributes.JS_CALL_AND_WAIT_STATUS, result);
authenticationContext.setProperty(FrameworkConstants.JSAttributes.JS_CALL_AND_WAIT_DATA, data);
if (!promptOnLongWait()) {
synchronized (context) {
context.notify();
}
}
});
if (caller != null) {
FrameworkServiceDataHolder.getInstance().getAsyncSequenceExecutor().exec(caller, asyncReturn, context);
if (!promptOnLongWait()) {
int waitTimeout = getLongWaitTimeout();
synchronized (context) {
try {
context.wait(waitTimeout);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("Thread interrupted while waiting for the external call to complete for session " + "data key: " + context.getContextIdentifier() + ". ", e);
}
}
resumeLongWait(request, response, context);
}
return true;
}
return false;
}
Aggregations