org.pac4j.core.http.adapter.HttpActionAdapter Java Examples
The following examples show how to use
org.pac4j.core.http.adapter.HttpActionAdapter.
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: LogoutHandler.java From vertx-pac4j with Apache License 2.0 | 6 votes |
@Override public void handle(final RoutingContext routingContext) { final LogoutLogic<Void, VertxWebContext> bestLogic = FindBest.logoutLogic(null, config, DefaultLogoutLogic.INSTANCE); final HttpActionAdapter<Void, VertxWebContext> bestAdapter = FindBest.httpActionAdapter(null, config, VertxHttpActionAdapter.INSTANCE); final VertxWebContext webContext = new VertxWebContext(routingContext, sessionStore); vertx.executeBlocking(future -> { bestLogic.perform(webContext, config, bestAdapter, defaultUrl, logoutUrlPattern, localLogout, destroySession, centralLogout); 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()) { routingContext.fail(new TechnicalException(asyncResult.cause())); } }); }
Example #2
Source File: CallbackHandler.java From vertx-pac4j with Apache License 2.0 | 6 votes |
@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 #3
Source File: SecurityFilter.java From jee-pac4j with Apache License 2.0 | 6 votes |
@Override protected final void internalFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) 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 SecurityLogic<Object, JEEContext> bestLogic = FindBest.securityLogic(securityLogic, config, DefaultSecurityLogic.INSTANCE); final JEEContext context = new JEEContext(request, response, bestSessionStore); bestLogic.perform(context, config, (ctx, profiles, parameters) -> { // if no profiles are loaded, pac4j is not concerned with this request filterChain.doFilter(profiles.isEmpty() ? request : new Pac4JHttpServletRequestWrapper(request, profiles), response); return null; }, bestAdapter, clients, authorizers, matchers, multiProfile); }
Example #4
Source File: DefaultFeatureSupport.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
@Override public void setup(Bootstrap<?> bootstrap) { ObjectMapper om = bootstrap.getObjectMapper(); // for Config om.addMixIn(SessionStore.class, sessionStoreMixin()); om.addMixIn(Authorizer.class, authorizerMixin()); om.addMixIn(HttpActionAdapter.class, httpActionAdapterMixin()); om.addMixIn(Matcher.class, matcherMixin()); om.addMixIn(SecurityLogic.class, securityLogicMixin()); om.addMixIn(CallbackLogic.class, callbackLogicMixin()); om.addMixIn(LogoutLogic.class, logoutLogicMixin()); // for Clients om.addMixIn(Client.class, clientMixin()); om.addMixIn(BaseClient.class, baseClientMixin()); // for Clients and Client subsclasses om.addMixIn(AjaxRequestResolver.class, ajaxRequestResolverMixin()); om.addMixIn(UrlResolver.class, urlResolverMixin()); om.addMixIn(CallbackUrlResolver.class, callbackUrlResolverMixin()); om.addMixIn(AuthorizationGenerator.class, authorizationGeneratorMixin()); // for Client/BaseClient om.addMixIn(Authenticator.class, authenticatorMixin()); om.addMixIn(CredentialsExtractor.class, credentialExtractorMixin()); om.addMixIn(ProfileCreator.class, profileCreatorMixin()); // for IndirectClient om.addMixIn(RedirectActionBuilder.class, redirectActionBuilderMixin()); om.addMixIn(LogoutActionBuilder.class, logoutActionBuilderMixin()); // for some of the Authenticators om.addMixIn(PasswordEncoder.class, passwordEncoderMixin()); }
Example #5
Source File: SecurityInterceptor.java From spring-webmvc-pac4j with Apache License 2.0 | 5 votes |
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { final SessionStore<JEEContext> bestSessionStore = FindBest.sessionStore(null, config, JEESessionStore.INSTANCE); final HttpActionAdapter<Boolean, JEEContext> bestAdapter = FindBest.httpActionAdapter(httpActionAdapter, config, JEEHttpActionAdapter.INSTANCE); final SecurityLogic<Boolean, JEEContext> bestLogic = FindBest.securityLogic(securityLogic, config, DefaultSecurityLogic.INSTANCE); final JEEContext context = (JEEContext) FindBest.webContextFactory(null, config, JEEContextFactory.INSTANCE) .newContext(request, response, bestSessionStore); final Object result = bestLogic.perform(context, config, (ctx, profiles, parameters) -> true, bestAdapter, clients, authorizers, matchers, multiProfile); if (result == null) { return false; } return Boolean.parseBoolean(result.toString()); }
Example #6
Source File: LogoutController.java From spring-webmvc-pac4j with Apache License 2.0 | 5 votes |
@RequestMapping("${pac4j.logout.path:/logout}") public void logout(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 LogoutLogic<Object, JEEContext> bestLogic = FindBest.logoutLogic(logoutLogic, config, DefaultLogoutLogic.INSTANCE); final JEEContext context = (JEEContext) FindBest.webContextFactory(null, config, JEEContextFactory.INSTANCE) .newContext(request, response, bestSessionStore); bestLogic.perform(context, config, bestAdapter, this.defaultUrl, this.logoutUrlPattern, this.localLogout, this.destroySession, this.centralLogout); }
Example #7
Source File: CallbackController.java From spring-webmvc-pac4j with Apache License 2.0 | 5 votes |
@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 #8
Source File: SecurityHandler.java From vertx-pac4j with Apache License 2.0 | 5 votes |
@Override public void handle(final RoutingContext routingContext) { final SecurityLogic<Void, VertxWebContext> bestLogic = FindBest.securityLogic(null, config, DefaultSecurityLogic.INSTANCE); final HttpActionAdapter<Void, VertxWebContext> bestAdapter = FindBest.httpActionAdapter(null, config, VertxHttpActionAdapter.INSTANCE); final VertxWebContext webContext = new VertxWebContext(routingContext, sessionStore); vertx.executeBlocking(future -> bestLogic.perform(webContext, config, (ctx, 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, multiProfile), 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()) { unexpectedFailure(routingContext, asyncResult.cause()); } else { LOG.info("Authorised to view resource " + routingContext.request().path()); routingContext.next(); } }); }
Example #9
Source File: LogoutFilter.java From jee-pac4j with Apache License 2.0 | 5 votes |
@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 LogoutLogic<Object, JEEContext> bestLogic = FindBest.logoutLogic(logoutLogic, config, DefaultLogoutLogic.INSTANCE); final JEEContext context = new JEEContext(request, response, bestSessionStore); bestLogic.perform(context, config, bestAdapter, this.defaultUrl, this.logoutUrlPattern, this.localLogout, this.destroySession, this.centralLogout); }
Example #10
Source File: CallbackFilter.java From jee-pac4j with Apache License 2.0 | 5 votes |
@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); }
Example #11
Source File: Pac4jFactory.java From dropwizard-pac4j with Apache License 2.0 | 4 votes |
/** * @since 1.1.1 * @return an {@link HttpActionAdapter} */ @JsonProperty public HttpActionAdapter getHttpActionAdapter() { return httpActionAdapter; }
Example #12
Source File: Pac4jFactory.java From dropwizard-pac4j with Apache License 2.0 | 4 votes |
@JsonProperty public void setHttpActionAdapter(HttpActionAdapter httpActionAdapter) { this.httpActionAdapter = httpActionAdapter; }
Example #13
Source File: SecurityInterceptor.java From spring-webmvc-pac4j with Apache License 2.0 | 4 votes |
public SecurityInterceptor(final Config config, final String clients, final HttpActionAdapter httpActionAdapter) { this.clients = clients; this.config = config; this.httpActionAdapter = httpActionAdapter; }
Example #14
Source File: SecurityInterceptor.java From spring-webmvc-pac4j with Apache License 2.0 | 4 votes |
public HttpActionAdapter getHttpActionAdapter() { return httpActionAdapter; }
Example #15
Source File: SecurityInterceptor.java From spring-webmvc-pac4j with Apache License 2.0 | 4 votes |
public void setHttpActionAdapter(final HttpActionAdapter httpActionAdapter) { this.httpActionAdapter = httpActionAdapter; }