From: Determe, Sebastien (sd378r) Date: Tue, 29 Aug 2017 10:54:36 +0000 (-0700) Subject: Rename the CldsSecurityConfig X-Git-Tag: 6.0.0~11^2~1051^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=0627eb6d8ef545725c7828a0e11a85788495982a;p=policy%2Fclamp.git Rename the CldsSecurityConfig This was unclear that this class was related to the Clds Users, so it has to be renamed Change-Id: Ia93bc24d4940a017274e55d06075f60954c75cc3 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java similarity index 76% rename from src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java rename to src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java index 7e6021c2b..a187ac556 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());