Spring Security with Java Configuration: How to handle BadCredentialsException from a custom provider
I need to authenticate some rest services using a token id in the url (or maybe in the request header - but this is not important for now). I am trying to use java configuration to set this up using as a guide this post . My problem is that I do not know how to handle "BadCredentialsException" that is thrown when the authentication fails from the provider. Here is my Security Config: public static class SecurityConfigForRS extends WebSecurityConfigurerAdapter { @Autowired TokenAuthenticationProvider tokenAuthenticationProvider; @Override protected void configure(AuthenticationManagerBuilder