1 package org.onap.appc.services.dmaapService;
3 import java.util.Properties;
5 import org.onap.appc.configuration.ConfigurationFactory;
6 import org.springframework.context.annotation.Bean;
7 import org.springframework.context.annotation.Configuration;
8 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
9 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
10 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
11 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
12 import org.springframework.security.crypto.password.PasswordEncoder;
15 public class AuthenticationConfig extends WebSecurityConfigurerAdapter {
17 private final String PROPERTIES_PREFIX = "appc.srvcomm.messaging";
18 private final String DEFAULT_USER = "appc";
19 private final String DEFAULT_PASSWORD = "onapappc";
22 protected void configure(HttpSecurity http) throws Exception {
23 http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic();
27 protected void configure(AuthenticationManagerBuilder auth) throws Exception {
28 org.onap.appc.configuration.Configuration configuration = ConfigurationFactory.getConfiguration();
29 Properties props = configuration.getProperties();
30 String user = props.getProperty(PROPERTIES_PREFIX + ".user");
31 String pass = props.getProperty(PROPERTIES_PREFIX + ".pass");
36 pass = DEFAULT_PASSWORD;
38 auth.inMemoryAuthentication().withUser(user).password(encoder().encode(pass)).roles("USER");
42 public PasswordEncoder encoder() {
43 return new BCryptPasswordEncoder();