Spring Security(Third Edition)
上QQ阅读APP看书,第一时间看更新

The springSecurityFilterChain filter

The next step is to configure springSecurityFilterChain to intercept all requests by creating an implementation of AbstractSecurityWebApplicationInitializer. It is critical for springSecurityFilterChain to be declared first, to ensure the request is secured prior to any other logic being invoked. To ensure springSecurityFilterChain gets loaded first, we can use @Order(1) as shown in the following configuration:

    //src/main/java/c/p/s/web/configuration/SecurityWebAppInitializer

@Order(1)
public class SecurityWebAppInitializer extends
AbstractSecurityWebApplicationInitializer {
public SecurityWebAppInitializer() {
super();
}
}

The SecurityWebAppInitializer class will automatically register the springSecurityFilterChain filter for every URL in your application and will add ContextLoaderListener, which loads SecurityConfig.