org.pac4j.core.context.session.SessionStore Java Examples
The following examples show how to use
org.pac4j.core.context.session.SessionStore.
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: 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 #2
Source File: SecurityHandler.java From vertx-pac4j with Apache License 2.0 | 6 votes |
public SecurityHandler(final Vertx vertx, final SessionStore<VertxWebContext> sessionStore, final Config config, final Pac4jAuthProvider authProvider, final SecurityHandlerOptions options) { super(authProvider); CommonHelper.assertNotNull("vertx", vertx); CommonHelper.assertNotNull("sessionStore", sessionStore); CommonHelper.assertNotNull("config", config); CommonHelper.assertNotNull("config.getClients()", config.getClients()); CommonHelper.assertNotNull("authProvider", authProvider); CommonHelper.assertNotNull("options", options); clientNames = options.getClients(); authorizerName = options.getAuthorizers(); matcherName = options.getMatchers(); multiProfile = options.isMultiProfile(); this.vertx = vertx; this.sessionStore = sessionStore; this.config = config; }
Example #3
Source File: VertxSessionStore.java From vertx-pac4j with Apache License 2.0 | 6 votes |
@Override public Optional<SessionStore<VertxWebContext>> buildFromTrackableSession(final VertxWebContext context, final Object trackableSession) { if (trackableSession != null) { final CompletableFuture<io.vertx.ext.web.Session> vertxSessionFuture = new CompletableFuture<>(); sessionStore.get((String) trackableSession, asyncResult -> { if (asyncResult.succeeded()) { vertxSessionFuture.complete(asyncResult.result()); } else { vertxSessionFuture.completeExceptionally(asyncResult.cause()); } }); final CompletableFuture<VertxSessionStore> pac4jSessionFuture = vertxSessionFuture.thenApply(session -> { if (session != null) { return new VertxSessionStore(sessionStore, session); } else { return null; } }); try { return Optional.ofNullable(pac4jSessionFuture.get()); } catch (final InterruptedException|ExecutionException e) { throw new TechnicalException(e); } } return Optional.empty(); }
Example #4
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 #5
Source File: CallbackHandler.java From vertx-pac4j with Apache License 2.0 | 5 votes |
public CallbackHandler(final Vertx vertx, final SessionStore<VertxWebContext> sessionStore, final Config config, final CallbackHandlerOptions options) { this.vertx = vertx; this.sessionStore = sessionStore; this.config = config; this.defaultUrl = options.getDefaultUrl(); this.saveInSession = options.getSaveInSession(); this.multiProfile = options.getMultiProfile(); this.renewSession = options.getRenewSession(); this.defaultClient = options.getDefaultClient(); }
Example #6
Source File: LogoutHandler.java From vertx-pac4j with Apache License 2.0 | 5 votes |
/** * Construct based on the option values provided * * @param vertx the vertx API * @param sessionStore the session store * @param options - the options to configure this handler * @param config the pac4j configuration */ public LogoutHandler(final Vertx vertx, final SessionStore<VertxWebContext> sessionStore , final LogoutHandlerOptions options, final Config config) { this.defaultUrl = options.getDefaultUrl(); this.logoutUrlPattern = options.getLogoutUrlPattern(); this.config = config; this.vertx = vertx; this.sessionStore = sessionStore; this.localLogout = options.isLocalLogout(); this.destroySession = options.isDestroySession(); this.centralLogout = options.isCentralLogout(); }
Example #7
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 #8
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 #9
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 #10
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 #11
Source File: PippoWebContextTest.java From pippo with Apache License 2.0 | 5 votes |
@Test public void shouldReturnPippoSessionStoreWhenAccessed() { PippoWebContext context = makePippoWebContext(); SessionStore<PippoWebContext> sessionStore = context.getSessionStore(); assertThat(sessionStore, instanceOf(PippoSessionStore.class)); assertThat(sessionStore.getTrackableSession(context), is(mockSession)); }
Example #12
Source File: Pac4jProducer.java From jee-pac4j with Apache License 2.0 | 5 votes |
/** * Factory method which produces a pac4j web context. * * @param httpServletRequest the http servlet request to be used for building the web context * @param httpServletResponse the http servlet response to be used for building the web context * @return a web context associated with the current servlet request */ @Produces JEEContext getWebContext(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) { logger.trace("Producing a pac4j web context..."); final SessionStore<JEEContext> bestSessionStore = FindBest.sessionStore(null, Config.INSTANCE, JEESessionStore.INSTANCE); JEEContext jEEContext = new JEEContext( httpServletRequest, httpServletResponse, bestSessionStore ); logger.trace("Returning a pac4j web context."); return jEEContext; }
Example #13
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 #14
Source File: PippoWebContext.java From pippo with Apache License 2.0 | 4 votes |
@Override public void setSessionStore(SessionStore sessionStore) { throw new UnsupportedOperationException(); }
Example #15
Source File: PippoWebContext.java From pippo with Apache License 2.0 | 4 votes |
@Override public SessionStore<PippoWebContext> getSessionStore() { return sessionStore; }
Example #16
Source File: PippoWebContext.java From pippo with Apache License 2.0 | 4 votes |
public PippoWebContext(RouteContext routeContext, SessionStore<PippoWebContext> sessionStore) { this.routeContext = routeContext; this.sessionStore = (sessionStore != null) ? sessionStore : new PippoSessionStore(); }
Example #17
Source File: PippoSessionStore.java From pippo with Apache License 2.0 | 4 votes |
@Override public SessionStore<PippoWebContext> buildFromTrackableSession(PippoWebContext pippoWebContext, Object trackableSession) { return (trackableSession != null) ? new ProvidedPippoSessionStore((Session) trackableSession) : null; }
Example #18
Source File: CallbackDeployingPac4jAuthHandler.java From vertx-pac4j with Apache License 2.0 | 4 votes |
private Handler<RoutingContext> authResultHandler(final Vertx vertx, final SessionStore<VertxWebContext> sessionStore, final Config config, final CallbackHandlerOptions callbackOptions) { return new CallbackHandler(vertx, sessionStore, config, callbackOptions); }
Example #19
Source File: KnoxSessionStore.java From knox with Apache License 2.0 | 4 votes |
@Override public SessionStore buildFromTrackableSession(WebContext arg0, Object arg1) { return null; }
Example #20
Source File: VertxWebContext.java From vertx-pac4j with Apache License 2.0 | 4 votes |
@Override public SessionStore getSessionStore() { return this.sessionStore; }
Example #21
Source File: VertxSessionStore.java From vertx-pac4j with Apache License 2.0 | 4 votes |
public VertxSessionStore(final io.vertx.ext.web.sstore.SessionStore sessionStore, final Session providedSession) { this.sessionStore = sessionStore; this.providedSession = providedSession; }
Example #22
Source File: VertxSessionStore.java From vertx-pac4j with Apache License 2.0 | 4 votes |
public VertxSessionStore(final io.vertx.ext.web.sstore.SessionStore sessionStore) { this(sessionStore, null); }
Example #23
Source File: ComponentConfig.java From spring-webmvc-pac4j with Apache License 2.0 | 4 votes |
protected SessionStore<JEEContext> getSessionStore() { return FindBest.sessionStore(sessionStore, config, JEESessionStore.INSTANCE); }
Example #24
Source File: JaxRsContext.java From jax-rs-pac4j with Apache License 2.0 | 4 votes |
@Override public SessionStore getSessionStore() { return sessionStore; }
Example #25
Source File: JaxRsContext.java From jax-rs-pac4j with Apache License 2.0 | 4 votes |
public JaxRsContext(Providers providers, ContainerRequestContext requestContext, SessionStore sessionStore) { this.providers = providers; this.requestContext = requestContext; this.sessionStore = sessionStore; }
Example #26
Source File: ServletJaxRsContext.java From jax-rs-pac4j with Apache License 2.0 | 4 votes |
public ServletJaxRsContext(Providers providers, ContainerRequestContext requestContext, SessionStore sessionStore, HttpServletRequest request) { super(providers, requestContext, sessionStore != null ? sessionStore : new ServletSessionStore()); CommonHelper.assertNotNull("request", request); this.request = request; }
Example #27
Source File: GrizzlyJaxRsContext.java From jax-rs-pac4j with Apache License 2.0 | 4 votes |
public GrizzlyJaxRsContext(Providers providers, ContainerRequestContext requestContext, SessionStore sessionStore, Request request) { super(providers, requestContext, sessionStore != null ? sessionStore : new GrizzlySessionStore()); this.request = request; }
Example #28
Source File: GrizzlyJaxRsContext.java From jax-rs-pac4j with Apache License 2.0 | 4 votes |
public GrizzlyJaxRsContext(Providers providers, ContainerRequestContext requestContext, SessionStore sessionStore, Request request) { super(providers, requestContext, sessionStore != null ? sessionStore : new GrizzlySessionStore()); this.request = request; }
Example #29
Source File: GrizzlyJaxRsContext.java From jax-rs-pac4j with Apache License 2.0 | 4 votes |
public GrizzlyJaxRsContext(Providers providers, ContainerRequestContext requestContext, SessionStore sessionStore, Request request) { super(providers, requestContext, sessionStore != null ? sessionStore : new GrizzlySessionStore()); this.request = request; }