aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcin Wilk <m.wilk@samsung.com>2021-01-14 12:30:23 +0100
committerMarcin Wilk <m.wilk@samsung.com>2021-01-18 15:31:23 +0100
commit3481b12d1cde75fe066e26ba07f8aed817b6d9f9 (patch)
tree0d028a8bbdd5ffa52af4b855bf23475d972f4307
parent0e57b850ab1f49f23c5295dc8e409faa8b19f059 (diff)
Refactor property loggingfrankfurt
Log property values in a consistent way during the initialization. Hide passwords/secrets if not at DEBUG level. Issue-ID: APPC-1916 Signed-off-by: Marcin Wilk <m.wilk@samsung.com> Change-Id: I89fbb1ab74001ba3ca0dc39c275c5340f700a6b1 (cherry picked from commit 0a5c2dc5ea4efb67eb6bc4b542cd6ac4180fec98)
-rw-r--r--appc-core/appc-common-bundle/src/main/java/org/onap/appc/configuration/ConfigurationFactory.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/appc-core/appc-common-bundle/src/main/java/org/onap/appc/configuration/ConfigurationFactory.java b/appc-core/appc-common-bundle/src/main/java/org/onap/appc/configuration/ConfigurationFactory.java
index 3cd2a7400..957002512 100644
--- a/appc-core/appc-common-bundle/src/main/java/org/onap/appc/configuration/ConfigurationFactory.java
+++ b/appc-core/appc-common-bundle/src/main/java/org/onap/appc/configuration/ConfigurationFactory.java
@@ -267,6 +267,16 @@ public final class ConfigurationFactory {
return local;
}
+ private static void logPropertyValue(String key, String value) {
+ if ((!StringUtils.containsIgnoreCase(key, "pass")) && (!StringUtils.containsIgnoreCase(key, "secret"))) {
+ logger.info(Msg.PROPERTY_VALUE, key, value);
+ } else if (logger.isDebugEnabled()) {
+ logger.debug(Msg.PROPERTY_VALUE, key, value);
+ } else {
+ logger.info(Msg.PROPERTY_VALUE, key, value.replaceAll(".", "*"));
+ }
+ }
+
/**
* This method will clear the current configuration and then re-initialize it with the default
* values, application-specific configuration file, user-supplied properties (if any), and then
@@ -313,10 +323,7 @@ public final class ConfigurationFactory {
}
}
for (String key : config.getProperties().stringPropertyNames()) {
- if ((!StringUtils.containsIgnoreCase(key, "pass"))&&(!StringUtils.containsIgnoreCase(key, "secret")))
- logger.info(Msg.PROPERTY_VALUE, key, config.getProperty(key));
- else
- logger.info(Msg.PROPERTY_VALUE, key, config.getProperty(key));
+ logPropertyValue(key, config.getProperty(key));
}
} else {
logger.info(Msg.NO_DEFAULTS_FOUND, DEFAULT_PROPERTIES);
@@ -363,7 +370,7 @@ public final class ConfigurationFactory {
stream = new BufferedInputStream(new FileInputStream(file));
fileProperties.load(stream);
for (String key : fileProperties.stringPropertyNames()) {
- logger.info(Msg.PROPERTY_VALUE, key, fileProperties.getProperty(key));
+ logPropertyValue(key, fileProperties.getProperty(key));
config.setProperty(key, fileProperties.getProperty(key));
}
found = true;
@@ -392,7 +399,7 @@ public final class ConfigurationFactory {
if (props != null) {
logger.info(Msg.LOADING_APPLICATION_OVERRIDES);
for (String key : props.stringPropertyNames()) {
- logger.info(Msg.PROPERTY_VALUE, key, props.getProperty(key));
+ logPropertyValue(key, props.getProperty(key));
config.setProperty(key, props.getProperty(key));
}
} else {