The method and() is undefined for the type HttpSecurity

8.6k views Asked by At

Im trying to follow this example that is basically a bit of code to actually invalidate de login on angular.js.

I get "The method and() is undefined for the type HttpSecurity"

This is my part of my Code (line 89):

@EnableWebMvcSecurity
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.httpBasic()

        .and().authorizeRequests()
            .antMatchers("/login", "/error" , "/error.html")
            .permitAll()
            .anyRequest()
            .fullyAuthenticated()
            /*.permitAll().anyRequest().authenticated()*/

        .and()
            .logout()
            .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
            .logoutSuccessUrl("/")
            .permitAll()

        .and()
            .csrf().csrfTokenRepository(csrfTokenRepository())

        .and()
            .addFilterAfter(csrfHeaderFilter(), CsrfFilter.class)

        .and() /* HERE IS WHERE I GET THE WARNING */
            .sessionManagement()
            .maximumSessions(1)
            .expiredUrl("/expired")
            .maxSessionsPreventsLogin(true)
            .sessionRegistry(sessionRegistry());


    }

    ...more code here

    }
1

There are 1 answers

2
ci_ On BEST ANSWER

addFilterAfter() already returns an instance of HttpSecurity so you can just call sessionManagement() on it without calling and() first.