org.springframework.session.web.http.HeaderHttpSessionStrategy Java Examples

The following examples show how to use org.springframework.session.web.http.HeaderHttpSessionStrategy. 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: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #2
Source File: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #3
Source File: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #4
Source File: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #5
Source File: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #6
Source File: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #7
Source File: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #8
Source File: HttpSessionConfig.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy(){
 HeaderHttpSessionStrategy headerSession = new HeaderHttpSessionStrategy();
 CookieHttpSessionStrategy cookieSession = new CookieHttpSessionStrategy();
 headerSession.setHeaderName("x-auth-token");
 return new SmartHttpSessionStrategy(cookieSession,headerSession);
}
 
Example #9
Source File: CustomizableHttpSessionStrategy.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	Assert.hasText(strategyHeaderName, "strategyHeaderName must has text!");
	this.headerStrategy = new HeaderHttpSessionStrategy();
	this.headerStrategy.setHeaderName(tokenHeaderName);
	this.cookieStrategy = new CookieHttpSessionStrategy();
	if (cookieSerializer!=null) {
		this.cookieStrategy.setCookieSerializer(cookieSerializer);
	}
}
 
Example #10
Source File: SmartHttpSessionStrategy.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
public SmartHttpSessionStrategy(CookieHttpSessionStrategy browser, HeaderHttpSessionStrategy api) {
    this.browser = browser;
    this.api = api;
}
 
Example #11
Source File: SmartHttpSessionStrategy.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
public SmartHttpSessionStrategy(CookieHttpSessionStrategy browser, HeaderHttpSessionStrategy api) {
    this.browser = browser;
    this.api = api;
}
 
Example #12
Source File: BasicAuthSecurityConfiguration.java    From spring-cloud-dashboard with Apache License 2.0 4 votes vote down vote up
@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 #13
Source File: HttpSessionConfig.java    From dpCms with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpSessionStrategy httpSessionStrategy() {
        return new HeaderHttpSessionStrategy(); 
}
 
Example #14
Source File: PolymerResourceSpringSecurityConfig.java    From spring-polymer-demo with Artistic License 2.0 4 votes vote down vote up
@Bean
HeaderHttpSessionStrategy sessionStrategy() {
  return new HeaderHttpSessionStrategy();
}