aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-08-29 03:54:36 -0700
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-08-29 03:54:36 -0700
commit0627eb6d8ef545725c7828a0e11a85788495982a (patch)
tree96fa9ee8723710b594095e066f3669be758f7139 /src/main/java/org
parentb5dd22afb9e4e456d85a233d2cd6ed43f72441a9 (diff)
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) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java/org')
-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 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());