[英]How to convert these spring security xml configuration to java configuration
I'm trying to convert spring security xml
configurations to java
configuration, does someone knows to convert these below tags: 我正在尝试将spring security xml
配置转换为java
配置,有人知道如何将以下标记转换为:
<authentication-manager alias="authenticationManager">
<authentication-provider ref="...." />
<authentication-provider ref="...." />
</authentication-manager>
this one 这个
<oauth:provider consumer-details-service-ref="oauthConsumerDetails" token-services-ref="tokenServices"
require10a="false" authenticate-token-url="/oauth_authenticate_token" />
this one 这个
<oauth:token-services id="tokenServices" />
and this one 还有这个
<global-method-security pre-post-annotations="enabled" secured-annotations="enabled"/>
I don't understand fully what you want, but here some code with Java configuration annotations that can help you: 我不完全了解您想要什么,但是这里有一些带有Java配置注释的代码可以帮助您:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserService userDetailsService;
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Autowired
public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider());
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(userDetailsService);
authenticationProvider.setPasswordEncoder(passwordEncoder());
return authenticationProvider;
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.