Spring security spring安全性不同的登录消息

Spring security spring安全性不同的登录消息,spring-security,Spring Security,我正在尝试显示不同的登录错误消息,如“登录失败”或“内部系统错误”。或者甚至可以重定向到其他页面。除了没有表单登录标记之外,我尝试按照这里所做的操作进行操作,因此无法将身份验证失败处理程序ref设置为页面上显示的值。但是,我确实在FORM_LOGIN_FILTER上设置了authenticationFailureHandler(使用ExceptionMapingAuthenticationFailureHandler),FORM_LOGIN_FILTER是一个自定义类,它只是扩展了Usernam

我正在尝试显示不同的登录错误消息,如“登录失败”或“内部系统错误”。或者甚至可以重定向到其他页面。除了没有表单登录标记之外,我尝试按照这里所做的操作进行操作,因此无法将身份验证失败处理程序ref设置为页面上显示的值。但是,我确实在FORM_LOGIN_FILTER上设置了authenticationFailureHandler(使用ExceptionMapingAuthenticationFailureHandler),FORM_LOGIN_FILTER是一个自定义类,它只是扩展了UsernamePasswordAuthenticationFilter

我错过了什么

EDIT-09/19/2013:我做了一点调试,但我问错了问题。看来它工作得很好。但是,我有多个身份验证提供程序,第一个提供程序的异常会被第二个提供程序的异常覆盖。基本上,我试图模拟DB down异常,这是抛出的,但随后尝试对Active Directory进行身份验证,这是启动的,我只是得到user not found exc。因此,我没有得到我的AuthenticationServiceException

我想我在这一点上的问题是,如何在不改变提供者顺序的情况下使第一个例外保持不变(DB提供者用于大多数用户)


/login.jsp?errorCode=666

如果上述配置的身份验证失败,会发生什么情况?请参阅我从2013年9月19日开始的编辑。我的配置很好。我没有得到预期的异常的原因是因为我有多个身份验证提供程序。如何使第一个提供程序的异常保持不变,而不改变提供程序的顺序?似乎有一种方法可以通过抛出AccountStatusException来打破身份验证提供程序循环。这正是我想要的。
<http pattern="/**"  authentication-manager-ref='testAuthenticationManager' entry-point-ref="loginUrlAuthenticationEntryPoint" >
    <intercept-url pattern="/**" access="ROLE_USER" />
    <custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" />
    <custom-filter position="FORM_LOGIN_FILTER" ref="customFormLoginFilter" />
     <session-management session-authentication-strategy-ref="sas"/>
 </http>

<!-- This just extends UsernamePasswordAuthenticationFilter -->
<beans:bean id="customFormLoginFilter" class="com.acme.security.CustomAuthenticationFilter" >
    <beans:property name="sessionAuthenticationStrategy" ref="sas" />
    <beans:property name="filterProcessesUrl" value="/j_spring_security_check" />
    <beans:property name="authenticationManager" ref="testAuthenticationManager"/>    
    <beans:property name="authenticationSuccessHandler" ref="successHandler"/>        
    <beans:property name="authenticationFailureHandler" ref="failureHandler" />        
</beans:bean>

<beans:bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter">
    <beans:property name="sessionRegistry" ref="sessionRegistry" />
    <beans:property name="expiredUrl" value="/login.jsp?errorCode=maxSessionsExceeded" />
</beans:bean>

<beans:bean id="sas" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
    <beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" />
    <beans:property name="maximumSessions" value="1" />
</beans:bean>

<beans:bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" />

<beans:bean id="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
     <beans:property name="loginFormUrl" value="/login.jsp"/>
</beans:bean>

<beans:bean id="successHandler"
            class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
    <beans:property name="defaultTargetUrl" value="/login/setup.htm"/>
    <beans:property  name="alwaysUseDefaultTargetUrl" value="true"/>        
</beans:bean>

<beans:bean id="failureHandler"
    class="org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler">
    <beans:property name="defaultFailureUrl" value="/login.jsp" />
    <beans:property name="exceptionMappings">
        <beans:props>
            <beans:prop key="org.springframework.security.authentication.AuthenticationServiceException">/login.jsp?errorCode=666</beans:prop>
        </beans:props>
    </beans:property>
</beans:bean>