summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-application/src
diff options
context:
space:
mode:
authorPopescu, Serban <serban.popescu@amdocs.com>2019-01-17 13:16:09 -0500
committerSerban Popescu <serban.popescu@amdocs.com>2019-01-17 13:19:38 -0500
commit9898634b32ce6bd4d468f399bcc4899054e5ace8 (patch)
tree70b855ef47a72ac8c8cc24a40a1d4463d5647298 /sparkybe-onap-application/src
parentacfc65b5eca0c6ad28faca4c8aa59d522eeb8de3 (diff)
Properties can start with ENV
If an application property value starts with ENV: that value should be inferred from the Java property with the same name after the prefix ENV: is removed Change-Id: I3f05972747e83010dfdaeb08bb65a472dcf1637e Issue-ID: AAI-2089 Signed-off-by: Serban Popescu <serban.popescu@amdocs.com>
Diffstat (limited to 'sparkybe-onap-application/src')
-rw-r--r--sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyPasswordConfiguration.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyPasswordConfiguration.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyPasswordConfiguration.java
index b554375..3424454 100644
--- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyPasswordConfiguration.java
+++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyPasswordConfiguration.java
@@ -3,6 +3,7 @@ package org.onap.aai.sparky.config;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.util.security.Password;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
@@ -12,9 +13,10 @@ import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;
public class PropertyPasswordConfiguration
- implements ApplicationContextInitializer<ConfigurableApplicationContext> {
+ implements ApplicationContextInitializer<ConfigurableApplicationContext> {
private static final String JETTY_OBFUSCATION_PATTERN = "OBF:";
+ private static final String ENV = "ENV:";
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
@@ -24,7 +26,7 @@ public class PropertyPasswordConfiguration
decodePasswords(propertySource, propertyOverrides);
if (!propertyOverrides.isEmpty()) {
PropertySource<?> decodedProperties =
- new MapPropertySource("decoded " + propertySource.getName(), propertyOverrides);
+ new MapPropertySource("decoded " + propertySource.getName(), propertyOverrides);
environment.getPropertySources().addBefore(propertySource.getName(), decodedProperties);
}
}
@@ -41,6 +43,9 @@ public class PropertyPasswordConfiguration
if (rawValueString.startsWith(JETTY_OBFUSCATION_PATTERN)) {
String decodedValue = Password.deobfuscate(rawValueString);
propertyOverrides.put(key, decodedValue);
+ } else if(rawValueString.startsWith(ENV)){
+ String decodedValue = System.getProperty(StringUtils.removeStart(rawValueString, ENV));
+ propertyOverrides.put(key, decodedValue);
}
}
}