spring securty SimpleUrlAuthenticationFailureHandler

时间:2015-09-11 15:26:38

标签: spring spring-mvc spring-security

@Component
public class TrackerAuthFailureHandler extends SimpleUrlAuthenticationFailureHandler{
    @Override
    public void onAuthenticationFailure(HttpServletRequest request,
            HttpServletResponse response, AuthenticationException exception)
            throws IOException, ServletException {

        if(exception.getClass().isAssignableFrom(DisabledException.class)){
            super.setDefaultFailureUrl("/accountRecovery");
        }       
        super.onAuthenticationFailure(request, response, exception);
    }
}

SpringSecurity.java

@Autowired
    private TrackerAuthFailureHandler trackerAuthFailureHandler;

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .anyRequest().authenticated()
                .and()
            .formLogin()
                .loginPage("/login")
                .permitAll()
                .failureHandler(trackerAuthFailureHandler);

    }

我的代码有什么问题吗?身份验证失败后,Page不会重定向到" / accountRecovery"网址。

0 个答案:

没有答案
相关问题