Spring用户身份验证未调用失败

时间:2013-12-02 09:55:51

标签: java spring authentication spring-security

我遇到了Spring用户身份验证失败的问题。这是我的UserAuthenticationFailureHandler类:

public class UserAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler{


@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException{
    ...
    System.out.println("\n test \n");
}

这是spring-security.xml文件:

<form-login authentication-success-handler-ref="userAuthenticationSuccessHandler" 
                authentication-failure-handler-ref="userAuthenticationFailureHandler"/>

    ...

<beans:bean id="userAuthenticationSuccessHandler" 
    class="path.UserAuthenticationSuccessHandler"/>

<beans:bean id="userAuthenticationFailureHandler"
    class="path.UserAuthenticationFailureHandler/>

因此AuthenticationSuccessHandler工作正常,并在成功身份验证时调用。但是FailureHandler不会被调用。

但SuccessHandler看起来就像FailureHandler:

public class UserAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
...

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, 
  Authentication authentication) throws ServletException, IOException {
  ...
    System.out.println("\ntest\n");
}

... }

我不确定我做错了什么。谁能给我一些提示? 谢谢!

0 个答案:

没有答案