I have a filter which extends AbstractAuthenticationProcessingFilter.
In security config class I have below,
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.addFilterBefore(getMyFilter(), BasicAuthenticationFilter.class);
http.addFilterAfter(getMyFilter2(), MyFilter.class);
http.csrf().disable().authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/**").permitAll();
}
private MyFilter getMyFilter() {
return new MyFilter(properties, apiConsumer);
}
When I invoke an REST endpoint with postman, the doFilter method of MyFilter get hits twice. In both time it has the same requestedSessionId and strippedServletPath in the ServletRequest.
But MyFilter2 which extend GenericFilterBean, only get invoke once.
The order of filter execution is MyFilter.doFilter -> MyFilter2.doFilter -> MyFilter.doFilter
What would be the reason and how can I find the root cause?