org.springframework.session.web.http.SessionRepositoryFilter Java Examples
The following examples show how to use
org.springframework.session.web.http.SessionRepositoryFilter.
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: SpringHttpSessionConfigurationTests.java From spring-session with Apache License 2.0 | 6 votes |
@Test void sessionCookieConfigConfiguration() { registerAndRefresh(SessionCookieConfigConfiguration.class); SessionRepositoryFilter sessionRepositoryFilter = this.context.getBean(SessionRepositoryFilter.class); assertThat(sessionRepositoryFilter).isNotNull(); CookieHttpSessionIdResolver httpSessionIdResolver = (CookieHttpSessionIdResolver) ReflectionTestUtils .getField(sessionRepositoryFilter, "httpSessionIdResolver"); assertThat(httpSessionIdResolver).isNotNull(); DefaultCookieSerializer cookieSerializer = (DefaultCookieSerializer) ReflectionTestUtils .getField(httpSessionIdResolver, "cookieSerializer"); assertThat(cookieSerializer).isNotNull(); assertThat(ReflectionTestUtils.getField(cookieSerializer, "cookieName")).isEqualTo("test-name"); assertThat(ReflectionTestUtils.getField(cookieSerializer, "cookiePath")).isEqualTo("test-path"); assertThat(ReflectionTestUtils.getField(cookieSerializer, "cookieMaxAge")).isEqualTo(600); assertThat(ReflectionTestUtils.getField(cookieSerializer, "domainName")).isEqualTo("test-domain"); }
Example #2
Source File: ChoerodonRedisHttpSessionConfiguration.java From oauth-server with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean requestContextFilterChainRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(requestContextFilter()); registration.setOrder(SessionRepositoryFilter.DEFAULT_ORDER + 1); registration.setName("requestContextFilter"); return registration; }
Example #3
Source File: SpringSessionFixAutoConfiguration.java From joinfaces with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnBean(SessionRepositoryFilter.class) public FilterRegistrationBean<SpringSessionFixFilter> springSessionFixFilterRegistrationBean( SessionProperties sessionProperties ) { FilterRegistrationBean<SpringSessionFixFilter> registrationBean = new FilterRegistrationBean<>(new SpringSessionFixFilter()); registrationBean.setOrder(sessionProperties.getServlet().getFilterOrder() + 1); registrationBean.setDispatcherTypes(getDispatcherTypes(sessionProperties)); return registrationBean; }
Example #4
Source File: ApplicationConfig.java From docker-kubernetes-by-example-java with Apache License 2.0 | 5 votes |
@Bean @Order(value = 0) FilterRegistrationBean sessionRepositoryFilterRegistration( SessionRepositoryFilter filter) { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean( new DelegatingFilterProxy(filter)); filterRegistrationBean.setUrlPatterns(Arrays.asList("/*")); return filterRegistrationBean; }
Example #5
Source File: IndexDocTests.java From spring-session with Apache License 2.0 | 5 votes |
@Test void runSpringHttpSessionConfig() { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.register(SpringHttpSessionConfig.class); context.setServletContext(new MockServletContext()); context.refresh(); try { context.getBean(SessionRepositoryFilter.class); } finally { context.close(); } }
Example #6
Source File: Initializer.java From spring-session with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { this.instance = createHazelcastInstance(); Map<String, Session> sessions = this.instance.getMap(SESSION_MAP_NAME); MapSessionRepository sessionRepository = new MapSessionRepository(sessions); SessionRepositoryFilter<? extends Session> filter = new SessionRepositoryFilter<>(sessionRepository); Dynamic fr = sce.getServletContext().addFilter("springSessionFilter", filter); fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); }
Example #7
Source File: SpringHttpSessionConfiguration.java From spring-session with Apache License 2.0 | 5 votes |
@Bean public <S extends Session> SessionRepositoryFilter<? extends Session> springSessionRepositoryFilter( SessionRepository<S> sessionRepository) { SessionRepositoryFilter<S> sessionRepositoryFilter = new SessionRepositoryFilter<>(sessionRepository); sessionRepositoryFilter.setHttpSessionIdResolver(this.httpSessionIdResolver); return sessionRepositoryFilter; }
Example #8
Source File: SpringHttpSessionConfigurationTests.java From spring-session with Apache License 2.0 | 5 votes |
@Test void defaultConfiguration() { registerAndRefresh(DefaultConfiguration.class); assertThat(this.context.getBean(SessionEventHttpSessionListenerAdapter.class)).isNotNull(); assertThat(this.context.getBean(SessionRepositoryFilter.class)).isNotNull(); assertThat(this.context.getBean(SessionRepository.class)).isNotNull(); }
Example #9
Source File: SpringHttpSessionConfigurationTests.java From spring-session with Apache License 2.0 | 5 votes |
@Test void rememberMeServicesConfiguration() { registerAndRefresh(RememberMeServicesConfiguration.class); SessionRepositoryFilter sessionRepositoryFilter = this.context.getBean(SessionRepositoryFilter.class); assertThat(sessionRepositoryFilter).isNotNull(); CookieHttpSessionIdResolver httpSessionIdResolver = (CookieHttpSessionIdResolver) ReflectionTestUtils .getField(sessionRepositoryFilter, "httpSessionIdResolver"); assertThat(httpSessionIdResolver).isNotNull(); DefaultCookieSerializer cookieSerializer = (DefaultCookieSerializer) ReflectionTestUtils .getField(httpSessionIdResolver, "cookieSerializer"); assertThat(cookieSerializer).isNotNull(); assertThat(ReflectionTestUtils.getField(cookieSerializer, "rememberMeRequestAttribute")) .isEqualTo(SpringSessionRememberMeServices.REMEMBER_ME_LOGIN_ATTR); }
Example #10
Source File: BasicAuthSecurityConfiguration.java From spring-cloud-dashboard with Apache License 2.0 | 4 votes |
@Override protected void configure(HttpSecurity http) throws Exception { final RequestMatcher textHtmlMatcher = new MediaTypeRequestMatcher( contentNegotiationStrategy, MediaType.TEXT_HTML); final String loginPage = dashboard("/#/login"); final BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint(); basicAuthenticationEntryPoint.setRealmName(securityProperties.getBasic().getRealm()); basicAuthenticationEntryPoint.afterPropertiesSet(); http .csrf() .disable() .authorizeRequests() .antMatchers("/") .authenticated() .antMatchers( dashboard("/**"), "/authenticate", "/security/info", "/features", "/assets/**").permitAll() .and() .formLogin().loginPage(loginPage) .loginProcessingUrl(dashboard("/login")) .defaultSuccessUrl(dashboard("/")).permitAll() .and() .logout().logoutUrl(dashboard("/logout")) .logoutSuccessUrl(dashboard("/logout-success.html")) .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()).permitAll() .and().httpBasic() .and().exceptionHandling() .defaultAuthenticationEntryPointFor( new LoginUrlAuthenticationEntryPoint(loginPage), textHtmlMatcher) .defaultAuthenticationEntryPointFor(basicAuthenticationEntryPoint, AnyRequestMatcher.INSTANCE) .and() .authorizeRequests() .anyRequest().authenticated(); final SessionRepositoryFilter<ExpiringSession> sessionRepositoryFilter = new SessionRepositoryFilter<ExpiringSession>( sessionRepository()); sessionRepositoryFilter .setHttpSessionStrategy(new HeaderHttpSessionStrategy()); http.addFilterBefore(sessionRepositoryFilter, ChannelProcessingFilter.class).csrf().disable(); http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED); }
Example #11
Source File: SpringSessionFixAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 4 votes |
@Bean public SessionRepositoryFilter<?> sessionRepositoryFilter() { return mock(SessionRepositoryFilter.class); }
Example #12
Source File: MockServerConfig.java From bearchoke with Apache License 2.0 | 4 votes |
@Bean(name = "springSessionRepositoryFilter") public SessionRepositoryFilter sessionRepositoryFilter() { return new SessionRepositoryFilter(new MapSessionRepository()); }