本文整理汇总了Java中org.springframework.security.web.context.SecurityContextPersistenceFilter类的典型用法代码示例。如果您正苦于以下问题:Java SecurityContextPersistenceFilter类的具体用法?Java SecurityContextPersistenceFilter怎么用?Java SecurityContextPersistenceFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SecurityContextPersistenceFilter类属于org.springframework.security.web.context包,在下文中一共展示了SecurityContextPersistenceFilter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
final Filter corsFilter = context.getBean(ICorsFilterConfig.class).corsFilter();
final AuthenticationEntryPoint basicAuthenticationEntryPoint = context.getBean(
BASIC_AUTH_BEAN_NAME,
AuthenticationEntryPoint.class);
http
.antMatcher(JwtRestServiceConfig.REST_API_URL_PREFIX + "/**")
// As of Spring Security 4.0, CSRF protection is enabled by default.
.csrf().disable()
// Configure CORS
.addFilterBefore(corsFilter, SecurityContextPersistenceFilter.class)
.authorizeRequests()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.antMatchers("/**").hasAnyAuthority(ROLE_USER)
.and()
.httpBasic().authenticationEntryPoint(basicAuthenticationEntryPoint);
}
示例2: filterChain
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
private List<SecurityFilterChain> filterChain() {
List<SecurityFilterChain> filters = new ArrayList<SecurityFilterChain>(12);
RequestMatcher req = new AntPathRequestMatcher("/**");
filters.add(new DefaultSecurityFilterChain(req, new SecurityContextPersistenceFilter(),
logoutFilter(),cojAuthenticationProcessingFilter(),new SecurityContextHolderAwareRequestFilter(),
rememberMeAuthenticationFilter(),anonymousAuthenticationFilter(),exceptionTranslationFilter(),filterInvocationInterceptor()
));
return filters;
}
示例3: configure
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll().and().formLogin().loginPage("/signin").defaultSuccessUrl("/blog").and().logout().logoutUrl("/logout").logoutSuccessUrl("/blog").and().rememberMe().rememberMeParameter("remember-me").and().csrf().disable();
User admin = userRepository.findByUsername("admin");
if (admin == null)
admin = new User("admin", "123456");
admin.setAdmin(true);
admin.setPassword("123456");
userRepository.save(admin);
http.addFilterAfter(new DevSigninFilter(userRepository), SecurityContextPersistenceFilter.class);
}
示例4: filterChainProxy
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
/**
* Gets a filter chain proxy.
*
* @param trustedUserAuthenticationFilter the trusted user authentication filter.
* @param httpHeaderAuthenticationFilter the HTTP header authentication filter.
*
* @return the filter chain proxy.
*/
@Bean
public FilterChainProxy filterChainProxy(final TrustedUserAuthenticationFilter trustedUserAuthenticationFilter,
final HttpHeaderAuthenticationFilter httpHeaderAuthenticationFilter)
{
return new FilterChainProxy(new SecurityFilterChain()
{
@Override
public boolean matches(HttpServletRequest request)
{
// Match all URLs.
return true;
}
@Override
public List<Filter> getFilters()
{
List<Filter> filters = new ArrayList<>();
// Required filter to store session information between HTTP requests.
filters.add(new SecurityContextPersistenceFilter());
// Trusted user filter to bypass security based on SpEL expression environment property.
filters.add(trustedUserAuthenticationFilter);
// Filter that authenticates based on http headers.
if (Boolean.valueOf(configurationHelper.getProperty(ConfigurationValue.SECURITY_HTTP_HEADER_ENABLED)))
{
filters.add(httpHeaderAuthenticationFilter);
}
// Anonymous user filter.
filters.add(new AnonymousAuthenticationFilter("AnonymousFilterKey"));
return filters;
}
});
}
示例5: configure
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/",
"/login",
"/login**",
"/register.html",
"/action/register",
"/action/verify/*",
"/js/**")
.permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login.html")
.loginProcessingUrl("/login")
.usernameParameter("username")
.passwordParameter("password")
.defaultSuccessUrl("/conversation.html")
.failureUrl("/login.html?error=true")
.permitAll()
.and()
.logout()
.logoutUrl("/logout.html")
.logoutSuccessUrl("/login.html")
.permitAll()
.and()
.addFilterBefore(ssoFilters(), BasicAuthenticationFilter.class)
.addFilterAfter(oAuth2ClientContextFilter, SecurityContextPersistenceFilter.class);
}
示例6: getServletFilters
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
@Override
protected Filter[] getServletFilters() {
return new Filter[]{
new MDCInsertingServletFilter(),
new HiddenHttpMethodFilter(),
new OpenEntityManagerInViewFilter(),
new RequestContextFilter(),
new SecurityContextPersistenceFilter()
};
}
示例7: securityContextPersistenceFilterWithASCFalse
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
public SecurityContextPersistenceFilter securityContextPersistenceFilterWithASCFalse() {
// return new SecurityContextPersistenceFilter(new HttpSessionSecurityContextRepository());// this stores token in httpSession
return new SecurityContextPersistenceFilter(statelessSecurityContextRepository());
}
示例8: securityContextPersistenceFilterWithASCFalse
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
public SecurityContextPersistenceFilter securityContextPersistenceFilterWithASCFalse() {
logger.info("securityContextPersistenceFilterWithASCFalse");
// return new SecurityContextPersistenceFilter(new HttpSessionSecurityContextRepository());// this stores token in httpSession
return new SecurityContextPersistenceFilter(statelessSecurityContextRepository());
}
示例9: addSecurityContextPersistenceFilter
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
private void addSecurityContextPersistenceFilter(List<Filter> filters, SecurityContextRepository contextRepository) {
SecurityContextPersistenceFilter securityContextFilter = new SecurityContextPersistenceFilter(contextRepository);
filters.add(securityContextFilter);
}
示例10: getSecurityContextPersistenceFilter
import org.springframework.security.web.context.SecurityContextPersistenceFilter; //导入依赖的package包/类
/**
* Gets the security context persistence filter.
*
* @return the security context persistence filter
*/
@Bean(name = "sif")
public SecurityContextPersistenceFilter getSecurityContextPersistenceFilter() {
return new SecurityContextPersistenceFilter();
}