I am currently using UserDetailsServiceto get values from a user file:
<bean id="userDetailsService" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userProperties" value="users.properties"/>
</bean>
My properties file is intended for editing by the administrator, and user passwords are not encrypted:
bob=bobpassword
alice=alicepassword
Now, since I use PasswordEncoderin my application, I need to encrypt passwords and add them to UserDetails. This can be done somewhere in the code, but, in my opinion, it is not very convenient.
I found PropertyPlaceholderConfigurerusing a method convertPropertyValue(String value)that can be overridden.
From what I understand, it should be possible to load the properties file into PropertyPlaceholderConfigurer, where the properties can be encrypted in the method convertPropertyValueand then loaded using UserDetailsService. Can this be done? If so, the tips would help me, otherwise I would appreciate an alternative solution.
source
share