HI.
Please help anyone who has encountered this problem.
I want to run an example Custom Project Setup. In class CustomUserDetailsAuthenticationProvider in line 3:
public class CustomUserDetailsAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
...
1 @Override
2 protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication)
throws AuthenticationException {
3 CustomAuthenticationToken auth = (CustomAuthenticationToken) authentication;
I get an error:
java.lang.ClassCastException: org.springframework.security.authentication.UsernamePasswordAuthenticationToken cannot be cast to secyriry.authentication.loginpassworld.CustomAuthenticationToken
Сhecking gives false
if(auth instanceof UsernamePasswordAuthenticationToken){ //auth=null
auth= (CustomAuthenticationToken) authentication;
}
I understand the error but I can't understand it
- Why this solution was applied
- How to fix the situation
I translated everything using GOOGLE