org.pac4j.core.engine.DefaultCallbackLogic Java Examples

The following examples show how to use org.pac4j.core.engine.DefaultCallbackLogic. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CallbackHandler.java    From vertx-pac4j with Apache License 2.0 6 votes vote down vote up
@Override
public void handle(RoutingContext event) {

    final CallbackLogic<Void, VertxWebContext> bestLogic = FindBest.callbackLogic(null, config, DefaultCallbackLogic.INSTANCE);
    final HttpActionAdapter<Void, VertxWebContext> bestAdapter = FindBest.httpActionAdapter(null, config, VertxHttpActionAdapter.INSTANCE);

    // Can we complete the authentication process here?
    final VertxWebContext webContext = new VertxWebContext(event, sessionStore);

    vertx.executeBlocking(future -> {
        bestLogic.perform(webContext, config, bestAdapter, defaultUrl, saveInSession, multiProfile, renewSession, defaultClient);
        future.complete(null);
    },
    false,
    asyncResult -> {
        // If we succeeded we're all good here, the job is done either through approving, or redirect, or
        // forbidding
        // However, if an error occurred we need to handle this here
        if (asyncResult.failed()) {
            event.fail(new TechnicalException(asyncResult.cause()));
        }
    });

}
 
Example #2
Source File: CallbackFilter.java    From jax-rs-pac4j with Apache License 2.0 5 votes vote down vote up
protected CallbackLogic<Object, JaxRsContext> buildLogic(Config config) {
    if (callbackLogic != null) {
        return callbackLogic;
    } else if (config.getCallbackLogic() != null) {
        return config.getCallbackLogic();
    } else {
        DefaultCallbackLogic<Object, JaxRsContext> logic = new DefaultCallbackLogic<>();
        logic.setProfileManagerFactory(JaxRsProfileManager::new);
        return logic;
    }
}
 
Example #3
Source File: CallbackController.java    From spring-webmvc-pac4j with Apache License 2.0 5 votes vote down vote up
@RequestMapping("${pac4j.callback.path:/callback}")
public void callback(final HttpServletRequest request, final HttpServletResponse response) {

    final SessionStore<JEEContext> bestSessionStore = FindBest.sessionStore(null, config, JEESessionStore.INSTANCE);
    final HttpActionAdapter<Object, JEEContext> bestAdapter = FindBest.httpActionAdapter(null, config, JEEHttpActionAdapter.INSTANCE);
    final CallbackLogic<Object, JEEContext> bestLogic = FindBest.callbackLogic(callbackLogic, config, DefaultCallbackLogic.INSTANCE);

    final JEEContext context = (JEEContext) FindBest.webContextFactory(null, config, JEEContextFactory.INSTANCE)
            .newContext(request, response, bestSessionStore);
    bestLogic.perform(context, config, bestAdapter, this.defaultUrl, this.saveInSession, this.multiProfile,
            this.renewSession, this.defaultClient);
}
 
Example #4
Source File: CallbackFilter.java    From jee-pac4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void internalFilter(final HttpServletRequest request, final HttpServletResponse response,
                                       final FilterChain chain) throws IOException, ServletException {

    final Config config = getSharedConfig();

    final SessionStore<JEEContext> bestSessionStore = FindBest.sessionStore(null, config, JEESessionStore.INSTANCE);
    final HttpActionAdapter<Object, JEEContext> bestAdapter = FindBest.httpActionAdapter(null, config, JEEHttpActionAdapter.INSTANCE);
    final CallbackLogic<Object, JEEContext> bestLogic = FindBest.callbackLogic(callbackLogic, config, DefaultCallbackLogic.INSTANCE);

    final JEEContext context = new JEEContext(request, response, bestSessionStore);
    bestLogic.perform(context, config, bestAdapter, this.defaultUrl, this.saveInSession, this.multiProfile, this.renewSession, this.defaultClient);
}