diff options
Diffstat (limited to 'src/main/java/org/onap/dcae/ApplicationSettings.java')
-rw-r--r-- | src/main/java/org/onap/dcae/ApplicationSettings.java | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/main/java/org/onap/dcae/ApplicationSettings.java b/src/main/java/org/onap/dcae/ApplicationSettings.java index 7d52c5e8..c4f2c063 100644 --- a/src/main/java/org/onap/dcae/ApplicationSettings.java +++ b/src/main/java/org/onap/dcae/ApplicationSettings.java @@ -43,6 +43,7 @@ import javax.annotation.Nullable; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.json.JSONObject; +import org.onap.dcae.common.configuration.AuthMethodType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,11 +70,21 @@ public class ApplicationSettings { Map<String, String> parsedArgs = argsParser.apply(args); configurationFileLocation = findOutConfigurationFileLocation(parsedArgs); loadPropertiesFromFile(); - parsedArgs.filterKeys(k -> !"c".equals(k)).forEach(this::updateProperty); + parsedArgs.filterKeys(k -> !"c".equals(k)).forEach(this::addOrUpdate); loadedJsonSchemas = loadJsonSchemas(); } - private void loadPropertiesFromFile() { + + public void reloadProperties() { + try { + properties.load(configurationFileLocation); + properties.refresh(); + } catch (ConfigurationException ex) { + log.error("Cannot load properties cause:", ex); + throw new ApplicationException(ex); + } + } + public void loadPropertiesFromFile() { try { properties.load(configurationFileLocation); } catch (ConfigurationException ex) { @@ -109,10 +120,6 @@ public class ApplicationSettings { return properties.getInt("collector.schema.checkflag", -1) > 0; } - public boolean authorizationEnabled() { - return properties.getInt("header.authflag", 0) > 0; - } - public JsonSchema jsonSchema(String version) { return loadedJsonSchemas.get(version) .orElse(loadedJsonSchemas.get(FALLBACK_VES_VERSION)) @@ -165,14 +172,6 @@ public class ApplicationSettings { return prependWithUserDirOnRelative(properties.getString("collector.keystore.file.location", "etc/keystore")); } - public boolean clientTlsAuthenticationEnabled() { - return httpsEnabled() && properties.getInt("collector.service.secure.clientauth", 0) > 0; - } - - public String keystoreAlias() { - return properties.getString("collector.keystore.alias", "tomcat"); - } - public String truststorePasswordFileLocation() { return prependWithUserDirOnRelative(properties.getString("collector.truststore.passwordfile", "etc/trustpasswordfile")); } @@ -189,6 +188,10 @@ public class ApplicationSettings { return prependWithUserDirOnRelative(properties.getString("collector.dmaapfile", "etc/DmaapConfig.json")); } + public String authMethod(){ + return properties.getString("auth.method", AuthMethodType.NO_AUTH.value()); + } + public Map<String, String[]> dMaaPStreamsMapping() { String streamIdsProperty = properties.getString("collector.dmaap.streamid", null); if (streamIdsProperty == null) { @@ -198,6 +201,14 @@ public class ApplicationSettings { } } + public void addOrUpdate(String key, String value) { + if (properties.containsKey(key)) { + properties.setProperty(key, value); + } else { + properties.addProperty(key, value); + } + } + private JSONObject jsonSchema() { return new JSONObject(properties.getString("collector.schema.file", format("{\"%s\":\"etc/CommonEventFormat_28.4.1.json\"}", FALLBACK_VES_VERSION))); @@ -214,14 +225,6 @@ public class ApplicationSettings { return HashMap.ofAll(domainToStreamIdsMapping); } - private void updateProperty(String key, String value) { - if (properties.containsKey(key)) { - properties.setProperty(key, value); - } else { - properties.addProperty(key, value); - } - } - private String prependWithUserDirOnRelative(String filePath) { if (!Paths.get(filePath).isAbsolute()) { filePath = Paths.get(appInvocationDir, filePath).toString(); |