use of org.pac4j.core.http.adapter.HttpActionAdapter in project buji-pac4j by bujiio.
the class SecurityFilter method doFilter.
@Override
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
final SessionStore bestSessionStore = FindBest.sessionStore(null, config, ShiroSessionStore.INSTANCE);
final HttpActionAdapter bestAdapter = FindBest.httpActionAdapter(null, config, JEEHttpActionAdapter.INSTANCE);
final SecurityLogic bestLogic = FindBest.securityLogic(securityLogic, config, DefaultSecurityLogic.INSTANCE);
final WebContext context = FindBest.webContextFactory(null, config, JEEContextFactory.INSTANCE).newContext(servletRequest, servletResponse);
bestLogic.perform(context, bestSessionStore, config, (ctx, session, profiles, parameters) -> {
filterChain.doFilter(servletRequest, servletResponse);
return null;
}, bestAdapter, clients, authorizers, matchers);
}
use of org.pac4j.core.http.adapter.HttpActionAdapter in project buji-pac4j by bujiio.
the class CallbackFilter method doFilter.
@Override
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
final SessionStore bestSessionStore = FindBest.sessionStore(null, config, ShiroSessionStore.INSTANCE);
final HttpActionAdapter bestAdapter = FindBest.httpActionAdapter(httpActionAdapter, config, JEEHttpActionAdapter.INSTANCE);
final CallbackLogic bestLogic = FindBest.callbackLogic(callbackLogic, config, DefaultCallbackLogic.INSTANCE);
final WebContext context = FindBest.webContextFactory(null, config, JEEContextFactory.INSTANCE).newContext(servletRequest, servletResponse);
bestLogic.perform(context, bestSessionStore, config, bestAdapter, defaultUrl, false, defaultClient);
}
use of org.pac4j.core.http.adapter.HttpActionAdapter in project vertx-pac4j by pac4j.
the class CallbackHandler method handle.
@Override
public void handle(RoutingContext event) {
final CallbackLogic bestLogic = FindBest.callbackLogic(null, config, DefaultCallbackLogic.INSTANCE);
final HttpActionAdapter 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, sessionStore, config, bestAdapter, defaultUrl, renewSession, defaultClient);
future.complete(null);
}, false, asyncResult -> {
// forbidding. However, if an error occurred we need to handle this here
if (asyncResult.failed()) {
event.fail(new TechnicalException(asyncResult.cause()));
}
});
}
use of org.pac4j.core.http.adapter.HttpActionAdapter in project vertx-pac4j by pac4j.
the class LogoutHandler method handle.
@Override
public void handle(final RoutingContext routingContext) {
final LogoutLogic bestLogic = FindBest.logoutLogic(null, config, DefaultLogoutLogic.INSTANCE);
final HttpActionAdapter bestAdapter = FindBest.httpActionAdapter(null, config, VertxHttpActionAdapter.INSTANCE);
final VertxWebContext webContext = new VertxWebContext(routingContext, sessionStore);
vertx.executeBlocking(future -> {
bestLogic.perform(webContext, sessionStore, config, bestAdapter, defaultUrl, logoutUrlPattern, localLogout, destroySession, centralLogout);
future.complete(null);
}, false, asyncResult -> {
// However, if an error occurred we need to handle this here
if (asyncResult.failed()) {
routingContext.fail(new TechnicalException(asyncResult.cause()));
}
});
}
use of org.pac4j.core.http.adapter.HttpActionAdapter in project vertx-pac4j by pac4j.
the class SecurityHandler method authenticate.
@Override
public void authenticate(RoutingContext routingContext, Handler<AsyncResult<User>> handler) {
final SecurityLogic bestLogic = FindBest.securityLogic(null, config, DefaultSecurityLogic.INSTANCE);
final HttpActionAdapter bestAdapter = FindBest.httpActionAdapter(null, config, VertxHttpActionAdapter.INSTANCE);
final VertxWebContext webContext = new VertxWebContext(routingContext, sessionStore);
vertx.executeBlocking(future -> bestLogic.perform(webContext, sessionStore, config, (ctx, store, profiles, parameters) -> {
// This is what should occur if we are authenticated and authorized to view the requested
// resource
future.complete();
return null;
}, bestAdapter, clientNames, authorizerName, matcherName), asyncResult -> {
// However, if an error occurred we need to handle this here
if (asyncResult.failed()) {
unexpectedFailure(routingContext, asyncResult.cause());
} else {
LOG.info("Authorised to view resource " + routingContext.request().path());
routingContext.next();
}
});
}
Aggregations