summaryrefslogtreecommitdiffstats
path: root/BRMSGateway
diff options
context:
space:
mode:
authorpa834y <pa834y@att.com>2019-03-26 14:29:38 -0400
committerpa834y <pa834y@att.com>2019-03-31 19:59:20 -0400
commitc1b69dfb1297365d35f2ada8690f13f787d38b4f (patch)
treef7c9780ad4cd84bb24f5d527feac83cb81f50319 /BRMSGateway
parentc683a67fbf4a50e68bf8736517865b43db75ed4b (diff)
Enhancement to use the common CryptoUtils
Change-Id: I06718526382b424eab991f39a7dac1b5cf4f1b74 Issue-ID: POLICY-1422 Signed-off-by: pa834y <pa834y@att.com>
Diffstat (limited to 'BRMSGateway')
-rw-r--r--BRMSGateway/config.properties5
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java21
2 files changed, 15 insertions, 11 deletions
diff --git a/BRMSGateway/config.properties b/BRMSGateway/config.properties
index d99e0e658..2ef1a28be 100644
--- a/BRMSGateway/config.properties
+++ b/BRMSGateway/config.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# ONAP Policy Engine
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -80,3 +80,6 @@ ping_interval=30000
brms.dependency.version=1.4.0-SNAPSHOT
ENVIRONMENT = DEVL
+
+# AES key for password encryption in config files
+#org.onap.policy.encryption.aes.key=12345678901234567890123456789012
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
index 4466afe3c..a48aac04e 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +25,6 @@ import com.att.nsa.cambria.client.CambriaBatchingPublisher;
import com.att.nsa.cambria.client.CambriaClientBuilders;
import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
import com.fasterxml.jackson.core.JsonProcessingException;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -53,14 +52,12 @@ import java.util.concurrent.TimeUnit;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
-
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import javax.ws.rs.ProcessingException;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.maven.model.Dependency;
@@ -93,6 +90,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.utils.BackUpHandler;
import org.onap.policy.utils.BackUpMonitor;
import org.onap.policy.utils.BusPublisher;
+import org.onap.policy.utils.PeCryptoUtils;
import org.onap.policy.utils.PolicyUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
@@ -120,6 +118,7 @@ public class BrmsPush {
private static final String[] GOALS = { "clean", "deploy" };
private static final String DEFAULT_VERSION = "1.4.0-SNAPSHOT";
private static final String DEPENDENCY_FILE = "dependency.json";
+ private static final String PROP_AES_KEY = "org.onap.policy.encryption.aes.key";
public static final String BRMSPERSISTENCE = "brmsEclipselink.persistencexml";
private static Map<String, String> modifiedGroups = new HashMap<>();
@@ -187,6 +186,9 @@ public class BrmsPush {
throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "Data/File Read Error while reading from the property file.");
}
+ // init the aes key from prop or env
+ PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY));
+
LOGGER.info("Trying to set up IntegrityMonitor");
String resourceName = null;
try {
@@ -254,7 +256,7 @@ public class BrmsPush {
repUrlList.add(repUrl);
}
repUserName = config.getProperty("repositoryUsername");
- repPassword = config.getProperty("repositoryPassword");
+ repPassword = PeCryptoUtils.decrypt(config.getProperty("repositoryPassword"));
if (repUserName == null || repPassword == null) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "repostoryUserName and respositoryPassword properties are required.");
@@ -521,8 +523,10 @@ public class BrmsPush {
LOGGER.info("Updated Local Memory values with values from database.");
} catch (final Exception exception) {
LOGGER.error("Unable to sync group info", exception);
- et.rollback();
- throw exception;
+ if (et.isActive()) {
+ et.rollback();
+ }
+
}
}
@@ -581,7 +585,6 @@ public class BrmsPush {
} catch (final Exception exception) {
LOGGER.error("Unable add policy to database", exception);
et.rollback();
- throw exception;
}
}
@@ -1147,7 +1150,6 @@ public class BrmsPush {
} catch (final Exception exception) {
LOGGER.error("Unable add/update policy group to database for controller name: " + name, exception);
et.rollback();
- throw exception;
}
}
@@ -1203,7 +1205,6 @@ public class BrmsPush {
} catch (final Exception exception) {
LOGGER.error("Unable remove policy from group to database for policy name: " + policyName, exception);
et.rollback();
- throw exception;
}
}