diff options
author | Dominik Mizyn <d.mizyn@samsung.com> | 2020-02-17 15:23:43 +0100 |
---|---|---|
committer | Dominik Mizyn <d.mizyn@samsung.com> | 2020-02-17 15:49:13 +0100 |
commit | b0e652a3c051310f247aef2e5569f829541f549b (patch) | |
tree | 8c77329894665a2c86aa0bc74047644a9485bd38 /policy-endpoints/src/main/java/org/onap | |
parent | d5229beabe407eeef2cd56c57a525f5e36245bf0 (diff) |
Allow storing REST servers password and userName in environment variables
This patch allows to store and get REST servers password and userName from
environment variables. This is needed if we want to send those
variables by helm secrets.
Issue-ID: OOM-2287
Change-Id: I4d6a8bf188a0d17e5444137d871dd341627ec397
Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap')
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java index 43e39d33..72747350 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java @@ -91,9 +91,9 @@ public class RestServer extends ServiceManagerContainer { props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "false"); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SWAGGER_SUFFIX, "true"); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX, - restServerParameters.getUserName()); + getValue(restServerParameters.getUserName())); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX, - restServerParameters.getPassword()); + getValue(restServerParameters.getPassword())); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX, String.valueOf(restServerParameters.isHttps())); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_AAF_SUFFIX, @@ -124,6 +124,13 @@ public class RestServer extends ServiceManagerContainer { return names.toString(); } + private String getValue(final String value) { + if (value != null && value.matches("[$][{].*[}]$")) { + return System.getenv(value.substring(2, value.length() - 1)); + } + return value; + } + @Override public String toString() { return "RestServer [servers=" + servers + "]"; |