Spring 3 : Can't find AuthenticationProcessing

2019-04-28 18:48发布

问题:

I'm not able to find AuthenticationProcessingFilter when migrating from Spring 2 to Spring 3 (using spring-core)

回答1:

This class has been renamed to UsernamePasswordAuthenticationFilter in Spring security 3.x.

ref : http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/web/authentication/AuthenticationProcessingFilter.html



回答2:

If you're looking for constants which were available in spring 3 in AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY That is no longer available in that class.

Alternative is spring has added WebAttributes class org.springframework.security.web.WebAttributes in which you can get the same exception using the below code - session[WebAttributes.AUTHENTICATION_EXCEPTION]

In WebAttributes AUTHENTICATION_EXCEPTION is string defined as below WebAttributes.AUTHENTICATION_EXCEPTION = "SPRING_SECURITY_LAST_EXCEPTION_KEY"

Hopefully this helps.