summaryrefslogtreecommitdiffstats
path: root/datarouter-node/src/main/java
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2019-10-08 16:24:28 +0100
committerefiacor <fiachra.corcoran@est.tech>2019-10-11 09:22:47 +0100
commit1ccd9c36ba12849148f9eb73e8ff2ffe4ade5870 (patch)
treeb138596f05a8cdda774d5b447253ac6c673ceceb /datarouter-node/src/main/java
parent029b5296b1bc070be3f1718190c50a1d58a2ecfa (diff)
Update AAF loading procedure2.1.3
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Issue-ID: DMAAP-1318 Change-Id: I8dc75bdbcd05e5316b5c05cbc258010068fb63e8
Diffstat (limited to 'datarouter-node/src/main/java')
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java2
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java4
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtils.java58
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java27
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java44
5 files changed, 86 insertions, 49 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java
index 245dbccd..9cdaeecd 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java
@@ -35,7 +35,7 @@ import org.onap.aaf.cadi.filter.CadiFilter;
public class DRNodeCadiFilter extends CadiFilter {
- private static EELFLogger logger = EELFManager.getInstance().getLogger(NodeServlet.class);
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(DRNodeCadiFilter.class);
DRNodeCadiFilter(boolean init, PropAccess access) throws ServletException {
super(init, access);
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java
index 46750812..83d5186a 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java
@@ -168,7 +168,9 @@ public class Delivery {
}
}
try {
- Files.delete(sxf.toPath()); // won't if anything still in it
+ if (sxf.list().length == 0) {
+ Files.delete(sxf.toPath()); // won't if anything still in it
+ }
} catch (IOException e) {
logger.error("Failed to delete file: " + sxf.getPath(), e);
}
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtils.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtils.java
new file mode 100644
index 00000000..542dfd08
--- /dev/null
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeAafPropsUtils.java
@@ -0,0 +1,58 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dmaap.datarouter.node;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import org.onap.aaf.cadi.PropAccess;
+
+class NodeAafPropsUtils {
+
+ private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger(NodeAafPropsUtils.class);
+ private PropAccess propAccess;
+
+ NodeAafPropsUtils(File propsFile) throws IOException {
+ propAccess = new PropAccess();
+ try {
+ propAccess.load(new FileInputStream(propsFile.getPath()));
+ } catch (IOException e) {
+ eelfLogger.error("Failed to load props file: " + propsFile + "\n" + e.getMessage(), e);
+ throw e;
+ }
+ }
+
+ String getDecryptedPass(String password) {
+ String decryptedPass = "";
+ try {
+ decryptedPass = getPropAccess().decrypt(getPropAccess().getProperty(password), false);
+ } catch (IOException e) {
+ eelfLogger.error("Failed to decrypt " + password + " : " + e.getMessage(), e);
+ }
+ return decryptedPass;
+ }
+
+ PropAccess getPropAccess() {
+ return propAccess;
+ }
+}
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java
index 0283f5cb..aeddc729 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java
@@ -105,6 +105,7 @@ public class NodeConfigManager implements DeliveryQueueHelper {
private String aafAction;
private String aafURL;
private boolean cadiEnabled;
+ private NodeAafPropsUtils nodeAafPropsUtils;
/**
@@ -124,6 +125,14 @@ public class NodeConfigManager implements DeliveryQueueHelper {
"/opt/app/datartr/etc/node.properties"));
}
provurl = drNodeProperties.getProperty("ProvisioningURL", "https://dmaap-dr-prov:8443/internal/prov");
+ String aafPropsFilePath = drNodeProperties
+ .getProperty("AAFPropsFilePath", "/opt/app/osaaf/local/org.onap.dmaap-dr.props");
+ try {
+ nodeAafPropsUtils = new NodeAafPropsUtils(new File(aafPropsFilePath));
+ } catch (IOException e) {
+ eelfLogger.error("NODE0314 Failed to load AAF props. Exiting", e);
+ exit(1);
+ }
/*
* START - AAF changes: TDP EPIC US# 307413
* Pull AAF settings from node.properties
@@ -131,8 +140,8 @@ public class NodeConfigManager implements DeliveryQueueHelper {
aafType = drNodeProperties.getProperty("AAFType", "org.onap.dmaap-dr.feed");
aafInstance = drNodeProperties.getProperty("AAFInstance", "legacy");
aafAction = drNodeProperties.getProperty("AAFAction", "publish");
- aafURL = drNodeProperties.getProperty("AafUrl", "https://aaf-onap-test.osaaf.org:8095");
cadiEnabled = Boolean.parseBoolean(drNodeProperties.getProperty("CadiEnabled", "false"));
+ aafURL = nodeAafPropsUtils.getPropAccess().getProperty("aaf_locate_url", "https://aaf-locate:8095");
/*
* END - AAF changes: TDP EPIC US# 307413
* Pull AAF settings from node.properties
@@ -168,13 +177,13 @@ public class NodeConfigManager implements DeliveryQueueHelper {
eventlogprefix = logdir + "/events";
eventlogsuffix = ".log";
redirfile = drNodeProperties.getProperty("RedirectionFile", "etc/redirections.dat");
- kstype = drNodeProperties.getProperty("KeyStoreType", "jks");
- ksfile = drNodeProperties.getProperty("KeyStoreFile", "etc/keystore");
- kspass = drNodeProperties.getProperty("KeyStorePassword", CHANGE_ME);
- kpass = drNodeProperties.getProperty("KeyPassword", CHANGE_ME);
+ kstype = drNodeProperties.getProperty("KeyStoreType", "PKCS12");
+ ksfile = nodeAafPropsUtils.getPropAccess().getProperty("cadi_keystore");
+ kspass = nodeAafPropsUtils.getDecryptedPass("cadi_keystore_password");
+ kpass = nodeAafPropsUtils.getDecryptedPass("cadi_keystore_password");
tstype = drNodeProperties.getProperty("TrustStoreType", "jks");
- tsfile = drNodeProperties.getProperty("TrustStoreFile");
- tspass = drNodeProperties.getProperty("TrustStorePassword", CHANGE_ME);
+ tsfile = nodeAafPropsUtils.getPropAccess().getProperty("cadi_truststore");
+ tspass = nodeAafPropsUtils.getDecryptedPass("cadi_truststore_password");
if (tsfile != null && tsfile.length() > 0) {
System.setProperty("javax.net.ssl.trustStoreType", tstype);
System.setProperty("javax.net.ssl.trustStore", tsfile);
@@ -802,6 +811,10 @@ public class NodeConfigManager implements DeliveryQueueHelper {
return cadiEnabled;
}
+ public NodeAafPropsUtils getNodeAafPropsUtils() {
+ return nodeAafPropsUtils;
+ }
+
/**
* Builds the permissions string to be verified.
*
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
index fcc3f897..56086301 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
@@ -25,12 +25,8 @@ package org.onap.dmaap.datarouter.node;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.EnumSet;
-import java.util.Properties;
import javax.servlet.DispatcherType;
-import javax.servlet.ServletException;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
@@ -43,7 +39,6 @@ import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.ssl.SslContextFactory;
-import org.onap.aaf.cadi.PropAccess;
/**
* The main starting point for the Data Router node.
@@ -144,7 +139,8 @@ public class NodeMain {
//CADI Filter activation check
if (nodeConfigManager.getCadiEnabled()) {
- enableCadi(servletContextHandler);
+ servletContextHandler.addFilter(new FilterHolder(new DRNodeCadiFilter(true,
+ nodeConfigManager.getNodeAafPropsUtils().getPropAccess())), "/*", EnumSet.of(DispatcherType.REQUEST));
}
server.setHandler(servletContextHandler);
@@ -163,24 +159,6 @@ public class NodeMain {
nodeMainLogger.debug("NODE00007 Node Server joined - " + server.getState());
}
- private static void enableCadi(ServletContextHandler servletContextHandler) throws ServletException {
- Properties cadiProperties = new Properties();
- try {
- Inner obj = new NodeMain().new Inner();
- InputStream in = obj.getCadiProps();
- cadiProperties.load(in);
- } catch (IOException e1) {
- nodeMainLogger
- .error("NODE00005 Exception in NodeMain.Main() loading CADI properties " + e1.getMessage(), e1);
- }
- cadiProperties.setProperty("aaf_locate_url", nodeConfigManager.getAafURL());
- nodeMainLogger.debug("NODE00005 aaf_url set to - " + cadiProperties.getProperty("aaf_url"));
-
- PropAccess access = new PropAccess(cadiProperties);
- servletContextHandler.addFilter(new FilterHolder(new DRNodeCadiFilter(true, access)), "/*", EnumSet
- .of(DispatcherType.REQUEST));
- }
-
private static class WaitForConfig implements Runnable {
private NodeConfigManager localNodeConfigManager;
@@ -200,26 +178,12 @@ public class NodeMain {
try {
wait();
} catch (Exception exception) {
- nodeMainLogger
- .error("NodeMain: waitForConfig exception. Exception Message:- " + exception.toString(),
- exception);
+ nodeMainLogger.error("NodeMain: waitForConfig exception. Exception Message:- "
+ + exception.toString(), exception);
}
}
localNodeConfigManager.deregisterConfigTask(this);
nodeMainLogger.debug("NODE0004 Node Configuration Data Received");
}
}
-
- class Inner {
-
- InputStream getCadiProps() {
- InputStream in = null;
- try {
- in = getClass().getClassLoader().getResourceAsStream("drNodeCadi.properties");
- } catch (Exception e) {
- nodeMainLogger.error("Exception in Inner.getCadiProps() method ", e);
- }
- return in;
- }
- }
}