如何将下面的xml配置(spring security)迁移到java配置。
<!-- Configure Authentication mechanism -->
<authentication-manager alias="authenticationManager">
<!-- SHA-256 values can be produced using 'echo n your_desired_password | sha256sum' (using normal *nix environments) -->
<authentication-provider user-service-ref="securityUserService" >
<password-encoder hash="sha-256"/>
</authentication-provider>
</authentication-manager>
感谢您的帮助。
答案 0 :(得分:0)
您应该使用registerAuthentication()方法,例如:
@Override
protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userDetailsServiceImpl)
.passwordEncoder(passwordEncoder());
}
@Bean public ShaPasswordEncoder passwordEncoder() throws Exception {
return new ShaPasswordEncoder(256);
}
来源:http://automateddeveloper.blogspot.co.uk/2014/02/spring-4-xml-to-annotation-configuration.html