2011-02-16 56 views
0

在spring security 3.0.5.RELEASE中,我可以重寫哪個類和方法來捕獲BadCredentialsException的錯誤密碼。這是我的security.xmlspring security哪個類重寫以獲取錯誤密碼

<beans:bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"> 
    <beans:property name="hideUserNotFoundExceptions" value="true" /> 
    <beans:property name="userDetailsService" ref="userDao"/> 
    <beans:property name="passwordEncoder" ref="passwordEncoder"/> 
</beans:bean> 

<security:authentication-manager> 
    <security:authentication-provider ref='daoAuthenticationProvider'/> 
</security:authentication-manager> 

回答

0

子類SimpleUrlAuthenticationFailureHandler的片段和覆蓋onAuthenticationFailure()。它得到一個傳遞給它的異常。 exception.getAuthentication()。getCredentials()將返回嘗試過的密碼。

形式-login元素配置您AuthenticationFailureHandler:

<form-login authentication-failure-handler-ref="authenticationFailureHandler" /> 
相關問題