I would like to add salt as:
PasswordEncoder encoder = new ShaPasswordEncoder(); userDetails.setPassword(encoder.encodePassword(userDetails.getPassword(),saltSource.getSalt(userDetails));
how far userDetails is an instance of my user class UserDetail , I must pass it to this spring: UserDetails class, but since it was logically expected, I got it in Runtime:
java.lang.ClassCastException: model.UserDetails cannot be cast to org.springframework.security.core.userdetails.UserDetails
configurations:
<beans:bean id="saultSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource"> <beans:property name="userPropertyToUse" value="username"/> </beans:bean> <authentication-manager alias="authenticationManager"> <authentication-provider> <password-encoder hash="sha"> <salt-source user-property="username"/> </password-encoder> <jdbc-user-service data-source-ref="dataSource"/> </authentication-provider> </authentication-manager>
How can I adjust the salt correctly in this case?
source share