我正在尝试将spring security xml
的配置转换为java
的配置,有人知道如何将以下这些标记转换:
<authentication-manager alias="authenticationManager">
<authentication-provider ref="...." />
<authentication-provider ref="...." />
</authentication-manager>
这个
<oauth:provider consumer-details-service-ref="oauthConsumerDetails" token-services-ref="tokenServices"
require10a="false" authenticate-token-url="/oauth_authenticate_token" />
这个
<oauth:token-services id="tokenServices" />
还有这个
<global-method-security pre-post-annotations="enabled" secured-annotations="enabled"/>
答案 0 :(得分:1)
我不完全了解您想要什么,但是这里有一些带有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;
}
}