Reputation: 625
I'm trying to convert spring security xml
configurations to java
configuration, does someone knows to convert these below tags:
<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"/>
Upvotes: 0
Views: 244
Reputation: 40
I don't understand fully what you want, but here some code with Java configuration annotations that can help you:
@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;
}
}
Upvotes: 1