Example usage for org.springframework.security.web.authentication AnonymousAuthenticationFilter AnonymousAuthenticationFilter

List of usage examples for org.springframework.security.web.authentication AnonymousAuthenticationFilter AnonymousAuthenticationFilter

Introduction

In this page you can find the example usage for org.springframework.security.web.authentication AnonymousAuthenticationFilter AnonymousAuthenticationFilter.

Prototype

public AnonymousAuthenticationFilter(String key) 

Source Link

Document

Creates a filter with a principal named "anonymousUser" and the single authority "ROLE_ANONYMOUS".

Usage

From source file:io.syndesis.runtime.SecurityConfiguration.java

@Override
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
protected void configure(HttpSecurity http) throws Exception {
    http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
            .addFilter(requestHeaderAuthenticationFilter())
            .addFilter(new AnonymousAuthenticationFilter("anonymous")).authorizeRequests()
            .antMatchers(HttpMethod.OPTIONS).permitAll().antMatchers("/api/v1/swagger.*").permitAll()
            .antMatchers("/api/v1/index.html").permitAll().antMatchers("/api/v1/version").permitAll()
            .antMatchers(HttpMethod.GET, "/api/v1/credentials/callback").permitAll().antMatchers("/api/v1/**")
            .hasRole("AUTHENTICATED").anyRequest().permitAll();

    http.csrf().disable();/* w ww  . j ava 2s. c  o m*/
}

From source file:br.com.hyperclass.snackbar.config.SecurityConfiguration.java

@Bean
public Filter anonymousFilter() {
    return new AnonymousAuthenticationFilter("anonymousUser");
}

From source file:org.springframework.security.config.http.DefaultFilterChainValidatorTests.java

@Before
public void setUp() throws Exception {
    AnonymousAuthenticationFilter aaf = new AnonymousAuthenticationFilter("anonymous");
    fsi = new FilterSecurityInterceptor();
    fsi.setAccessDecisionManager(accessDecisionManager);
    fsi.setSecurityMetadataSource(metadataSource);
    AuthenticationEntryPoint authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint("/login");
    ExceptionTranslationFilter etf = new ExceptionTranslationFilter(authenticationEntryPoint);
    DefaultSecurityFilterChain securityChain = new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, aaf,
            etf, fsi);//from  www .  j a v  a 2  s . co m
    fcp = new FilterChainProxy(securityChain);
    validator = new DefaultFilterChainValidator();

    ReflectionTestUtils.setField(validator, "logger", logger);
}