Мне нужно добавить пользовательский параметр в объект аутентификации. Поэтому я создаю оболочку для объекта аутентификации, которая содержит пользовательский параметр. Затем создайте этот объект в CustomAuthenticationProcessingFilter
.
public class CustomAuthenticationProcessingFilter extends UsernamePasswordAuthnticationFilter {
public Authentication attemptAuthentication(...){
Authentication auth = super.attemptAuthentication(...);
CustomAuthentication custAuth = new CustomAuthentication(auth);
custAuth.setCustomParameter("");
return custAuth;
}
}
Затем в CustomAuthenticationProvider
я получаю объект аутентификации и хочу привести его к CustomAuthentication
. Это бросает ClassCastException
. Разве объект не передан CustomAuthenticationProvider
тем же, что я создал в CustomAuthenticationProcessingFilter
?
Вот мой Spring Security Config -
<sec:http entry-point-ref="entryPoint" auto-config="false"> ... <sec:custom-filter ref="customAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER"/> </sec:http>