diff options
author | Christophe Closset <cc697w@intl.att.com> | 2017-08-29 14:02:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-08-29 14:02:09 +0000 |
commit | 78551555224bf3367c3635bf695978e903bcea14 (patch) | |
tree | c69a1356722d64b91a0264df28cc47deb6d29849 | |
parent | 2fdbae088810819b99769a2a91b94d760158fa03 (diff) | |
parent | 0627eb6d8ef545725c7828a0e11a85788495982a (diff) |
Merge "Rename the CldsSecurityConfig"
-rw-r--r-- | src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java (renamed from src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java) | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java index 7e6021c2..a187ac55 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java @@ -37,32 +37,50 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +/** + * This class is used to enable the HTTP authentication to login. It requires a + * specific JSON file containing the user definition + * (classpath:etc/config/clds/clds-users.json). + * + */ @Configuration @EnableWebSecurity @Profile("clamp-spring-authentication") -public class CldsSecurityConfig extends WebSecurityConfigurerAdapter { +public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSecurityConfig.class); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(CldsSecurityConfigUsers.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private ApplicationContext appContext; + private ApplicationContext appContext; @Value("${org.onap.clamp.config.files.cldsUsers:'classpath:etc/config/clds/clds-users.json'}") - private String cldsUsersFile; + private String cldsUsersFile; @Value("${CLDS_PERMISSION_TYPE_CL:permission-type-cl}") - private String cldsPersmissionTypeCl; + private String cldsPersmissionTypeCl; @Value("${CLDS_PERMISSION_INSTANCE:dev}") - private String cldsPermissionInstance; + private String cldsPermissionInstance; + /** + * This method configures on which URL the authorization will be enabled. + */ @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**") .authenticated().anyRequest().permitAll().and().logout(); } + /** + * This method is called by the framework and is used to load all the users + * defined in cldsUsersFile variable (this file path can be configured in + * the application.properties). + * + * @param auth + * @throws Exception + */ @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { CldsUser[] usersList = loadUsers(); @@ -79,6 +97,13 @@ public class CldsSecurityConfig extends WebSecurityConfigurerAdapter { } } + /** + * This method loads physically the JSON file and convert it to an Array of + * CldsUser. + * + * @return The array of CldsUser + * @throws Exception + */ private CldsUser[] loadUsers() throws Exception { logger.info("Load from clds-users.properties"); return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream()); |