Java 类org.springframework.security.web.context.SecurityContextPersistenceFilter 实例源码

项目:autopivot    文件:SecurityConfig.java   
@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);
}
项目:autopivot    文件:SecurityConfig.java   
@Override
protected final void configure(final HttpSecurity http) throws Exception {
    Filter jwtFilter = context.getBean(IJwtConfig.class).jwtFilter();
    Filter corsFilter = context.getBean(ICorsFilterConfig.class).corsFilter();

    http
            // As of Spring Security 4.0, CSRF protection is enabled by default.
            .csrf().disable()
            // Configure CORS
            .addFilterBefore(corsFilter, SecurityContextPersistenceFilter.class)
            // To allow authentication with JWT (Required for ActiveUI)
            .addFilterAfter(jwtFilter, SecurityContextPersistenceFilter.class);

    if (logout) {
        // Configure logout URL
        http.logout()
                .permitAll()
                .deleteCookies(cookieName)
                .invalidateHttpSession(true)
                .logoutSuccessHandler(new NoRedirectLogoutSuccessHandler());
    }

    if (useAnonymous) {
        // Handle anonymous users. The granted authority ROLE_USER
        // will be assigned to the anonymous request
        http.anonymous().principal("guest").authorities(ROLE_USER);
    }

    doConfigure(http);
}
项目:autopivot    文件:SecurityConfig.java   
@Override
protected void configure(HttpSecurity http) throws Exception {
    Filter corsFilter = context.getBean(ICorsFilterConfig.class).corsFilter();

    http
            .antMatcher(VersionServicesConfig.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("/**").permitAll();
}
项目:coj-web    文件:SecurityConfiguration.java   
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;
   }
项目:lxcCMS    文件:DevWebSecurityConfig.java   
@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);
}
项目:herd    文件:AppSpringModuleConfig.java   
/**
 * 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;
        }
    });
}
项目:nextrtc-videochat-with-rest    文件:WebSecurityConfig.java   
@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);
}
项目:unidle-old    文件:DispatcherServletInitializer.java   
@Override
protected Filter[] getServletFilters() {
    return new Filter[]{
            new MDCInsertingServletFilter(),
            new HiddenHttpMethodFilter(),
            new OpenEntityManagerInViewFilter(),
            new RequestContextFilter(),
            new SecurityContextPersistenceFilter()
    };
}
项目:interview-preparation    文件:WebSecurityConfig.java   
public SecurityContextPersistenceFilter securityContextPersistenceFilterWithASCFalse() {
    // return new SecurityContextPersistenceFilter(new HttpSessionSecurityContextRepository());// this stores token in httpSession
    return new SecurityContextPersistenceFilter(statelessSecurityContextRepository());
}
项目:interview-preparation    文件:WebSecurityConfig.java   
public SecurityContextPersistenceFilter securityContextPersistenceFilterWithASCFalse() {
    logger.info("securityContextPersistenceFilterWithASCFalse");
    // return new SecurityContextPersistenceFilter(new HttpSessionSecurityContextRepository());// this stores token in httpSession
    return new SecurityContextPersistenceFilter(statelessSecurityContextRepository());
}
项目:motech    文件:SecurityRuleBuilder.java   
private void addSecurityContextPersistenceFilter(List<Filter> filters, SecurityContextRepository contextRepository) {
    SecurityContextPersistenceFilter securityContextFilter = new SecurityContextPersistenceFilter(contextRepository);
    filters.add(securityContextFilter);
}
项目:psi-probe    文件:ProbeSecurityConfig.java   
/**
 * Gets the security context persistence filter.
 *
 * @return the security context persistence filter
 */
@Bean(name = "sif")
public SecurityContextPersistenceFilter getSecurityContextPersistenceFilter() {
  return new SecurityContextPersistenceFilter();
}