summaryrefslogtreecommitdiffstats
path: root/aai-els-onap-logging
diff options
context:
space:
mode:
authorLaMont, William(wl2432) <wl2432@att.com>2020-05-12 13:47:18 -0400
committerLaMont, William(wl2432) <wl2432@att.com>2020-05-12 13:48:11 -0400
commit1c955fe5f3cc766b0a9de836488a55f6ac4708c3 (patch)
treeed02e9f5a2c1e6b7cb9bd9948309b1bf007becce /aai-els-onap-logging
parent6915f57d07f466a6dd54be693b2af2cec9b8e0c1 (diff)
aai-common support for v20
Issue-ID: AAI-2904 Change-Id: I6dca2f785882b38ca2b2474a11affaa0328c003a Signed-off-by: LaMont, William(wl2432) <wl2432@att.com>
Diffstat (limited to 'aai-els-onap-logging')
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java108
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java2
3 files changed, 84 insertions, 29 deletions
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
index b0fb079c..35d206f0 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
@@ -37,6 +37,9 @@ public class AaiDmaapMetricLog extends MDCSetup {
private static final String TARGET_ENTITY = "DMaaP";
public AaiDmaapMetricLog() {
+ if(MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN) == null) {
+ setServerFQDN();
+ }
}
public void pre(String targetServiceName, String event, String transactionId, String serviceName) {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
index 7de6af28..9232b1c8 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
@@ -32,7 +32,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Properties;
-import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -44,9 +43,11 @@ public class AAIApplicationConfig {
private static final String PASSPHRASSES_FILENAME = ".passphrases";
private static final String PASSWORD_FILENAME = ".password";
private static final String TRUSTSTORE_PASSWORD_PROP_NAME = "cadi_truststore_password";
- private static final String SERVER_SSL_KEYSTORE_PROP_NAME = "server.ssl.key-store";
- private static final String SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME = "server.ssl.key-store.pkcs12";
- private static final String SERVER_SSL_TRUSTSTORE_PROP_NAME = "server.ssl.trust-store";
+ public static final String SERVER_SSL_KEYSTORE_PROP_NAME = "server.ssl.key-store";
+ public static final String SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME = "server.ssl.key-store.pkcs12";
+ public static final String SERVER_SSL_TRUSTSTORE_PROP_NAME = "server.ssl.trust-store";
+ public static final String TRUSTSTORE_PASSWORD_NAME = "server.ssl.trust-store-password";
+ public static final String KEYSTORE_PASSWORD_NAME = "server.ssl.key-store-password";
private static Properties serverProps;
private static boolean propsInitialized = false;
private static String TRUSTSTORE_PASSWORD = null;
@@ -66,20 +67,9 @@ public class AAIApplicationConfig {
* @throws AAIException the AAI exception
*/
public synchronized static void init() {
- /*LoggingContext.save();
- LoggingContext.component("config");
- LoggingContext.partnerName("NA");
- LoggingContext.targetEntity("AAI");
- LoggingContext.requestId(UUID.randomUUID().toString());
- LoggingContext.serviceName("AAI");
- LoggingContext.targetServiceName("init");
- LoggingContext.statusCode(StatusCode.COMPLETE);*/
LOGGER.info("Initializing AAIApplicationConfig");
-
AAIApplicationConfig.reloadConfig();
-
- //LoggingContext.restore();
}
/**
@@ -210,6 +200,14 @@ public class AAIApplicationConfig {
catch (AAIException e) {
return null;
}
+ return (retrieveKeystorePasswordWithCertPath(certPath));
+ }
+ /**
+ * Retrieve the keystore password
+ *
+ * @return the password
+ */
+ private static String retrieveKeystorePasswordWithCertPath(String certPath) {
File passwordFile = null;
InputStream passwordStream = null;
@@ -238,7 +236,6 @@ public class AAIApplicationConfig {
}
return keystorePassword;
}
-
/**
* Get the keystore password
*
@@ -247,23 +244,13 @@ public class AAIApplicationConfig {
public static String getKeystorePassword() {
return (KEYSTORE_PASSWORD);
}
-
/**
* Gets the truststore password
*
* @return the password
*/
- private static String retrieveTruststorePassword() {
- String certPath = serverProps.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
- if (certPath == null) {
- return null;
- }
- try {
- certPath = replaceProperties(certPath);
- }
- catch (AAIException e) {
- return null;
- }
+ private static String retrieveTruststorePasswordWithCertPath(String certPath) {
+
File passphrasesFile = null;
InputStream passphrasesStream = null;
String truststorePassword = null;
@@ -294,6 +281,24 @@ public class AAIApplicationConfig {
return truststorePassword;
}
+ /**
+ * Gets the truststore password
+ *
+ * @return the password
+ */
+ private static String retrieveTruststorePassword() {
+ String certPath = serverProps.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
+ if (certPath == null) {
+ return null;
+ }
+ try {
+ certPath = replaceProperties(certPath);
+ }
+ catch (AAIException e) {
+ return null;
+ }
+ return (retrieveTruststorePasswordWithCertPath(certPath));
+ }
/**
* Get the trustore password
@@ -359,4 +364,51 @@ public class AAIApplicationConfig {
m.appendTail(sb);
return(sb.toString());
}
+
+ public static Properties retrieveKeystoreProps() throws AAIException {
+
+ Properties props = new Properties();
+ String truststorePath = System.getProperty(SERVER_SSL_TRUSTSTORE_PROP_NAME);
+ String truststorePassword = System.getProperty(TRUSTSTORE_PASSWORD_NAME);
+ String keystorePath = System.getProperty(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME);
+ String keystorePassword = System.getProperty(KEYSTORE_PASSWORD_NAME);
+ String certLocation = System.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
+
+ if (truststorePath == null || truststorePath.isEmpty()){
+ truststorePath = AAIApplicationConfig.getTruststore();
+ }
+ if (truststorePath != null) {
+ props.setProperty(SERVER_SSL_TRUSTSTORE_PROP_NAME, truststorePath);
+ }
+ if (truststorePassword == null || truststorePassword.isEmpty()) {
+ if (certLocation != null && (!certLocation.isEmpty())) {
+ truststorePassword = AAIApplicationConfig.retrieveTruststorePasswordWithCertPath(certLocation);
+ }
+ else {
+ truststorePassword = AAIApplicationConfig.getTruststorePassword();
+ }
+
+ }
+ if (truststorePassword != null) {
+ props.setProperty(TRUSTSTORE_PASSWORD_NAME, truststorePassword);
+ }
+ if (keystorePath == null || keystorePath.isEmpty()){
+ keystorePath = AAIApplicationConfig.getKeystorePkcs12();
+ }
+ if (keystorePath != null) {
+ props.setProperty(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME, keystorePath);
+ }
+ if (keystorePassword == null || keystorePassword.isEmpty()){
+ if (certLocation != null && (!certLocation.isEmpty())) {
+ keystorePassword = AAIApplicationConfig.retrieveKeystorePasswordWithCertPath(certLocation);
+ }
+ else {
+ keystorePassword = AAIApplicationConfig.getKeystorePassword();
+ }
+ }
+ if (keystorePassword != null) {
+ props.setProperty(KEYSTORE_PASSWORD_NAME, keystorePassword);
+ }
+ return(props);
+ }
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
index a41ad27b..fef10a77 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
@@ -55,7 +55,7 @@ public class HbaseSaltPrefixer {
* @return the string
*/
public String prependSalt(String key) {
- int salt = key.hashCode() % NUM_REGION_BUCKETS;
+ int salt = Math.abs(key.hashCode()) % NUM_REGION_BUCKETS;
return salt + "-" + key;
}
}