Mar*_*ewd 10 spring spring-security
我正在设置一个不使用xml的新Web应用程序(没有web.xml,没有spring.xml).我几乎一切都工作,除了我无法弄清楚如何注册SaltSource.我需要用Java等效替换以下内容.
<authentication-manager>
<authentication-provider user-service-ref="authService" >
<password-encoder hash="sha" ref="myPasswordEncoder">
<salt-source user-property="salt"/>
</password-encoder>
</authentication-provider>
</authentication-manager>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我在Java中有这个.
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
ReflectionSaltSource rss = new ReflectionSaltSource();
rss.setUserPropertyToUse("salt");
auth.userDetailsService(authService).passwordEncoder(new MyPasswordEncoder());
// How do I set the saltSource down in DaoAuthenticationProvider
}
Run Code Online (Sandbox Code Playgroud)
那么如何注册SaltSource以便它最终出现在DaoAuthenticationProvider中(就像xml过去一样)?
Mar*_*ewd 13
我通过以下方式开展工作:
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
ReflectionSaltSource rss = new ReflectionSaltSource();
rss.setUserPropertyToUse("salt");
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setSaltSource(rss);
provider.setUserDetailsService(authService);
provider.setPasswordEncoder(new MyPasswordEncoder());
auth.authenticationProvider(provider);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3133 次 |
| 最近记录: |