【发布时间】:2011-11-07 04:06:36
【问题描述】:
我目前正在使用UserDetailsService 从用户文件中获取值:
<bean id="userDetailsService" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userProperties" value="users.properties"/>
</bean>
我的属性文件应由管理员编辑,并且用户名密码未加密:
bob=bobpassword
alice=alicepassword
现在,由于我在我的应用程序中使用了PasswordEncoder,我需要加密密码并将它们添加到UserDetails。这可以在代码中的某个地方完成,但在我看来不是很方便。
我找到了 PropertyPlaceholderConfigurer 和 convertPropertyValue(String value) 方法,它可以被覆盖。
据我了解,应该可以将属性文件加载到PropertyPlaceholderConfigurer 中,其中属性可以在convertPropertyValue 方法中加密,然后由UserDetailsService 加载。那有可能吗?如果是,提示会帮助我,否则我会很高兴看到替代解决方案。
【问题讨论】:
标签: properties spring-security