aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md114
-rw-r--r--Subscriber/src/SSASubscriber.java115
-rw-r--r--Subscriber/src/log4j.properties9
-rw-r--r--datarouter-node/aaf_certs/org.onap.dmaap-dr.jksbin0 -> 3659 bytes
-rw-r--r--datarouter-node/aaf_certs/org.onap.dmaap-dr.trust.jksbin0 -> 1413 bytes
-rwxr-xr-xdatarouter-node/pom.xml6
-rw-r--r--datarouter-node/self_signed/cacerts.jksbin1936 -> 0 bytes
-rw-r--r--datarouter-node/self_signed/keystore.jksbin2273 -> 0 bytes
-rw-r--r--datarouter-node/self_signed/mykey.cerbin921 -> 0 bytes
-rw-r--r--datarouter-node/self_signed/nodekey.cerbin921 -> 0 bytes
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java56
-rw-r--r--datarouter-node/src/main/resources/node.properties223
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java131
-rwxr-xr-xdatarouter-prov/aaf_certs/org.onap.dmaap-dr.jksbin0 -> 3660 bytes
-rwxr-xr-xdatarouter-prov/aaf_certs/org.onap.dmaap-dr.trust.jksbin0 -> 1413 bytes
-rwxr-xr-xdatarouter-prov/pom.xml6
-rw-r--r--datarouter-prov/self_signed/cacerts.jksbin983 -> 0 bytes
-rw-r--r--datarouter-prov/self_signed/keystore.jksbin2272 -> 0 bytes
-rw-r--r--datarouter-prov/self_signed/mykey.cerbin921 -> 0 bytes
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java10
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java14
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java2
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java200
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java36
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java6
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/node_data/node.properties112
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/cacerts.jksbin1936 -> 0 bytes
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/keystore.jksbin2273 -> 0 bytes
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/mykey.cerbin921 -> 0 bytes
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/nodekey.cerbin921 -> 0 bytes
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/cacerts.jksbin983 -> 0 bytes
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/keystore.jksbin2272 -> 0 bytes
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/mykey.cerbin921 -> 0 bytes
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/resources/misc/sql_init_01.sql12
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/resources/provserver.properties10
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java4
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java3
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java80
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java3
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java3
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java5
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java3
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java5
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java2
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java4
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecordTest.java83
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java88
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java77
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLITest.java215
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java498
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSetTest.java172
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java218
-rw-r--r--datarouter-prov/src/test/resources/integration_test.properties10
-rwxr-xr-xdatarouter-subscriber/pom.xml393
-rw-r--r--datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/Subscriber.java120
-rw-r--r--datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberServlet.java (renamed from Subscriber/src/SubscriberServlet.java)153
-rw-r--r--datarouter-subscriber/src/main/resources/docker/Dockerfile6
-rw-r--r--datarouter-subscriber/src/main/resources/docker/startup.sh12
-rw-r--r--datarouter-subscriber/src/main/resources/log4j.properties31
-rw-r--r--datarouter-subscriber/src/main/resources/subscriber.properties40
-rwxr-xr-x[-rw-r--r--]docker-compose/database/sql_init_01.sql (renamed from datarouter-prov/src/main/resources/docker-compose/database/sql_init_01.sql)12
-rw-r--r--docker-compose/docker-compose.yml (renamed from datarouter-prov/src/main/resources/docker-compose/docker-compose.yml)205
-rwxr-xr-xdocker-compose/node_data/aaf_certs/org.onap.dmaap-dr.jksbin0 -> 3659 bytes
-rwxr-xr-xdocker-compose/node_data/aaf_certs/org.onap.dmaap-dr.trust.jksbin0 -> 1413 bytes
-rw-r--r--docker-compose/node_data/node.properties (renamed from datarouter-node/src/main/resources/misc/node.properties)222
-rwxr-xr-xdocker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.jksbin0 -> 3660 bytes
-rwxr-xr-xdocker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.trust.jksbin0 -> 1413 bytes
-rw-r--r--docker-compose/prov_data/addFeed3.txt (renamed from datarouter-prov/src/main/resources/docker-compose/prov_data/addFeed3.txt)0
-rw-r--r--docker-compose/prov_data/addSubscriber.txt (renamed from datarouter-prov/src/main/resources/docker-compose/prov_data/addSubscriber.txt)0
-rwxr-xr-x[-rw-r--r--]docker-compose/prov_data/provserver.properties (renamed from datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties)10
-rw-r--r--docker-compose/subscriber_data/subscriber.properties40
-rwxr-xr-xpom.xml1
72 files changed, 2888 insertions, 892 deletions
diff --git a/README.md b/README.md
index 559b03d2..6e45867a 100644
--- a/README.md
+++ b/README.md
@@ -1,105 +1,103 @@
# DMAAP_DATAROUTER
-
+
## OVERVIEW
-
-The Data Routing System project is intended to provide a common framework by which data producers can make data available to data consumers and a way for potential consumers to find feeds with the data they require.
+
+The Data Routing System project is intended to provide a common framework by which data producers can make data available to data consumers and a way for potential consumers to find feeds with the data they require.
The delivery of data from these kinds of production systems is the domain of the Data Routing System. Its primary goal is to make it easier to move data from existing applications that may not have been designed from the ground up to share data.
The Data Routing System is different from many existing platforms for distributing messages from producers to consumers which focus on real-time delivery of small messages (on the order of a few kilobytes or so) for more
Provisioning is implemented as a Java servlet running under Jetty in one JVM
-
+
Provisioning data is stored in a MariaDB database
-
+
The backup provisioning server and each node is informed any time provisioning data changes
-
+
The backup provisioning server and each node may request the complete set of provisioning data at any time
-
+
A Node is implemented as a Java servlet running under Jetty in one JVM
Assumptions
For 95% of all feeds (there will be some exceptions):
-
+
Number of Publishing Endpoints per Feed: 1 – 10
-
+
Number of Subscribers per Feed: 2 – 10
-
+
File Size: 105 – 1010 bytes
-
+
with a distribution towards the high end
-
+
Frequency of Publishing: 1/day – 10/minute
-
+
Lifetime of a Feed: months to years
-
+
Lifetime of a Subscription: months to years
-
-
+
+
Data Router and Sensitive Data Handling
-
+
A publisher of a Data Router feed of sensitive (e.g., PCI, SPI, etc.) data needs to encrypt that data prior to delivering it to the Data Router
-
+
The Data Router will distribute that data to all of the subscribers of that feed.
-
+
Data Router does not examine the Feed content or enforce any restrictions or Validations on the Feed Content in any way
-
+
It is the responsibility of the subscribers to work with the publisher to determine how to decrypt that data
-
-
+
+
What the Data Router is NOT:
Does not support streaming data
-
+
Does not tightly couple to any specific publish endpoint or subscriber
-
+
Agnostic as to source and sink of data residing in an RDBMS, NoSQL DB, Other DBMS, Flat Files, etc.
-
+
Does not transform any published data
-
+
Does not “examine” any published data
-
+
Does not verify the integrity of a published file
-
+
Does not perform any data “cleansing”
-
+
Does not store feeds (not a repository or archive)
-
+
There is no long-term storage – assumes subscribers are responsive most of the time
-
+
Does not encrypt data when queued on a node
-
+
Does not provide guaranteed order of delivery
-
+
Per-file metadata can be used for ordering
-
- External customers supported is via DITREX (MOTS 18274)
-
-
-
-## BUILD
-
-Datarouter can be cloned and repository and builb using Maven
-In the repository
+
+
+
+## BUILD
+
+Datarouter can be cloned and repository and builb using Maven
+In the repository
Go to datarouter-prov in the root
mvn clean install
-
+
Go to datarouter-node in the root
mvn clean install
-
+
Project Build will be Successful
-## RUN
+## RUN
-Datarouter is a Unix based service
+Datarouter is a Unix based service
Pre-requisites to run the service
@@ -111,39 +109,39 @@ Install MariaDB and load needed table into the database
Sample sql_init_01.sql is provided in the datarouter-prov/src/main/resources/misc
-Go to datarouter-prov module and run the service using main.java
-
-Go to datarouter-node module and run the service using nodemain.java
+Go to datarouter-prov module and run the service using main.java
+
+Go to datarouter-node module and run the service using nodemain.java
Curl Commands to test:
create a feed:
-curl -v -X POST -H "Content-Type : application/vnd.att-dr.feed" -H "X-ATT-DR-ON-BEHALF-OF: rs873m" --data-ascii @/opt/app/datartr/addFeed3.txt --post301 --location-trusted -k https://prov.datarouternew.com:8443
+curl -v -X POST -H "Content-Type : application/vnd.att-dr.feed" -H "X-ATT-DR-ON-BEHALF-OF: rs873m" --data-ascii @/opt/app/datartr/addFeed3.txt --post301 --location-trusted -k https://dmaap-dr-prov:8443
Subscribe to feed:
-curl -v -X POST -H "Content-Type: application/vnd.att-dr.subscription" -H "X-ATT-DR-ON-BEHALF-OF: rs873m" --data-ascii @/opt/app/datartr/addSubscriber.txt --post301 --location-trusted -k https://prov.datarouternew.com:8443/subscribe/1
+curl -v -X POST -H "Content-Type: application/vnd.att-dr.subscription" -H "X-ATT-DR-ON-BEHALF-OF: rs873m" --data-ascii @/opt/app/datartr/addSubscriber.txt --post301 --location-trusted -k https://dmaap-dr-prov:8443/subscribe/1
Publish to feed:
-curl -v -X PUT --user rs873m:rs873m -H "Content-Type: application/octet-stream" --data-binary @/opt/app/datartr/addFeed3.txt --post301 --location-trusted -k https://prov.datarouternew.com:8443/publish/1/test1
+curl -v -X PUT --user rs873m:rs873m -H "Content-Type: application/octet-stream" --data-binary @/opt/app/datartr/addFeed3.txt --post301 --location-trusted -k https://dmaap-dr-prov:8443/publish/1/test1
+
-
- ## CONFIGURATION
+ ## CONFIGURATION
-Recommended
+Recommended
Environment - Unix based
Java - 1.8
-Maven - 3.2.5
+Maven - 3.2.5
MariaDB - 10.2.14
Self Signed SSL certificates
-
-
+
+
diff --git a/Subscriber/src/SSASubscriber.java b/Subscriber/src/SSASubscriber.java
deleted file mode 100644
index 5ec099bd..00000000
--- a/Subscriber/src/SSASubscriber.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 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.
- * * 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.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-
-import org.eclipse.jetty.http.HttpVersion;
-import org.eclipse.jetty.servlet.*;
-import org.eclipse.jetty.util.ssl.*;
-import org.eclipse.jetty.server.*;
-import org.apache.log4j.Logger;
-
-/**
- * Example stand alone subscriber
- */
-public class SSASubscriber {
- private static final int Port = 8447;
- private static final String KeyStoreType = "jks";
- private static final String KeyStoreFile = "/root/sub/subscriber.jks";
- //private static final String KeyStoreFile = "c:/tmp/subscriber.jks";
- private static final String KeyStorePassword = "changeit";
- private static final String KeyPassword = "changeit";
- private static final String ContextPath = "/";
- private static final String URLPattern = "/*";
-
- public static void main(String[] args) throws Exception {
- //User story # US792630 -Jetty Upgrade to 9.3.11
- //SSASubscriber register Jetty server.
- Server server = new Server();
- HttpConfiguration http_config = new HttpConfiguration();
- http_config.setSecureScheme("https");
- http_config.setSecurePort(Port);
- http_config.setRequestHeaderSize(8192);
-
- // HTTP connector
- ServerConnector http = new ServerConnector(server,
- new HttpConnectionFactory(http_config));
- http.setPort(7070);
- http.setIdleTimeout(30000);
-
- // SSL Context Factory
- SslContextFactory sslContextFactory = new SslContextFactory();
- sslContextFactory.setKeyStoreType(KeyStoreType);
- sslContextFactory.setKeyStorePath(KeyStoreFile);
- sslContextFactory.setKeyStorePassword(KeyStorePassword);
- sslContextFactory.setKeyManagerPassword(KeyPassword);
-
- // sslContextFactory.setTrustStorePath(ncm.getKSFile());
- // sslContextFactory.setTrustStorePassword("changeit");
- sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA",
- "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA",
- "SSL_RSA_EXPORT_WITH_RC4_40_MD5",
- "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
- "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
- "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
-
- // SSL HTTP Configuration
- HttpConfiguration https_config = new HttpConfiguration(http_config);
- https_config.addCustomizer(new SecureRequestCustomizer());
-
- // SSL Connector
- ServerConnector sslConnector = new ServerConnector(server,
- new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
- new HttpConnectionFactory(https_config));
- sslConnector.setPort(Port);
- server.addConnector(sslConnector);
-
- /**Skip SSLv3 Fixes*/
- sslContextFactory.addExcludeProtocols("SSLv3");
- System.out.println("Excluded protocols SSASubscriber-"+sslContextFactory.getExcludeProtocols().toString());
- /**End of SSLv3 Fixes*/
-
- // HTTPS Configuration
- ServerConnector https = new ServerConnector(server,
- new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
- new HttpConnectionFactory(https_config));
- https.setPort(Port);
- https.setIdleTimeout(30000);
- //server.setConnectors(new Connector[] { http, https });
- server.setConnectors(new Connector[] { http });
- ServletContextHandler ctxt = new ServletContextHandler(0);
- ctxt.setContextPath(ContextPath);
- server.setHandler(ctxt);
-
- ctxt.addServlet(new ServletHolder(new SubscriberServlet()), "/*");
-
- try {
- server.start();
- } catch ( Exception e ) {
- System.out.println("Jetty failed to start. Reporting will we unavailable-"+e);
- };
- server.join();
-
- System.out.println("Subscriber started-"+ server.getState());
-
- }
-} \ No newline at end of file
diff --git a/Subscriber/src/log4j.properties b/Subscriber/src/log4j.properties
deleted file mode 100644
index 8c12d5ca..00000000
--- a/Subscriber/src/log4j.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-log4j.debug=FALSE
-log4j.rootLogger=INFO,Root
-
-log4j.appender.Root=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.Root.file=/opt/app/datartr/logs/subscriber.log
-log4j.appender.Root.datePattern='.'yyyyMMdd
-log4j.appender.Root.append=true
-log4j.appender.Root.layout=org.apache.log4j.PatternLayout
-log4j.appender.Root.layout.ConversionPattern=%d %p %t %m%n
diff --git a/datarouter-node/aaf_certs/org.onap.dmaap-dr.jks b/datarouter-node/aaf_certs/org.onap.dmaap-dr.jks
new file mode 100644
index 00000000..4529cccb
--- /dev/null
+++ b/datarouter-node/aaf_certs/org.onap.dmaap-dr.jks
Binary files differ
diff --git a/datarouter-node/aaf_certs/org.onap.dmaap-dr.trust.jks b/datarouter-node/aaf_certs/org.onap.dmaap-dr.trust.jks
new file mode 100644
index 00000000..096fbb26
--- /dev/null
+++ b/datarouter-node/aaf_certs/org.onap.dmaap-dr.trust.jks
Binary files differ
diff --git a/datarouter-node/pom.xml b/datarouter-node/pom.xml
index 61e95400..18743db8 100755
--- a/datarouter-node/pom.xml
+++ b/datarouter-node/pom.xml
@@ -43,7 +43,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -376,10 +376,10 @@
<goal>copy-resources</goal>
</goals>
<configuration>
- <outputDirectory>${basedir}/target/opt/app/datartr/self_signed</outputDirectory>
+ <outputDirectory>${basedir}/target/opt/app/datartr/aaf_certs</outputDirectory>
<resources>
<resource>
- <directory>${basedir}/self_signed</directory>
+ <directory>${basedir}/aaf_certs</directory>
<includes>
<include>misc/**</include>
<include>**/**</include>
diff --git a/datarouter-node/self_signed/cacerts.jks b/datarouter-node/self_signed/cacerts.jks
deleted file mode 100644
index dfd81433..00000000
--- a/datarouter-node/self_signed/cacerts.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-node/self_signed/keystore.jks b/datarouter-node/self_signed/keystore.jks
deleted file mode 100644
index e5a4e781..00000000
--- a/datarouter-node/self_signed/keystore.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-node/self_signed/mykey.cer b/datarouter-node/self_signed/mykey.cer
deleted file mode 100644
index 2a5c9d70..00000000
--- a/datarouter-node/self_signed/mykey.cer
+++ /dev/null
Binary files differ
diff --git a/datarouter-node/self_signed/nodekey.cer b/datarouter-node/self_signed/nodekey.cer
deleted file mode 100644
index 4cdfdfe3..00000000
--- a/datarouter-node/self_signed/nodekey.cer
+++ /dev/null
Binary files differ
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
index 375a38e3..2c013ca5 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
@@ -28,26 +28,30 @@ import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
-import java.security.*;
-import java.io.*;
-import java.util.*;
-import java.security.cert.*;
-import java.net.*;
-import java.text.*;
-
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.security.KeyStore;
+import java.security.MessageDigest;
+import java.security.cert.X509Certificate;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.TimeZone;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.onap.dmaap.datarouter.node.eelf.EelfMsgs;
import org.slf4j.MDC;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
/**
* Utility functions for the data router node
*/
public class NodeUtils {
- private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger("org.onap.dmaap.datarouter.node.NodeUtils");
+
+ private static EELFLogger eelfLogger = EELFManager.getInstance()
+ .getLogger("org.onap.dmaap.datarouter.node.NodeUtils");
private static Logger nodeUtilsLogger = Logger.getLogger("org.onap.dmaap.datarouter.node.NodeUtils");
private static SimpleDateFormat logDate;
@@ -72,7 +76,7 @@ public class NodeUtils {
/**
* Given a user and password, generate the credentials
*
- * @param user User name
+ * @param user User name
* @param password User password
* @return Authorization header value
*/
@@ -96,13 +100,15 @@ public class NodeUtils {
md.update(key.getBytes());
return (getAuthHdr(node, base64Encode(md.digest())));
} catch (Exception exception) {
- nodeUtilsLogger.error("Exception in generating Credentials for given node name:= " + exception.toString(), exception);
+ nodeUtilsLogger
+ .error("Exception in generating Credentials for given node name:= " + exception.toString(), exception);
return (null);
}
}
/**
- * Given a keystore file and its password, return the value of the CN of the first private key entry with a certificate.
+ * Given a keystore file and its password, return the value of the CN of the first private key entry with a
+ * certificate.
*
* @param kstype The type of keystore
* @param ksfile The file name of the keystore
@@ -110,15 +116,16 @@ public class NodeUtils {
* @return CN of the certificate subject or null
*/
public static String getCanonicalName(String kstype, String ksfile, String kspass) {
- KeyStore ks=null;
+ KeyStore ks;
try {
ks = KeyStore.getInstance(kstype);
- try(FileInputStream fileInputStream=new FileInputStream(ksfile)) {
+ try (FileInputStream fileInputStream = new FileInputStream(ksfile)) {
ks.load(fileInputStream, kspass.toCharArray());
+ } catch (IOException ioException) {
+ nodeUtilsLogger.error("IOException occurred while opening FileInputStream: " + ioException.getMessage(),
+ ioException);
+ return (null);
}
- } catch(IOException ioException) {
- nodeUtilsLogger.error("Exception occurred while opening FileInputStream",ioException);
- return (null);
} catch (Exception e) {
setIpAndFqdnForEelf("getCanonicalName");
eelfLogger.error(EelfMsgs.MESSAGE_KEYSTORE_LOAD_ERROR, ksfile, e.toString());
@@ -147,7 +154,7 @@ public class NodeUtils {
if (parts.length < 1) {
return (null);
}
- subject = parts[0].trim();
+ subject = parts[5].trim();
if (!subject.startsWith("CN=")) {
return (null);
@@ -172,7 +179,8 @@ public class NodeUtils {
try {
return (InetAddress.getByName(ip).getAddress());
} catch (Exception exception) {
- nodeUtilsLogger.error("Exception in generating byte array for given IP address := " + exception.toString(), exception);
+ nodeUtilsLogger
+ .error("Exception in generating byte array for given IP address := " + exception.toString(), exception);
}
return (null);
}
@@ -202,7 +210,8 @@ public class NodeUtils {
}
/**
- * Escape fields that might contain vertical bar, backslash, or newline by replacing them with backslash p, backslash e and backslash n.
+ * Escape fields that might contain vertical bar, backslash, or newline by replacing them with backslash p,
+ * backslash e and backslash n.
*/
public static String loge(String s) {
if (s == null) {
@@ -246,7 +255,8 @@ public class NodeUtils {
MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
} catch (Exception exception) {
- nodeUtilsLogger.error("Exception in generating byte array for given IP address := " + exception.toString(), exception);
+ nodeUtilsLogger
+ .error("Exception in generating byte array for given IP address := " + exception.toString(), exception);
}
}
diff --git a/datarouter-node/src/main/resources/node.properties b/datarouter-node/src/main/resources/node.properties
index 411cc2b9..de38cb6f 100644
--- a/datarouter-node/src/main/resources/node.properties
+++ b/datarouter-node/src/main/resources/node.properties
@@ -1,112 +1,111 @@
-#-------------------------------------------------------------------------------
-# ============LICENSE_START==================================================
-# * org.onap.dmaap
-# * ===========================================================================
-# * Copyright 2017 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.
-# * 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.
-# * ============LICENSE_END====================================================
-# *
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# *
-#-------------------------------------------------------------------------------
-#
-# Configuration parameters fixed at startup for the DataRouter node
-#
-# URL to retrieve dynamic configuration
-#
-#ProvisioningURL: ${DRTR_PROV_INTURL}
-ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov
-
-#
-# URL to upload PUB/DEL/EXP logs
-#
-#LogUploadURL: ${DRTR_LOG_URL}
-LogUploadURL=https://prov.datarouternew.com:8443/internal/logs
-
-#
-# The port number for http as seen within the server
-#
-#IntHttpPort: ${DRTR_NODE_INTHTTPPORT:-8080}
-IntHttpPort=8080
-#
-# The port number for https as seen within the server
-#
-IntHttpsPort=8443
-#
-# The external port number for https taking port mapping into account
-#
-ExtHttpsPort=443
-#
-# The minimum interval between fetches of the dynamic configuration
-# from the provisioning server
-#
-MinProvFetchInterval=10000
-#
-# The minimum interval between saves of the redirection data file
-#
-MinRedirSaveInterval=10000
-#
-# The path to the directory where log files are stored
-#
-LogDir=/opt/app/datartr/logs
-#
-# The retention interval (in days) for log files
-#
-LogRetention=30
-#
-# The path to the directories where data and meta data files are stored
-#
-SpoolDir=/opt/app/datartr/spool
-#
-# The path to the redirection data file
-#
-#RedirectionFile: etc/redirections.dat
-#
-# The type of keystore for https
-#
-KeyStoreType: jks
-#
-# The path to the keystore for https
-#
-KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks
-#
-# The password for the https keystore
-#
-KeyStorePassword=changeit
-#
-# The password for the private key in the https keystore
-#
-KeyPassword=changeit
-#
-# The type of truststore for https
-#
-TrustStoreType=jks
-#
-# The path to the truststore for https
-#
-#TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
-TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks
-#
-# The password for the https truststore
-#
-TrustStorePassword=changeit
-#
-# The path to the file used to trigger an orderly shutdown
-#
-QuiesceFile=etc/SHUTDOWN
-#
-# The key used to generate passwords for node to node transfers
-#
-NodeAuthKey=Node123!
-
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright 2017 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.
+# * 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.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+#
+# Configuration parameters fixed at startup for the DataRouter node
+#
+# URL to retrieve dynamic configuration
+#
+#ProvisioningURL: ${DRTR_PROV_INTURL}
+ProvisioningURL=https://dmaap-dr-prov:8443/internal/prov
+
+#
+# URL to upload PUB/DEL/EXP logs
+#
+#LogUploadURL: ${DRTR_LOG_URL}
+LogUploadURL=https://dmaap-dr-prov:8443/internal/logs
+
+#
+# The port number for http as seen within the server
+#
+#IntHttpPort: ${DRTR_NODE_INTHTTPPORT:-8080}
+IntHttpPort=8080
+#
+# The port number for https as seen within the server
+#
+IntHttpsPort=8443
+#
+# The external port number for https taking port mapping into account
+#
+ExtHttpsPort=443
+#
+# The minimum interval between fetches of the dynamic configuration
+# from the provisioning server
+#
+MinProvFetchInterval=10000
+#
+# The minimum interval between saves of the redirection data file
+#
+MinRedirSaveInterval=10000
+#
+# The path to the directory where log files are stored
+#
+LogDir=/opt/app/datartr/logs
+#
+# The retention interval (in days) for log files
+#
+LogRetention=30
+#
+# The path to the directories where data and meta data files are stored
+#
+SpoolDir=/opt/app/datartr/spool
+#
+# The path to the redirection data file
+#
+#RedirectionFile: etc/redirections.dat
+#
+# The type of keystore for https
+KeyStoreType: jks
+#
+# The path to the keystore for https
+#
+KeyStoreFile:/opt/app/datartr/aaf_certs/org.onap.dmaap-dr.jks
+#
+# The password for the https keystore
+#
+KeyStorePassword=4*&GD+w58RUM]01No.CYY;z6
+#
+# The password for the private key in the https keystore
+#
+KeyPassword=4*&GD+w58RUM]01No.CYY;z6
+#
+# The type of truststore for https
+#
+TrustStoreType=jks
+#
+# The path to the truststore for https
+#
+#TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
+TrustStoreFile=/opt/app/datartr/aaf_certs/org.onap.dmaap-dr.trust.jks
+#
+# The password for the https truststore
+#
+TrustStorePassword=UDXlT6Iu[F)k,Htk92+B,0Xj
+#
+# The path to the file used to trigger an orderly shutdown
+#
+QuiesceFile=etc/SHUTDOWN
+#
+# The key used to generate passwords for node to node transfers
+#
+NodeAuthKey=Node123!
+
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java
new file mode 100644
index 00000000..97904a5e
--- /dev/null
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package org.onap.dmaap.datarouter.node;
+import org.apache.commons.lang3.reflect.FieldUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import static org.junit.Assert.*;
+import java.io.File;
+
+
+
+import static org.mockito.Mockito.*;
+
+@RunWith(PowerMockRunner.class)
+public class DeliveryQueueTest {
+
+ private DeliveryQueue deliveryQueue;
+ @Mock
+ private DestInfo destInfo;
+ @Mock
+ DeliveryQueueHelper deliveryQueueHelper;
+
+ private String dirPath = "/tmp/dir001/";
+ private String FileName1 = "10000000000004.fileName.M";
+
+ @Before
+ public void setUp() {
+ when(destInfo.getSpool()).thenReturn("tmp");
+ deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo);
+ }
+
+ @Test
+ public void Given_New_DeliveryQueue_Directory_Is_Created_As_Defined_By_DestInfo() throws Exception {
+ when(destInfo.getSpool()).thenReturn("tmp");
+ File file = new File("tmp");
+ assertTrue(file.exists());
+ deleteFile("tmp");
+ }
+
+ @Test
+ public void Given_Delivery_Task_Failed_And_Resume_Time_Not_Reached_Return_Null() throws Exception{
+ FieldUtils.writeField(deliveryQueue,"failed",true,true);
+ FieldUtils.writeField(deliveryQueue,"resumetime",System.currentTimeMillis()*2,true);
+ assertNull(deliveryQueue.peekNext());
+ }
+
+ @Test
+ public void Given_Delivery_Task_Return_Next_Delivery_Task_Id() throws Exception{
+ prepareFiles();
+ when(destInfo.getSpool()).thenReturn(dirPath);
+ deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo);
+ DeliveryTask nt = deliveryQueue.getNext();
+ assertEquals("10000000000004.fileName", nt.getPublishId());
+ deleteFile(dirPath + FileName1);
+ deleteFile(dirPath);
+ }
+
+ @Test
+ public void Given_Delivery_Task_Cancel_And_FileId_Is_Null_Return_Zero() throws Exception{
+ long rc = deliveryQueue.cancelTask("123.node.datarouternew.com");
+ assertEquals(0, rc);
+ }
+
+ private void prepareFiles() throws Exception{
+ createFolder(dirPath);
+ createFile(FileName1, dirPath);
+ String[] files = new String[2];
+ files[0] = dirPath + FileName1;
+ }
+
+ private void createFolder(String dirName) throws Exception{
+ String dirPath = dirName;
+
+ File newDirectory = new File(dirPath);
+ boolean isCreated = newDirectory.mkdirs();
+ if (isCreated) {
+ System.out.println("1. Successfully created directories, path: " + newDirectory.getCanonicalPath());
+ } else if (newDirectory.exists()) {
+ System.out.printf("1. Directory path already exist, path: " + newDirectory.getCanonicalPath());
+ } else {
+ System.out.println("1. Unable to create directory");
+ }
+ }
+
+ private void createFile( String file, String dir) throws Exception{
+ String FileName = file;
+ String dirPath = dir;
+
+ File newFile = new File(dirPath + File.separator + FileName);
+ boolean isCreated = newFile.createNewFile();
+ if (isCreated) {
+ System.out.println("\n2. Successfully created new file, path: " + newFile.getCanonicalPath());
+ } else { //File may already exist
+ System.out.println("\n2. Unable to create new file: " + newFile.getCanonicalPath());
+ }
+ }
+
+ private void deleteFile(String fileName) {
+ File file = new File(fileName);
+
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+
+} \ No newline at end of file
diff --git a/datarouter-prov/aaf_certs/org.onap.dmaap-dr.jks b/datarouter-prov/aaf_certs/org.onap.dmaap-dr.jks
new file mode 100755
index 00000000..155991ab
--- /dev/null
+++ b/datarouter-prov/aaf_certs/org.onap.dmaap-dr.jks
Binary files differ
diff --git a/datarouter-prov/aaf_certs/org.onap.dmaap-dr.trust.jks b/datarouter-prov/aaf_certs/org.onap.dmaap-dr.trust.jks
new file mode 100755
index 00000000..c8f9ee66
--- /dev/null
+++ b/datarouter-prov/aaf_certs/org.onap.dmaap-dr.trust.jks
Binary files differ
diff --git a/datarouter-prov/pom.xml b/datarouter-prov/pom.xml
index b3c28782..84731413 100755
--- a/datarouter-prov/pom.xml
+++ b/datarouter-prov/pom.xml
@@ -277,7 +277,7 @@
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
- <include>**/proserver.properties</include>
+ <include>**/provserver.properties</include>
</includes>
</resource>
<resource>
@@ -426,10 +426,10 @@
<goal>copy-resources</goal>
</goals>
<configuration>
- <outputDirectory>${basedir}/target/opt/app/datartr/self_signed</outputDirectory>
+ <outputDirectory>${basedir}/target/opt/app/datartr/aaf_certs</outputDirectory>
<resources>
<resource>
- <directory>${basedir}/self_signed</directory>
+ <directory>${basedir}/aaf_certs</directory>
<includes>
<include>misc/**</include>
<include>**/**</include>
diff --git a/datarouter-prov/self_signed/cacerts.jks b/datarouter-prov/self_signed/cacerts.jks
deleted file mode 100644
index 76a480ad..00000000
--- a/datarouter-prov/self_signed/cacerts.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/self_signed/keystore.jks b/datarouter-prov/self_signed/keystore.jks
deleted file mode 100644
index 2c22b4ac..00000000
--- a/datarouter-prov/self_signed/keystore.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/self_signed/mykey.cer b/datarouter-prov/self_signed/mykey.cer
deleted file mode 100644
index 2a5c9d70..00000000
--- a/datarouter-prov/self_signed/mykey.cer
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
index 412e1322..047043b1 100644..100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
@@ -319,7 +319,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
* @return an error string, or null if all is OK
*/
String isAuthorizedForProvisioning(HttpServletRequest request) {
- if (Boolean.parseBoolean(isAddressAuthEnabled)) {
+ if (!Boolean.parseBoolean(isAddressAuthEnabled)) {
return null;
}
// Is the request https?
@@ -369,7 +369,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
boolean isAuthorizedForInternal(HttpServletRequest request) {
try {
- if (Boolean.parseBoolean(isAddressAuthEnabled)) {
+ if (!Boolean.parseBoolean(isAddressAuthEnabled)) {
return true;
}
InetAddress ip = InetAddress.getByName(request.getRemoteAddr());
@@ -492,9 +492,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
// Normalize the nodes, and fill in nodeAddresses
InetAddress[] na = new InetAddress[nodes.length];
for (int i = 0; i < nodes.length; i++) {
- if (nodes[i].indexOf('.') < 0) {
- nodes[i] += "." + provDomain;
- }
try {
na[i] = InetAddress.getByName(nodes[i]);
intlogger.debug("PROV0003 DNS lookup: " + nodes[i] + " => " + na[i].toString());
@@ -520,9 +517,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
String[] pods = getPods();
na = new InetAddress[pods.length];
for (int i = 0; i < pods.length; i++) {
- if (pods[i].indexOf('.') < 0) {
- pods[i] += "." + provDomain;
- }
try {
na[i] = InetAddress.getByName(pods[i]);
intlogger.debug("PROV0003 DNS lookup: " + pods[i] + " => " + na[i].toString());
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
index 8614a6e8..101c9e6f 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/LogServlet.java
@@ -417,13 +417,13 @@ public class LogServlet extends BaseServlet {
Connection conn = null;
try {
conn = db.getConnection();
- Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery(sql);
- while (rs.next()) {
- rh.handleRow(rs);
- }
- rs.close();
- stmt.close();
+ try( Statement stmt = conn.createStatement()){
+ try(ResultSet rs = stmt.executeQuery(sql)){
+ while (rs.next()) {
+ rh.handleRow(rs);
+ }
+ }
+ }
} catch (SQLException sqlException) {
intlogger.info("Failed to get Records. Exception = " +sqlException.getMessage(),sqlException);
} finally {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
index 87979be6..800bd9af 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
@@ -185,8 +185,6 @@ public class Main {
sslContextFactory.setTrustStorePath(DEFAULT_TRUSTSTORE);
sslContextFactory.setTrustStorePassword("changeit");
}
- sslContextFactory.setTrustStorePath("/opt/app/datartr/self_signed/cacerts.jks");
- sslContextFactory.setTrustStorePassword("changeit");
sslContextFactory.setWantClientAuth(true);
// Servlet and Filter configuration
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
index 6564e175..8d6bfcf0 100644..100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
@@ -35,12 +35,10 @@ import java.security.KeyStoreException;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
-
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
@@ -57,16 +55,16 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
/**
- * This class is the base class for those servlets that need to proxy their requests from the
- * standby to active server. Its methods perform the proxy function to the active server. If the
- * active server is not reachable, a 503 (SC_SERVICE_UNAVAILABLE) is returned. Only
- * DELETE/GET/PUT/POST are supported.
+ * This class is the base class for those servlets that need to proxy their requests from the standby to active server.
+ * Its methods perform the proxy function to the active server. If the active server is not reachable, a 503
+ * (SC_SERVICE_UNAVAILABLE) is returned. Only DELETE/GET/PUT/POST are supported.
*
* @author Robert Eby
* @version $Id: ProxyServlet.java,v 1.3 2014/03/24 18:47:10 eby Exp $
*/
@SuppressWarnings("serial")
public class ProxyServlet extends BaseServlet {
+
private boolean inited = false;
private Scheme sch;
@@ -80,13 +78,13 @@ public class ProxyServlet extends BaseServlet {
try {
// Set up keystore
Properties props = (new DB()).getProperties();
- String type = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
+ String type = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
String store = props.getProperty(Main.KEYSTORE_PATH_PROPERTY);
- String pass = props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY);
+ String pass = props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY);
KeyStore keyStore = readStore(store, pass, type);
store = props.getProperty(Main.TRUSTSTORE_PATH_PROPERTY);
- pass = props.getProperty(Main.TRUSTSTORE_PASSWORD_PROPERTY);
+ pass = props.getProperty(Main.TRUSTSTORE_PASSWORD_PROPERTY);
if (store == null || store.length() == 0) {
store = Main.DEFAULT_TRUSTSTORE;
pass = "changeit";
@@ -95,30 +93,34 @@ public class ProxyServlet extends BaseServlet {
// We are connecting with the node name, but the certificate will have the CNAME
// So we need to accept a non-matching certificate name
- SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, "changeit", trustStore);
+ SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore,
+ props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY), trustStore);
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
sch = new Scheme("https", 443, socketFactory);
inited = true;
} catch (Exception e) {
e.printStackTrace();
}
- intlogger.info("ProxyServlet: inited = "+inited);
+ intlogger.info("ProxyServlet: inited = " + inited);
}
- private KeyStore readStore(String store, String pass, String type) throws KeyStoreException, FileNotFoundException {
+
+ private KeyStore readStore(String store, String pass, String type) throws KeyStoreException {
KeyStore ks = KeyStore.getInstance(type);
- FileInputStream instream = new FileInputStream(new File(store));
- try {
+ try (FileInputStream instream = new FileInputStream(new File(store))) {
ks.load(instream, pass.toCharArray());
+ } catch (FileNotFoundException fileNotFoundException) {
+ System.err.println("ProxyServlet: " + fileNotFoundException);
+ fileNotFoundException.printStackTrace();
} catch (Exception x) {
- System.err.println("READING TRUSTSTORE: "+x);
- } finally {
- try { instream.close(); } catch (Exception ignore) {}
+ System.err.println("READING TRUSTSTORE: " + x);
}
return ks;
}
+
/**
- * Return <i>true</i> if the requester has NOT set the <i>noproxy</i> CGI variable.
- * If they have, this indicates they want to forcibly turn the proxy off.
+ * Return <i>true</i> if the requester has NOT set the <i>noproxy</i> CGI variable. If they have, this indicates
+ * they want to forcibly turn the proxy off.
+ *
* @param req the HTTP request
* @return true or false
*/
@@ -127,22 +129,25 @@ public class ProxyServlet extends BaseServlet {
if (t != null) {
t = t.replaceAll("&amp;", "&");
for (String s : t.split("&")) {
- if (s.equals("noproxy") || s.startsWith("noproxy="))
+ if (s.equals("noproxy") || s.startsWith("noproxy=")) {
return false;
+ }
}
}
return true;
}
+
/**
- * Is this the standby server? If it is, the proxy functions can be used.
- * If not, the proxy functions should not be called, and will send a response of 500
- * (Internal Server Error).
+ * Is this the standby server? If it is, the proxy functions can be used. If not, the proxy functions should not be
+ * called, and will send a response of 500 (Internal Server Error).
+ *
* @return true if this server is the standby (and hence a proxy server).
*/
public boolean isProxyServer() {
SynchronizerTask st = SynchronizerTask.getSynchronizer();
return st.getState() == SynchronizerTask.STANDBY;
}
+
/**
* Issue a proxy DELETE to the active provisioning server.
*/
@@ -150,6 +155,7 @@ public class ProxyServlet extends BaseServlet {
public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "DELETE");
}
+
/**
* Issue a proxy GET to the active provisioning server.
*/
@@ -157,6 +163,7 @@ public class ProxyServlet extends BaseServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "GET");
}
+
/**
* Issue a proxy PUT to the active provisioning server.
*/
@@ -164,6 +171,7 @@ public class ProxyServlet extends BaseServlet {
public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "PUT");
}
+
/**
* Issue a proxy POST to the active provisioning server.
*/
@@ -171,123 +179,136 @@ public class ProxyServlet extends BaseServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "POST");
}
+
/**
- * Issue a proxy GET to the active provisioning server. Unlike doGet() above,
- * this method will allow the caller to fall back to other code if the remote server is unreachable.
+ * Issue a proxy GET to the active provisioning server. Unlike doGet() above, this method will allow the caller to
+ * fall back to other code if the remote server is unreachable.
+ *
* @return true if the proxy succeeded
*/
public boolean doGetWithFallback(HttpServletRequest req, HttpServletResponse resp) throws IOException {
boolean rv = false;
if (inited) {
String url = buildUrl(req);
- intlogger.info("ProxyServlet: proxying with fallback GET "+url);
- AbstractHttpClient httpclient = new DefaultHttpClient();
- HttpRequestBase proxy = new HttpGet(url);
- try {
- httpclient.getConnectionManager().getSchemeRegistry().register(sch);
-
- // Copy request headers and request body
- copyRequestHeaders(req, proxy);
-
- // Execute the request
- HttpResponse pxy_response = httpclient.execute(proxy);
-
- // Get response headers and body
- int code = pxy_response.getStatusLine().getStatusCode();
- resp.setStatus(code);
- copyResponseHeaders(pxy_response, resp);
-
- HttpEntity entity = pxy_response.getEntity();
- if (entity != null) {
- InputStream in = entity.getContent();
- IOUtils.copy(in, resp.getOutputStream());
- in.close();
+ intlogger.info("ProxyServlet: proxying with fallback GET " + url);
+ try (AbstractHttpClient httpclient = new DefaultHttpClient()) {
+ HttpRequestBase proxy = new HttpGet(url);
+ try {
+ httpclient.getConnectionManager().getSchemeRegistry().register(sch);
+
+ // Copy request headers and request body
+ copyRequestHeaders(req, proxy);
+
+ // Execute the request
+ HttpResponse pxy_response = httpclient.execute(proxy);
+
+ // Get response headers and body
+ int code = pxy_response.getStatusLine().getStatusCode();
+ resp.setStatus(code);
+ copyResponseHeaders(pxy_response, resp);
+
+ HttpEntity entity = pxy_response.getEntity();
+ if (entity != null) {
+ InputStream in = entity.getContent();
+ IOUtils.copy(in, resp.getOutputStream());
+ in.close();
+ }
+ rv = true;
+
+ } catch (IOException e) {
+ System.err.println("ProxyServlet: " + e);
+ e.printStackTrace();
+ } finally {
+ proxy.releaseConnection();
+ httpclient.getConnectionManager().shutdown();
}
- rv = true;
- } catch (IOException e) {
- System.err.println("ProxyServlet: "+e);
- e.printStackTrace();
- } finally {
- proxy.releaseConnection();
- httpclient.getConnectionManager().shutdown();
}
} else {
intlogger.warn("ProxyServlet: proxy disabled");
}
return rv;
}
+
private void doProxy(HttpServletRequest req, HttpServletResponse resp, final String method) throws IOException {
if (inited && isProxyServer()) {
String url = buildUrl(req);
- intlogger.info("ProxyServlet: proxying "+method + " "+url);
- AbstractHttpClient httpclient = new DefaultHttpClient();
- ProxyHttpRequest proxy = new ProxyHttpRequest(method, url);
- try {
- httpclient.getConnectionManager().getSchemeRegistry().register(sch);
-
- // Copy request headers and request body
- copyRequestHeaders(req, proxy);
- if (method.equals("POST") || method.equals("PUT")){
- BasicHttpEntity body = new BasicHttpEntity();
- body.setContent(req.getInputStream());
- body.setContentLength(-1); // -1 = unknown
- proxy.setEntity(body);
- }
+ intlogger.info("ProxyServlet: proxying " + method + " " + url);
+ try (AbstractHttpClient httpclient = new DefaultHttpClient()) {
+ ProxyHttpRequest proxy = new ProxyHttpRequest(method, url);
+ try {
+ httpclient.getConnectionManager().getSchemeRegistry().register(sch);
+
+ // Copy request headers and request body
+ copyRequestHeaders(req, proxy);
+ if (method.equals("POST") || method.equals("PUT")) {
+ BasicHttpEntity body = new BasicHttpEntity();
+ body.setContent(req.getInputStream());
+ body.setContentLength(-1); // -1 = unknown
+ proxy.setEntity(body);
+ }
- // Execute the request
- HttpResponse pxy_response = httpclient.execute(proxy);
+ // Execute the request
+ HttpResponse pxy_response = httpclient.execute(proxy);
- // Get response headers and body
- int code = pxy_response.getStatusLine().getStatusCode();
- resp.setStatus(code);
- copyResponseHeaders(pxy_response, resp);
+ // Get response headers and body
+ int code = pxy_response.getStatusLine().getStatusCode();
+ resp.setStatus(code);
+ copyResponseHeaders(pxy_response, resp);
- HttpEntity entity = pxy_response.getEntity();
- if (entity != null) {
- InputStream in = entity.getContent();
- IOUtils.copy(in, resp.getOutputStream());
- in.close();
+ HttpEntity entity = pxy_response.getEntity();
+ if (entity != null) {
+ InputStream in = entity.getContent();
+ IOUtils.copy(in, resp.getOutputStream());
+ in.close();
+ }
+ } catch (IOException e) {
+ intlogger.warn("ProxyServlet: " + e);
+ resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
+ e.printStackTrace();
+ } finally {
+ proxy.releaseConnection();
+ httpclient.getConnectionManager().shutdown();
}
- } catch (IOException e) {
- intlogger.warn("ProxyServlet: "+e);
- resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
- e.printStackTrace();
- } finally {
- proxy.releaseConnection();
- httpclient.getConnectionManager().shutdown();
}
} else {
intlogger.warn("ProxyServlet: proxy disabled");
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
+
private String buildUrl(HttpServletRequest req) {
StringBuilder sb = new StringBuilder("https://");
sb.append(URLUtilities.getPeerPodName());
sb.append(req.getRequestURI());
String q = req.getQueryString();
- if (q != null)
+ if (q != null) {
sb.append("?").append(q);
+ }
return sb.toString();
}
+
private void copyRequestHeaders(HttpServletRequest from, HttpRequestBase to) {
@SuppressWarnings("unchecked")
List<String> list = Collections.list(from.getHeaderNames());
for (String name : list) {
// Proxy code will add this one
- if (!name.equalsIgnoreCase("Content-Length"))
+ if (!name.equalsIgnoreCase("Content-Length")) {
to.addHeader(name, from.getHeader(name));
+ }
}
}
+
private void copyResponseHeaders(HttpResponse from, HttpServletResponse to) {
for (Header hdr : from.getAllHeaders()) {
// Don't copy Date: our Jetty will add another Date header
- if (!hdr.getName().equals("Date"))
+ if (!hdr.getName().equals("Date")) {
to.addHeader(hdr.getName(), hdr.getValue());
+ }
}
}
public class ProxyHttpRequest extends HttpEntityEnclosingRequestBase {
+
private final String method;
public ProxyHttpRequest(final String method, final String uri) {
@@ -295,6 +316,7 @@ public class ProxyServlet extends BaseServlet {
this.method = method;
setURI(URI.create(uri));
}
+
@Override
public String getMethod() {
return method;
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
index 4c140490..f3eb1eb6 100644..100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
@@ -32,7 +32,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-
import org.apache.log4j.Logger;
import org.onap.dmaap.datarouter.provisioning.utils.DB;
@@ -43,6 +42,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @version $Id: NodeClass.java,v 1.2 2014/01/15 16:08:43 eby Exp $
*/
public abstract class NodeClass extends Syncable {
+
private static Map<String, Integer> map;
private static Logger intLogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
public NodeClass() {
@@ -53,19 +53,20 @@ public abstract class NodeClass extends Syncable {
}
/**
- * Add nodes to the NODES table, when the NODES parameter value is changed.
- * Nodes are only added to the table, they are never deleted. The node name is normalized
- * to contain the domain (if missing).
+ * Add nodes to the NODES table, when the NODES parameter value is changed. Nodes are only added to the table, they
+ * are never deleted. The node name is normalized to contain the domain (if missing).
*
* @param nodes a pipe separated list of the current nodes
*/
public static void setNodes(String[] nodes) {
- if (map == null)
+ if (map == null) {
reload();
+ }
int nextid = 0;
for (Integer n : map.values()) {
- if (n >= nextid)
+ if (n >= nextid) {
nextid = n + 1;
+ }
}
// take | separated list, add domain if needed.
@@ -136,8 +137,9 @@ public abstract class NodeClass extends Syncable {
public static Integer lookupNodeName(final String name) {
Integer n = map.get(name);
- if (n == null)
+ if (n == null) {
throw new IllegalArgumentException("Invalid node name: " + name);
+ }
return n;
}
@@ -148,8 +150,9 @@ public abstract class NodeClass extends Syncable {
if (s.endsWith("*")) {
s = s.substring(0, s.length() - 1);
for (String s2 : keyset) {
- if (s2.startsWith(s))
+ if (s2.startsWith(s)) {
coll.add(s2);
+ }
}
} else if (keyset.contains(s)) {
coll.add(s);
@@ -162,14 +165,6 @@ public abstract class NodeClass extends Syncable {
return coll;
}
- protected String lookupNodeID(int n) {
- for (String s : map.keySet()) {
- if (map.get(s) == n)
- return s;
- }
- return null;
- }
-
public static String normalizeNodename(String s) {
if (s != null && s.indexOf('.') <= 0) {
Parameters p = Parameters.getParameter(Parameters.PROV_DOMAIN);
@@ -184,4 +179,13 @@ public abstract class NodeClass extends Syncable {
}
}
+
+ protected String lookupNodeID(int n) {
+ for (String s : map.keySet()) {
+ if (map.get(s) == n) {
+ return s;
+ }
+ }
+ return null;
+ }
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java
index a907a03b..bbcacb53 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DB.java
@@ -38,14 +38,12 @@ import java.util.*;
*/
public class DB {
- /**
- * The name of the properties file (in CLASSPATH)
- */
+ private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
+
private static String DB_URL;
private static String DB_LOGIN;
private static String DB_PASSWORD;
private static Properties props;
- private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
private static final Queue<Connection> queue = new LinkedList<>();
public static String HTTPS_PORT;
diff --git a/datarouter-prov/src/main/resources/docker-compose/node_data/node.properties b/datarouter-prov/src/main/resources/docker-compose/node_data/node.properties
deleted file mode 100644
index 48485023..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/node_data/node.properties
+++ /dev/null
@@ -1,112 +0,0 @@
-#-------------------------------------------------------------------------------
-# ============LICENSE_START==================================================
-# * org.onap.dmaap
-# * ===========================================================================
-# * Copyright 2017 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.
-# * 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.
-# * ============LICENSE_END====================================================
-# *
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# *
-#-------------------------------------------------------------------------------
-#
-# Configuration parameters fixed at startup for the DataRouter node
-#
-# URL to retrieve dynamic configuration
-#
-#ProvisioningURL: ${DRTR_PROV_INTURL:-https://feeds-drtr.web.att.com/internal/prov}
-ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov
-
-#
-# URL to upload PUB/DEL/EXP logs
-#
-#LogUploadURL: ${DRTR_LOG_URL:-https://feeds-drtr.web.att.com/internal/logs}
-LogUploadURL=https://prov.datarouternew.com:8443/internal/logs
-
-#
-# The port number for http as seen within the server
-#
-#IntHttpPort: ${DRTR_NODE_INTHTTPPORT:-8080}
-IntHttpPort=8080
-#
-# The port number for https as seen within the server
-#
-IntHttpsPort=8443
-#
-# The external port number for https taking port mapping into account
-#
-ExtHttpsPort=443
-#
-# The minimum interval between fetches of the dynamic configuration
-# from the provisioning server
-#
-MinProvFetchInterval=10000
-#
-# The minimum interval between saves of the redirection data file
-#
-MinRedirSaveInterval=10000
-#
-# The path to the directory where log files are stored
-#
-LogDir=/opt/app/datartr/logs
-#
-# The retention interval (in days) for log files
-#
-LogRetention=30
-#
-# The path to the directories where data and meta data files are stored
-#
-SpoolDir=/opt/app/datartr/spool
-#
-# The path to the redirection data file
-#
-#RedirectionFile: etc/redirections.dat
-#
-# The type of keystore for https
-#
-KeyStoreType: jks
-#
-# The path to the keystore for https
-#
-KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks
-#
-# The password for the https keystore
-#
-KeyStorePassword=changeit
-#
-# The password for the private key in the https keystore
-#
-KeyPassword=changeit
-#
-# The type of truststore for https
-#
-TrustStoreType=jks
-#
-# The path to the truststore for https
-#
-#TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
-TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks
-#
-# The password for the https truststore
-#
-TrustStorePassword=changeit
-#
-# The path to the file used to trigger an orderly shutdown
-#
-QuiesceFile=etc/SHUTDOWN
-#
-# The key used to generate passwords for node to node transfers
-#
-NodeAuthKey=Node123!
-
diff --git a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/cacerts.jks b/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/cacerts.jks
deleted file mode 100644
index dfd81433..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/cacerts.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/keystore.jks b/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/keystore.jks
deleted file mode 100644
index e5a4e781..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/keystore.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/mykey.cer b/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/mykey.cer
deleted file mode 100644
index 2a5c9d70..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/mykey.cer
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/nodekey.cer b/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/nodekey.cer
deleted file mode 100644
index 4cdfdfe3..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/node_data/self_signed/nodekey.cer
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/cacerts.jks b/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/cacerts.jks
deleted file mode 100644
index 76a480ad..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/cacerts.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/keystore.jks b/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/keystore.jks
deleted file mode 100644
index 2c22b4ac..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/keystore.jks
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/mykey.cer b/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/mykey.cer
deleted file mode 100644
index 2a5c9d70..00000000
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/self_signed/mykey.cer
+++ /dev/null
Binary files differ
diff --git a/datarouter-prov/src/main/resources/misc/sql_init_01.sql b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
index e01ce3b0..356a67a9 100644..100755
--- a/datarouter-prov/src/main/resources/misc/sql_init_01.sql
+++ b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
@@ -124,18 +124,18 @@ CREATE TABLE GROUPS (
);
INSERT INTO PARAMETERS VALUES
- ('ACTIVE_POD', 'prov.datarouternew.com'),
- ('PROV_ACTIVE_NAME', 'prov.datarouternew.com'),
+ ('ACTIVE_POD', 'dmaap-dr-prov'),
+ ('PROV_ACTIVE_NAME', 'dmaap-dr-prov'),
('STANDBY_POD', ''),
- ('PROV_NAME', 'prov.datarouternew.com'),
- ('NODES', '172.100.0.1|node.datarouternew.com'),
- ('PROV_DOMAIN', 'datarouternew.com'),
+ ('PROV_NAME', 'dmaap-dr-prov'),
+ ('NODES', 'dmaap-dr-node'),
+ ('PROV_DOMAIN', ''),
('DELIVERY_INIT_RETRY_INTERVAL', '10'),
('DELIVERY_MAX_AGE', '86400'),
('DELIVERY_MAX_RETRY_INTERVAL', '3600'),
('DELIVERY_RETRY_RATIO', '2'),
('LOGROLL_INTERVAL', '300'),
- ('PROV_AUTH_ADDRESSES', '172.100.0.1|prov.datarouternew.com|node.datarouternew.com'),
+ ('PROV_AUTH_ADDRESSES', 'dmaap-dr-prov|dmaap-dr-node'),
('PROV_AUTH_SUBJECTS', ''),
('PROV_MAXFEED_COUNT', '10000'),
('PROV_MAXSUB_COUNT', '100000'),
diff --git a/datarouter-prov/src/main/resources/provserver.properties b/datarouter-prov/src/main/resources/provserver.properties
index 7758a64d..744bc9ce 100644..100755
--- a/datarouter-prov/src/main/resources/provserver.properties
+++ b/datarouter-prov/src/main/resources/provserver.properties
@@ -27,11 +27,11 @@ org.onap.dmaap.datarouter.provserver.https.port = 8443
org.onap.dmaap.datarouter.provserver.https.relaxation = true
org.onap.dmaap.datarouter.provserver.keystore.type = jks
-org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
-org.onap.dmaap.datarouter.provserver.keystore.path = /opt/app/datartr/self_signed/keystore.jks
-org.onap.dmaap.datarouter.provserver.keystore.password = changeit
-org.onap.dmaap.datarouter.provserver.truststore.path = /opt/app/datartr/self_signed/cacerts.jks
-org.onap.dmaap.datarouter.provserver.truststore.password = changeit
+org.onap.dmaap.datarouter.provserver.keymanager.password = Qgw77oaQcdP*F8Pwa[&.,.Ab
+org.onap.dmaap.datarouter.provserver.keystore.path = /opt/app/datartr/aaf_certs/org.onap.dmaap-dr.jks
+org.onap.dmaap.datarouter.provserver.keystore.password = Qgw77oaQcdP*F8Pwa[&.,.Ab
+org.onap.dmaap.datarouter.provserver.truststore.path = /opt/app/datartr/aaf_certs/org.onap.dmaap-dr.trust.jks
+org.onap.dmaap.datarouter.provserver.truststore.password = 9M?)?:KAj1z6gpLhNrVUG@0T
org.onap.dmaap.datarouter.provserver.accesslog.dir = /opt/app/datartr/logs
org.onap.dmaap.datarouter.provserver.spooldir = /opt/app/datartr/spool
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java
index 71446219..3e5e1d04 100644..100755
--- a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java
+++ b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java
@@ -114,7 +114,7 @@ public class IntegrationTestBase {
}
}
- SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, "changeit", trustStore);
+ SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, props.getProperty("test.kspassword"), trustStore);
Scheme sch = new Scheme("https", 443, socketFactory);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
@@ -164,7 +164,7 @@ public class IntegrationTestBase {
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
- FileUtils.deleteDirectory(new File("./unit-test-logs"));
+ FileUtils.deleteDirectory(new File("." + File.pathSeparator+ "unit-test-logs"));
}
protected void ckResponse(HttpResponse response, int expect) {
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
index 61d030d9..8cc48683 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
@@ -40,6 +40,7 @@ import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.mock;
@@ -84,7 +85,7 @@ public class BaseServletTest extends DrServletTestBase {
authAddressesAndNetworks.add(("127.0.0.1"));
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "authorizedAddressesAndNetworks", authAddressesAndNetworks, true);
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "requireCert", true, true);
- assertThat(baseServlet.isAuthorizedForProvisioning(request), is("Client certificate is missing."));
+ assertNull(baseServlet.isAuthorizedForProvisioning(request));
}
@Test
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
index 35bc85d8..87390bc5 100644..100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
@@ -22,6 +22,21 @@
******************************************************************************/
package org.onap.dmaap.datarouter.provisioning;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.argThat;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
@@ -38,20 +53,11 @@ import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Mockito.*;
-import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
-
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.provisioning.beans.Feed")
public class DRFeedsServletTest extends DrServletTestBase {
+
private static DRFeedsServlet drfeedsServlet;
@Mock
@@ -77,14 +83,17 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_GET_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
setBehalfHeader(null);
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
@@ -92,7 +101,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_GET_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
when(request.getRequestURI()).thenReturn("/123");
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
@@ -100,7 +110,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_GET_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
setAuthoriserToReturnRequestNotAuthorized();
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -146,14 +157,17 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
setBehalfHeader(null);
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
@@ -161,7 +175,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_POST_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
when(request.getRequestURI()).thenReturn("/123");
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
@@ -169,28 +184,33 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_POST_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated()
+ throws Exception {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.feed; version=1.1");
when(request.getContentType()).thenReturn("stub_contentType");
drfeedsServlet.doPost(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE), argThat(notNullValue(String.class)));
+ verify(response)
+ .sendError(eq(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
setAuthoriserToReturnRequestNotAuthorized();
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Active_Feeds_Equals_Max_Feeds_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Active_Feeds_Equals_Max_Feeds_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "maxFeeds", 0, true);
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
protected JSONObject getJSONfromInput(HttpServletRequest req) {
@@ -202,7 +222,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Feed_Is_Not_Valid_Object_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Feed_Is_Not_Valid_Object_Bad_Request_Response_Is_Generated()
+ throws Exception {
when(request.getHeader("X-ATT-DR-ON-BEHALF-OF-GROUP")).thenReturn(null);
JSONObject JSObject = buildRequestJsonObject();
@@ -218,7 +239,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Feed_Already_Exists_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Feed_Already_Exists_Bad_Request_Response_Is_Generated()
+ throws Exception {
setFeedToReturnInvalidFeedIdSupplied();
JSONObject JSObject = buildRequestJsonObject();
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
@@ -252,12 +274,14 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
};
drfeedsServlet.doPost(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class)));
+ verify(response)
+ .sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Change_On_Feeds_Succeeds_A_STATUS_OK_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Change_On_Feeds_Succeeds_A_STATUS_OK_Response_Is_Generated()
+ throws Exception {
ServletOutputStream outStream = mock(ServletOutputStream.class);
when(response.getOutputStream()).thenReturn(outStream);
JSONObject JSObject = buildRequestJsonObject();
@@ -301,7 +325,9 @@ public class DRFeedsServletTest extends DrServletTestBase {
when(request.isSecure()).thenReturn(true);
Set<String> authAddressesAndNetworks = new HashSet<String>();
authAddressesAndNetworks.add(("127.0.0.1"));
- FieldUtils.writeDeclaredStaticField(BaseServlet.class, "authorizedAddressesAndNetworks", authAddressesAndNetworks, true);
+ FieldUtils
+ .writeDeclaredStaticField(BaseServlet.class, "authorizedAddressesAndNetworks", authAddressesAndNetworks,
+ true);
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "requireCert", false, true);
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "maxFeeds", 100, true);
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
index f5302cb9..cb8a28da 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
@@ -76,6 +76,7 @@ public class FeedServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_DELETE_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
feedServlet.doDelete(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -147,6 +148,7 @@ public class FeedServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
feedServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -200,6 +202,7 @@ public class FeedServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_PUT_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
feedServlet.doPut(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
index a0831b73..fa0caea6 100644..100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
@@ -76,6 +76,7 @@ public class GroupServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
groupServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -105,6 +106,7 @@ public class GroupServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_PUT_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
groupServlet.doPut(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -184,6 +186,7 @@ public class GroupServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
groupServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
index f8342449..97900d4d 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
@@ -89,6 +89,8 @@ public class InternalServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_GET_And_Address_Not_Authorized_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
+
internalServlet.doGet(request, response);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -188,6 +190,7 @@ public class InternalServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_PUT_And_Address_Not_Authorized_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
internalServlet.doPut(request, response);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -232,6 +235,7 @@ public class InternalServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_DELETE_And_Address_Not_Authorized_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
internalServlet.doDelete(request, response);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -278,6 +282,7 @@ public class InternalServletTest extends DrServletTestBase {
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
internalServlet.doPost(request, response);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java
index 63715804..34421f52 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java
@@ -69,6 +69,7 @@ public class RouteServletTest extends DrServletTestBase
@Test
public void Given_Request_Is_HTTP_DELETE_And_Is_Not_Authorized() throws Exception {
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
routeServlet.doDelete(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -207,6 +208,7 @@ public class RouteServletTest extends DrServletTestBase
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Authorized() throws Exception {
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
routeServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -290,6 +292,7 @@ public class RouteServletTest extends DrServletTestBase
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Authorized() throws Exception {
routeServlet.doPost(request, response);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java
index 0a9632eb..0babdc47 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java
@@ -105,6 +105,8 @@ public class StatisticsServletTest extends DrServletTestBase {
when(response.getOutputStream()).thenReturn(outStream);
statisticsServlet = PowerMockito.mock(StatisticsServlet.class);
PowerMockito.doReturn(null).when(statisticsServlet, "getRecordsForSQL", anyString());
+ PowerMockito.doCallRealMethod().when(statisticsServlet, "buildMapFromRequest", anyObject());
+ PowerMockito.doCallRealMethod().when(statisticsServlet, "getTimeFromParam", anyString());
doNothing().when(statisticsServlet).rsToCSV(anyObject(), anyObject());
doCallRealMethod().when(statisticsServlet).doGet(request, response);
when(statisticsServlet.getFeedIdsByGroupId(anyInt())).thenReturn(new StringBuffer("1"));
@@ -116,10 +118,13 @@ public class StatisticsServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_GET_With_GroupId_And_FeedId_Parameters_Then_Request_Succeeds()
throws Exception {
when(request.getParameter("feedid")).thenReturn("1");
+ when(request.getParameter("statusCode")).thenReturn("500");
ServletOutputStream outStream = mock(ServletOutputStream.class);
when(response.getOutputStream()).thenReturn(outStream);
statisticsServlet = PowerMockito.mock(StatisticsServlet.class);
PowerMockito.doReturn(null).when(statisticsServlet, "getRecordsForSQL", anyString());
+ PowerMockito.doCallRealMethod().when(statisticsServlet, "buildMapFromRequest", anyObject());
+ PowerMockito.doCallRealMethod().when(statisticsServlet, "getTimeFromParam", anyString());
doNothing().when(statisticsServlet).rsToCSV(anyObject(), anyObject());
doCallRealMethod().when(statisticsServlet).doGet(request, response);
doCallRealMethod().when(statisticsServlet).queryGeneretor(anyObject());
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
index cdf96ba6..25341d42 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
@@ -81,6 +81,7 @@ public class SubscribeServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscribeServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -137,6 +138,7 @@ public class SubscribeServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscribeServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
index b42e3a76..c5660672 100644..100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
@@ -73,6 +73,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_DELETE_SC_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doDelete(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -130,6 +131,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -184,6 +186,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_PUT_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doPut(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -323,6 +326,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecordTest.java
new file mode 100644
index 00000000..69016f24
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/BaseLogRecordTest.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.dmaap.datarouter.provisioning.beans;
+
+import org.jetbrains.annotations.NotNull;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
+
+import java.text.ParseException;
+
+public class BaseLogRecordTest {
+
+ private BaseLogRecord baseLogRecord;
+
+ @Test
+ public void Validate_Constructor_Creates_Object_With_Get_Methods() throws ParseException {
+ String[] args = {"2018-08-29-10-10-10-543.", "DLX", "238465493.fileName",
+ "1", "/publish/1/fileName", "285"};
+ baseLogRecord = new BaseLogRecord(args);
+ Assert.assertEquals("238465493.fileName", baseLogRecord.getPublishId());
+ Assert.assertEquals(1, baseLogRecord.getFeedid());
+ Assert.assertEquals("", baseLogRecord.getRequestUri());
+ Assert.assertEquals("GET", baseLogRecord.getMethod());
+ Assert.assertEquals("", baseLogRecord.getContentType());
+ Assert.assertEquals(285, baseLogRecord.getContentLength());
+ }
+
+ @Test
+ public void Validate_AsJsonObject_Correct_Json_Object_After_Set_Methods() throws ParseException {
+ String[] args = {"2018-08-29-10-10-10-543.", "DEL", "238465493.fileName",
+ "1", "", "/delete/1", "DELETE", "application/octet-stream", "285"};
+ baseLogRecord = new BaseLogRecord(args);
+ baseLogRecord.setContentLength(265);
+ baseLogRecord.setEventTime(1535533810543L);
+ baseLogRecord.setPublishId("2345657324.fileName");
+ baseLogRecord.setFeedid(2);
+ baseLogRecord.setRequestUri("/delete/2");
+ baseLogRecord.setMethod("PUT");
+ baseLogRecord.setContentType("application/json");
+ LOGJSONObject baseLogRecordJson = createBaseLogRecordJson();
+ String baseLogRecordString = stripBracketFromJson(baseLogRecordJson);
+ String baseLogRecordStringObject = stripBracketFromJson(baseLogRecord.asJSONObject());
+ Assert.assertTrue(baseLogRecordStringObject.matches(baseLogRecordString));
+ }
+
+ private LOGJSONObject createBaseLogRecordJson() {
+ LOGJSONObject baseLogRecordJson = new LOGJSONObject();
+ baseLogRecordJson.put("date", "2018-08-29T[0-1][0-9]:10:10.543Z");
+ baseLogRecordJson.put("publishId", "2345657324.fileName");
+ baseLogRecordJson.put("requestURI", "/delete/2");
+ baseLogRecordJson.put("method", "PUT");
+ baseLogRecordJson.put("contentType", "application/json");
+ baseLogRecordJson.put("contentLength", 265);
+ return baseLogRecordJson;
+ }
+
+ private String stripBracketFromJson(LOGJSONObject baseLogRecordJson) {
+ String baseLogRecordString = baseLogRecordJson.toString();
+ baseLogRecordString = baseLogRecordString.substring(1, baseLogRecordString.length() - 1);
+ return baseLogRecordString;
+ }
+}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java
new file mode 100644
index 00000000..ad259a59
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.dmaap.datarouter.provisioning.beans;
+
+import org.apache.commons.lang3.reflect.FieldUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.Mockito.mock;
+
+@RunWith(PowerMockRunner.class)
+@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.provisioning.beans.Feed")
+public class IngressRouteTest {
+
+ private IngressRoute ingressRoute;
+
+ @Before
+ public void setUp() throws IllegalAccessException{
+ PowerMockito.mockStatic(Feed.class);
+ Feed feed = mock(Feed.class);
+ PowerMockito.when(Feed.getFeedById(1)).thenReturn(feed);
+ Map<String, Integer> map = new HashMap<>();
+ FieldUtils.writeDeclaredStaticField(NodeClass.class, "map", map, true);
+ }
+
+ @Test
+ public void Validate_IngressRoute_Constructors_Create_Same_Object() {
+ List<String> nodes = new ArrayList<>();
+ nodes.add("node.datarouternew.com");
+ ingressRoute = new IngressRoute(1, 1, "user1", "172.100.0.0/25", nodes);
+ JSONObject ingressRouteJson = createIngressRouteJson();
+ Assert.assertEquals(ingressRoute, new IngressRoute(ingressRouteJson));
+ }
+
+ @Test
+ public void Validate_AsJsonObject_Returns_Same_Values() {
+ List<String> nodes = new ArrayList<>();
+ nodes.add("node.datarouternew.com");
+ ingressRoute = new IngressRoute(1, 1, "user1", "172.100.0.0/25", nodes);
+ JSONObject ingressRouteJson = createIngressRouteJson();
+ Assert.assertEquals(ingressRoute.asJSONObject().toString(), ingressRouteJson.toString());
+ }
+
+ private JSONObject createIngressRouteJson() {
+ JSONObject ingressRouteJson = new JSONObject();
+ ingressRouteJson.put("seq", 1);
+ ingressRouteJson.put("feedid", 1);
+ ingressRouteJson.put("user", "user1");
+ ingressRouteJson.put("subnet", "172.100.0.0/25");
+ JSONArray nodes = new JSONArray();
+ nodes.put("node.datarouternew.com");
+ ingressRouteJson.put("node", nodes);
+ return ingressRouteJson;
+ }
+
+}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java
new file mode 100644
index 00000000..eaeb91cc
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.dmaap.datarouter.provisioning.beans;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
+
+import java.text.ParseException;
+import java.util.LinkedHashMap;
+
+public class PublishRecordTest {
+
+ private PublishRecord publishRecord;
+
+ @Before
+ public void setUp() throws ParseException {
+ String[] args = {"2018-08-29-10-10-10-543.", "PUB", "238465493.fileName",
+ "1", "/publish/1/fileName", "PUT", "application/octet-stream", "285",
+ "172.100.0.3", "user1", "301"};
+ publishRecord = new PublishRecord(args);
+ }
+
+ @Test
+ public void Validate_Contructor_Creates_Object_With_Get_Methods() {
+ Assert.assertEquals("fileName", publishRecord.getFeedFileid());
+ Assert.assertEquals("172.100.0.3", publishRecord.getRemoteAddr());
+ Assert.assertEquals("user1", publishRecord.getUser());
+ Assert.assertEquals(301, publishRecord.getStatus());
+ }
+
+ @Test
+ public void Validate_AsJsonObject_Correct_Json_Object_After_Set_Methods() {
+ publishRecord.setFeedFileid("fileName2");
+ publishRecord.setRemoteAddr("172.100.0.4");
+ publishRecord.setStatus(201);
+ publishRecord.setUser("user2");
+ LOGJSONObject publishRecordJson = createPublishRecordJson();
+ Assert.assertEquals(publishRecordJson.toString(), publishRecord.asJSONObject().toString());
+ }
+
+ private LOGJSONObject createPublishRecordJson() {
+ LinkedHashMap<String, Object> publishRecordMap = new LinkedHashMap<>();
+ publishRecordMap.put("statusCode", 201);
+ publishRecordMap.put("publishId", "238465493.fileName");
+ publishRecordMap.put("requestURI", "/publish/1/fileName");
+ publishRecordMap.put("sourceIP", "172.100.0.4");
+ publishRecordMap.put("method", "PUT");
+ publishRecordMap.put("contentType", "application/octet-stream");
+ publishRecordMap.put("endpointId", "user2");
+ publishRecordMap.put("type", "pub");
+ publishRecordMap.put("date", "2018-08-29T10:10:10.543Z");
+ publishRecordMap.put("contentLength", 285);
+ return new LOGJSONObject(publishRecordMap);
+ }
+}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLITest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLITest.java
new file mode 100755
index 00000000..dc8d4c79
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLITest.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.dmaap.datarouter.provisioning.utils;
+
+import org.apache.commons.lang3.reflect.FieldUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.StatusLine;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.impl.client.AbstractHttpClient;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(PowerMockRunner.class)
+public class DRRouteCLITest {
+
+ @Mock
+ private AbstractHttpClient httpClient;
+
+ @Mock
+ private CloseableHttpResponse httpResponse;
+
+ @Mock
+ private HttpEntity httpEntity;
+
+ @Mock
+ private StatusLine statusLine;
+
+ private DRRouteCLI drRouteCLI;
+
+ @Before
+ public void setUp() throws IllegalAccessException{
+ drRouteCLI = mock(DRRouteCLI.class);
+ doCallRealMethod().when(drRouteCLI).runCommand(anyObject());
+ FieldUtils.writeField(drRouteCLI, "server", "prov.datarouternew.com", true);
+ }
+
+ @Test
+ public void Given_Add_Egress_Then_RunCommand_Returns_True() throws Exception{
+ mockHttpClientForRestCall();
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"add", "egress", "1", "node.datarouternew.com"}));
+ }
+
+ @Test
+ public void Given_Add_Network_Then_RunCommand_Returns_True() throws Exception{
+ mockHttpClientForRestCall();
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"add", "network", "prov.datarouternew.com", "node.datarouternew.com", "172.100.0.1"}));
+ }
+
+ @Test
+ public void Given_Add_Egress_With_Incorrect_Args_Then_RunCommand_Returns_False() throws Exception{
+ mockHttpClientForRestCall();
+ Assert.assertFalse(drRouteCLI.runCommand(new String[]{"add", "egress", "1", "user1", "172.100.0.0", "node.datarouternew.com"}));
+ }
+
+ @Test
+ public void Given_Error_On_Post_Rest_Call_RunCommand_Returns_False() throws Exception{
+ mockErrorResponseFromRestCall();
+ Assert.assertFalse(drRouteCLI.runCommand(new String[]{"add", "network", "prov.datarouternew.com", "node.datarouternew.com"}));
+ }
+
+ @Test
+ public void Given_Delete_Ingress_Then_RunCommand_Returns_True() throws Exception{
+ mockHttpClientForRestCall();
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"del", "ingress", "1", "user1", "172.100.0.0"}));
+ }
+
+ @Test
+ public void Given_Delete_Egress_Then_RunCommand_Returns_True() throws Exception{
+ mockHttpClientForRestCall();
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"del", "egress", "1"}));
+ }
+
+ @Test
+ public void Given_Delete_Network_Then_RunCommand_Returns_True() throws Exception{
+ mockHttpClientForRestCall();
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"del", "network", "prov.datarouternew.com", "node.datarouternew.com"}));
+ }
+
+ @Test
+ public void Given_Delete_Ingress_With_Incorrect_Args_Then_RunCommand_Returns_False() throws Exception{
+ mockHttpClientForRestCall();
+ Assert.assertFalse(drRouteCLI.runCommand(new String[]{"del", "ingress", "prov.datarouternew.com", "node.datarouternew.com"}));
+ }
+
+ @Test
+ public void Given_Error_On_Delete_Rest_Call_RunCommand_Returns_False() throws Exception{
+ mockErrorResponseFromRestCall();
+ Assert.assertFalse(drRouteCLI.runCommand(new String[]{"del", "network", "prov.datarouternew.com", "node.datarouternew.com"}));
+ }
+
+ @Test
+ public void Given_List_Args_Then_RunCommand_Returns_True() throws Exception{
+ mockHttpClientForGetRequest();
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"list"}));
+ }
+
+ @Test
+ public void Given_Error_On_Get_Rest_Call_RunCommand_Returns_True() throws Exception{
+ mockErrorResponseFromRestCall();
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"list"}));
+ }
+
+ @Test
+ public void Given_Width_Arg_Then_RunCommand_Returns_True() {
+ Assert.assertTrue(drRouteCLI.runCommand(new String[]{"width", "130"}));
+ }
+
+ @Test
+ public void Given_Usage_Arg_Then_RunCommand_Returns_False() {
+ Assert.assertFalse(drRouteCLI.runCommand(new String[]{"usage"}));
+ }
+
+ private void mockHttpClientForRestCall() throws Exception{
+ when(httpResponse.getEntity()).thenReturn(httpEntity);
+ when(statusLine.getStatusCode()).thenReturn(200);
+ when(httpResponse.getStatusLine()).thenReturn(statusLine);
+ when(httpClient.execute(anyObject())).thenReturn(httpResponse);
+ FieldUtils.writeField(drRouteCLI, "httpclient", httpClient, true);
+ }
+
+ private void mockHttpClientForGetRequest() throws Exception{
+ mockResponseFromGet();
+ when(httpResponse.getEntity()).thenReturn(httpEntity);
+ when(statusLine.getStatusCode()).thenReturn(200);
+ when(httpResponse.getStatusLine()).thenReturn(statusLine);
+ when(httpClient.execute(anyObject())).thenReturn(httpResponse);
+ FieldUtils.writeField(drRouteCLI, "httpclient", httpClient, true);
+ }
+
+ private void mockResponseFromGet() throws IOException {
+ JSONObject response = new JSONObject();
+ response.put("ingress", addIngressObject());
+ response.put("egress", addEgressObject());
+ response.put("routing", addRoutingObject());
+ InputStream in = new ByteArrayInputStream(response.toString().getBytes());
+ when(httpEntity.getContent()).thenReturn(in);
+ }
+
+ private JSONArray addRoutingObject() {
+ JSONArray routing = new JSONArray();
+ JSONObject route = new JSONObject();
+ route.put("from", "prov.datarouternew.com");
+ route.put("to", "node.datarouternew.com");
+ route.put("via", "172.100.0.1");
+ routing.put(route);
+ return routing;
+ }
+
+ private JSONObject addEgressObject() {
+ JSONObject egress = new JSONObject();
+ egress.put("1", "node.datarouternew.com");
+ egress.put("2", "172.0.0.1");
+ return egress;
+ }
+
+ private JSONArray addIngressObject() {
+ JSONArray ingresses = new JSONArray();
+ JSONObject ingress = new JSONObject();
+ ingress.put("seq", 21);
+ ingress.put("feedid", 1);
+ ingress.put("user", "user1");
+ ingress.put("subnet", "172.0.0.0");
+ JSONArray nodes = new JSONArray();
+ nodes.put("node.datarouternew.com");
+ nodes.put("172.0.0.1");
+ ingress.put("node", nodes);
+ ingresses.put(ingress);
+ return ingresses;
+ }
+
+ private void mockErrorResponseFromRestCall() throws Exception{
+ InputStream in = new ByteArrayInputStream("<pre> Server Not Found </pre>".getBytes());
+ when(httpEntity.getContent()).thenReturn(in);
+ when(httpResponse.getEntity()).thenReturn(httpEntity);
+ when(statusLine.getStatusCode()).thenReturn(400);
+ when(httpResponse.getStatusLine()).thenReturn(statusLine);
+ when(httpClient.execute(anyObject())).thenReturn(httpResponse);
+ FieldUtils.writeField(drRouteCLI, "httpclient", httpClient, true);
+ }
+}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java
new file mode 100755
index 00000000..7cfe68f9
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java
@@ -0,0 +1,498 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package org.onap.dmaap.datarouter.provisioning.utils;
+
+import java.io.CharArrayWriter;
+import java.io.Writer;
+import org.json.JSONArray;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import java.util.HashMap;
+import java.util.Map;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+
+@RunWith(PowerMockRunner.class)
+public class LOGJSONObjectTest {
+
+ private static LOGJSONObject logJO;
+
+ @Before
+ public void setUp() throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", null);
+ logJO = new LOGJSONObject(map);
+ }
+
+ @Test
+ public void Given_Method_Is_Accumulate_And_Value_Is_Valid_Put_Value_Into_New_JSONArray()
+ throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", 3);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ logJObject.accumulate(s, null);
+ assertThat(logJObject.get("key").toString(), is("[3,null]"));
+ }
+
+ @Test
+ public void Given_Method_Is_Accumulate_And_Value_Is_Null_Dont_Add_Key_Value_Pair()
+ throws Exception {
+ String s = "key";
+ logJO.accumulate(s, null);
+ assertThat(logJO.has("key"), is(false));
+ }
+
+ @Test
+ public void Given_Method_Is_Append_And_Value_Is_Null_Append_New_Value()
+ throws Exception {
+ String s = "key";
+ double d = 2.0;
+ logJO.append(s, d);
+ assertThat(logJO.getJSONArray("key").get(0), is(2.0));
+ }
+
+
+ @Test
+ public void Given_Method_Is_DoubleToString_And_Value_Is_NaN_Return_Null()
+ throws Exception {
+ double d = 2.0;
+ assertThat(logJO.doubleToString(d), is("2"));
+ }
+
+
+ @Test
+ public void Given_Method_Is_GetBoolean_And_Value_Is_False_Return_False()
+ throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", false);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getBoolean(s), is(false));
+ }
+
+ @Test
+ public void Given_Method_Is_GetBoolean_And_Value_Is_True_Return_True()
+ throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", true);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getBoolean(s), is(true));
+ }
+
+ @Test
+ public void Given_Method_Is_GetDouble_And_Value_Is_A_Double_Return_Value()
+ throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", 2.0);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getDouble(s), is(2.0));
+ }
+
+ @Test
+ public void Given_Method_Is_GetInt_And_Value_Is_An_Int_Return_Value()
+ throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", 3);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getInt(s), is(3));
+ }
+
+ @Test
+ public void Given_Method_Is_GetJSONArray_And_Value_Is_A_JSONArray_Return_Value()
+ throws Exception {
+ JSONArray jA = new JSONArray();
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", jA);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getJSONArray(s), is(jA));
+ }
+
+ @Test
+ public void Given_Method_Is_GetJSONObject_And_Value_Is_A_JSONObject_Return_Value()
+ throws Exception {
+ LOGJSONObject logJObj = new LOGJSONObject();
+ logJObj.put("stub_key", 1);
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", logJObj);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getJSONObject(s), is(logJObj));
+ }
+
+ @Test
+ public void Given_Method_Is_GetLong_And_Value_Is_A_Long_Return_Value()
+ throws Exception {
+ long l = 5;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", l);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getLong(s), is(5L));
+ }
+
+ @Test
+ public void Given_Method_Is_getNames_And_Value_Is_A_LOGJSONObject_Return_StringArray()
+ throws Exception {
+ LOGJSONObject logJObj = new LOGJSONObject();
+ logJObj.put("name", "stub_name");
+ String[] sArray = new String[logJObj.length()];
+ sArray[0] = "name";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", sArray);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getNames(logJObj), is(sArray));
+ }
+
+ @Test
+ public void Given_Method_Is_GetString_And_Value_Is_A_String_Return_Value()
+ throws Exception {
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.getString(s), is("value"));
+ }
+
+ @Test
+ public void Given_Method_Is_Increment_And_Value_Is_Null_Put_Defualt_Value()
+ throws Exception {
+ Map<String, Object> mapResult = new HashMap<>();
+ mapResult.put("key", 1);
+ LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
+
+ String val = null;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ logJObject.increment(s);
+ assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
+ }
+
+ @Test
+ public void Given_Method_Is_Increment_And_Value_Is_An_Int_Put_Value_Plus_One()
+ throws Exception {
+ Map<String, Object> mapResult = new HashMap<>();
+ mapResult.put("key", 3);
+ LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
+
+ int val = 2;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ logJObject.increment(s);
+ assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
+ }
+
+ @Test
+ public void Given_Method_Is_Increment_And_Value_Is_A_Long_Put_Value_Plus_One()
+ throws Exception {
+ Map<String, Object> mapResult = new HashMap<>();
+ mapResult.put("key", 4L);
+ LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
+
+ long val = 3;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ logJObject.increment(s);
+ assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
+ }
+
+ @Test
+ public void Given_Method_Is_Increment_And_Value_Is_A_Double_Put_Value_Plus_One()
+ throws Exception {
+ Map<String, Object> mapResult = new HashMap<>();
+ mapResult.put("key", 5.0);
+ LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
+
+ double val = 4.0;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ logJObject.increment(s);
+ assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
+ }
+
+ @Test
+ public void Given_Method_Is_Increment_And_Value_Is_A_Float_Put_Value_Plus_One()
+ throws Exception {
+ Map<String, Object> mapResult = new HashMap<>();
+ mapResult.put("key", 5.0);
+ LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
+
+ float val = 4.0f;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ logJObject.increment(s);
+ assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
+ }
+
+ @Test
+ public void Given_Method_Is_Names_And_Object_Contains_Keys_Put_Keys_Into_New_JSONArray()
+ throws Exception {
+ JSONArray ja = new JSONArray();
+ ja.put("key");
+
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.names().get(0), is(ja.get(0)));
+ }
+
+ @Test
+ public void Given_Method_Is_NumberToString_And_Number_is_Not_Null_Return_Reformatted_Number_As_String()
+ throws Exception {
+ Number num = 3.0;
+
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.numberToString(num), is("3"));
+ }
+
+ @Test
+ public void Given_Method_Is_OptBoolean_And_Value_is_Boolean_Return_Value()
+ throws Exception {
+ boolean val = true;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optBoolean(s, false), is(true));
+ }
+
+ @Test
+ public void Given_Method_Is_OptBoolean_And_Value_is_Not_Boolean_Return_Default_Value()
+ throws Exception {
+ String val = "not_boolean";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optBoolean(s, false), is(false));
+ }
+
+ @Test
+ public void Given_Method_Is_OptDouble_And_Value_is_Double_Return_Value()
+ throws Exception {
+ double val = 2.0;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optDouble(s, 0.0), is(2.0));
+ }
+
+ @Test
+ public void Given_Method_Is_OptDouble_And_Value_is_Not_Double_Return_Default_Value()
+ throws Exception {
+ String val = "not_double";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optDouble(s, 0.0), is(0.0));
+ }
+
+ @Test
+ public void Given_Method_Is_OptInt_And_Value_is_Int_Return_Value()
+ throws Exception {
+ int val = 1;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optInt(s, 0), is(1));
+ }
+
+ @Test
+ public void Given_Method_Is_OptInt_And_Value_Is_Null_Return_Default_Value()
+ throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", null);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optInt(s, 0), is(0));
+ }
+
+ @Test
+ public void Given_Method_Is_OptLong_And_Value_is_Long_Return_Value()
+ throws Exception {
+ long val = 4;
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optLong(s, 0), is(4L));
+ }
+
+ @Test
+ public void Given_Method_Is_OptLong_And_Value_is_Not_Long_Return_Default_Value()
+ throws Exception {
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", null);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optLong(s, 0), is(0L));
+ }
+
+ @Test
+ public void Given_Method_Is_OptString_And_Value_is_String_Return_Value()
+ throws Exception {
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", val);
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.optString(s, "default_value"), is("value"));
+ }
+
+ @Test
+ public void Given_Method_Is_putOnce_And_KeyValuePair_Does_Not_Exist_In_logJObject_Put_KeyValuePair_Into_logJObject()
+ throws Exception {
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ String s = "key";
+ assertThat(logJObject.putOnce(s, val).get("key"), is("value"));
+ }
+
+ @Test
+ public void Given_Method_Is_StringToValue_And_Value_Is_Number_Return_Number()
+ throws Exception {
+ String val = "312";
+ Map<String, Object> map = new HashMap<>();
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ assertThat(logJObject.stringToValue(val), is(312));
+ }
+
+ @Test
+ public void Given_Method_Is_ToJSONArray_And_KeyValue_Exists_Return_Value_Array()
+ throws Exception {
+ JSONArray names = new JSONArray();
+ Map<String, Object> map = new HashMap<>();
+ map.put("name", "value");
+ names.put("name");
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ assertThat(logJObject.toJSONArray(names).get(0), is("value"));
+ }
+
+ @Test
+ public void Given_Method_Is_ValueToString_And_Value_Is_JSONArray_Return_Value_To_String()
+ throws Exception {
+ JSONArray val = new JSONArray();
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", "value");
+ val.put("value");
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ assertThat(logJObject.valueToString(val), is("[\"value\"]"));
+ }
+
+ @Test
+ public void Given_Method_Is_writeValue_And_Value_IS_Not_Null_Return_Writer_With_Value()
+ throws Exception {
+ Writer writer = new CharArrayWriter();
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", "value");
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ assertThat(logJObject.writeValue(writer, val, 3, 1).toString(), is("\"value\""));
+ }
+
+ @Test
+ public void Given_Method_Is_write_And_Length_Of_logJObject_Is_One_Write_Value_With_Indent()
+ throws Exception {
+ Writer writer = new CharArrayWriter();
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", "value");
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ assertThat(logJObject.write(writer, 3, 1).toString(), is("{\"key\": \"value\"}"));
+ }
+
+ @Test
+ public void Given_Method_Is_write_And_Length_Of_logJObject_Is_Not_One_Or_Zero_Write_Value_With_New_Indent()
+ throws Exception {
+ Writer writer = new CharArrayWriter();
+ String val = "value";
+ Map<String, Object> map = new HashMap<>();
+ map.put("key", "value");
+ map.put("key1", "value1");
+ LOGJSONObject logJObject = new LOGJSONObject(map);
+
+ assertThat(logJObject.write(writer, 3, 1).toString(), is("{\n \"key1\": \"value1\",\n \"key\": \"value\"\n }"));
+ }
+}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSetTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSetTest.java
new file mode 100755
index 00000000..32c964af
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/RLEBitSetTest.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package org.onap.dmaap.datarouter.provisioning.utils;
+
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class RLEBitSetTest {
+
+
+ private static RLEBitSet RLEBSet;
+
+ @Before
+ public void setUp() throws Exception {
+ RLEBSet = new RLEBitSet();
+ }
+
+ @Test
+ public void Given_Method_Is_Length_And_BitSet_Is_Empty_Return_0()
+ throws Exception {
+ assertThat(RLEBSet.length(), is(0L));
+ }
+
+ @Test
+ public void Given_Method_Is_Length_And_BitSet_Is_Not_Empty_Return_Length()
+ throws Exception {
+ RLEBSet.set(2L, 5L);
+ assertThat(RLEBSet.length(), is(5L));
+ }
+
+ @Test
+ public void Given_Method_Is_Get_And_Value_Is_Inside_BitSet_Return_True()
+ throws Exception {
+ long val = 4L;
+ RLEBSet.set(2L, 7L);
+ assertThat(RLEBSet.get(val), is(true));
+ }
+
+ @Test
+ public void Given_Method_Is_Get_And_Value_Is_Not_Inside_BitSet_Return_False()
+ throws Exception {
+ long val = 9L;
+ RLEBSet.set(2L, 7L);
+ assertThat(RLEBSet.get(val), is(false));
+ }
+
+ @Test
+ public void Given_Method_Is_Set_And_Value_Is_Range_And_Is_Outside_BitSet_Then_Update_Range()
+ throws Exception {
+ String val = "4-8";
+ RLEBSet.set(2L, 7L);
+ RLEBSet.set(val);
+ assertThat(RLEBSet.toString(), is("2-8"));
+ }
+
+ @Test
+ public void Given_Method_Is_Set_And_Value_Is_Not_Range_And_Is_Inside_BitSet_Then_Keep_Same_Range()
+ throws Exception {
+ String val = "3";
+ RLEBSet.set(2L, 7L);
+ RLEBSet.set(val);
+ assertThat(RLEBSet.toString(), is("2-6"));
+ }
+
+ @Test
+ public void Given_Method_Is_Set_And_Value_Is_Not_Range_And_Is_Outside_BitSet_Then_Add_New_Range()
+ throws Exception {
+ String val = "9";
+ RLEBSet.set(2L, 7L);
+ RLEBSet.set(val);
+ assertThat(RLEBSet.toString(), is("2-6,9"));
+ }
+
+ @Test
+ public void Given_Method_Is_Clear_Return_Blank_Set()
+ throws Exception {
+ RLEBSet.set(2L, 7L);
+ RLEBSet.clear();
+ assertThat(RLEBSet.toString(), is(""));
+ }
+
+ @Test
+ public void Given_Method_Is_Clear_ValueRange_And_Range_Overlaps_BitSet_Return_Trimmed_BitSet()
+ throws Exception {
+ long from = 1L;
+ long to = 4L;
+ RLEBSet.set(2L, 7L);
+ RLEBSet.clear(from, to);
+ assertThat(RLEBSet.toString(), is("4-6"));
+ }
+
+ @Test
+ public void Given_Method_Is_Clear_ValueRange_And_Range_Is_Inside_BitSet_Return_Split_BitSets()
+ throws Exception {
+ long from = 4L;
+ long to = 7L;
+ RLEBSet.set(2L, 9L);
+ RLEBSet.clear(from, to);
+ assertThat(RLEBSet.toString(), is("2-3,7-8"));
+ }
+
+ @Test
+ public void Given_Method_Is_Clear_ValueRange_And_Range_Is_Outside_BitSet_Return_Unchanged_BitSets()
+ throws Exception {
+ long from = 8L;
+ long to = 11L;
+ RLEBSet.set(2L, 7L);
+ RLEBSet.clear(from, to);
+ assertThat(RLEBSet.toString(), is("2-6"));
+ }
+
+ @Test
+ public void Given_Method_Is_And_Return_Common_Value_Set()
+ throws Exception {
+ RLEBitSet bSet = new RLEBitSet();
+ bSet.set(6L,11L);
+ RLEBSet.set(2L, 9L);
+ RLEBSet.and(bSet);
+ assertThat(RLEBSet.toString(), is("6-8"));
+ }
+
+ @Test
+ public void Given_Method_Is_AndNot_Return_Non_Common_Value_Set()
+ throws Exception {
+ RLEBitSet bSet = new RLEBitSet();
+ bSet.set(6L,11L);
+ RLEBSet.set(2L, 9L);
+ RLEBSet.andNot(bSet);
+ assertThat(RLEBSet.toString(), is("2-5"));
+ }
+
+ @Test
+ public void Given_Method_Is_Cardinality_Return_Bits_Set_To_True()
+ throws Exception {
+ RLEBSet.set(2L, 9L);
+ assertThat(RLEBSet.cardinality(), is(7));
+ }
+
+ @Test
+ public void Given_Method_Is_Clone_Return_Identical_Clone()
+ throws Exception {
+ RLEBSet.set(2L, 9L);
+ assertThat(RLEBSet.clone().toString(), is(RLEBSet.toString()));
+ }
+}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java
new file mode 100644
index 00000000..a8e919b7
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/ThrottleFilterTest.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package org.onap.dmaap.datarouter.provisioning.utils;
+
+import org.apache.commons.lang3.reflect.FieldUtils;
+import org.eclipse.jetty.continuation.Continuation;
+import org.eclipse.jetty.continuation.ContinuationSupport;
+import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.server.HttpChannel;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
+import org.junit.Test;
+
+import org.junit.runner.RunWith;
+import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+import org.mockito.Mock;
+
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+
+import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.*;
+
+@RunWith(PowerMockRunner.class)
+@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.provisioning.beans.Parameters",
+ "org.eclipse.jetty.server.Request",
+ "org.eclipse.jetty.continuation.ContinuationSupport",
+ "org.eclipse.jetty.server.HttpConnection"})
+public class ThrottleFilterTest {
+
+ @Mock
+ private HttpServletRequest request;
+
+ @Mock
+ private HttpServletResponse response;
+
+ @Mock
+ private FilterChain filterchain;
+
+ @Mock
+ private HttpConnection httpconnection;
+
+ @Mock
+ private ContinuationSupport continuationsupport;
+
+ @Mock
+ private Request req;
+
+ @Mock
+ private HttpChannel httpchannel;
+
+ @Mock
+ private Continuation continuation;
+
+
+
+ @Test
+ public void Given_Throttle_Filter_Configure_And_Parameter_Is_Not_Null_Then_Enabled_And_Action_Is_True() throws Exception {
+ mockParametersWithValues("2,5,throttle");
+ ThrottleFilter.configure();
+ boolean enabled = (boolean) FieldUtils.readStaticField(ThrottleFilter.class, "enabled", true);
+ int action = (int) FieldUtils.readStaticField(ThrottleFilter.class, "action", true);
+ assertThat(enabled, is(true));
+ assertThat(action, is(0));
+
+ }
+
+ @Test
+ public void Given_Do_Filter_run_and_enabled_and_action_is_true_and_rate_is_0_then_continiuation_will_call_setAttribute_and_resume_once() throws Exception {
+ mockParametersWithValues("100,5,thing");
+ ThrottleFilter throttlefilter = new ThrottleFilter();
+ ThrottleFilter.configure();
+ mockServletInputStream();
+ FieldUtils.writeDeclaredStaticField(ThrottleFilter.class, "action", 1, true);
+ Map<String, List<Continuation>> suspended_requests = new HashMap<String, List<Continuation>>();
+ List<Continuation> continuation_list = new ArrayList<>();
+ continuation_list.add(continuation);
+ suspended_requests.put("null/-1", continuation_list);
+ FieldUtils.writeDeclaredField(throttlefilter, "suspended_requests", suspended_requests, true);
+ throttlefilter.doFilter(request, response, filterchain);
+ verify(continuation, times(1)).setAttribute(anyString(), any());
+ verify(continuation, times(1)).resume();
+ }
+
+ @Test
+ public void Given_Do_Filter_Run_and_enabled_and_action_is_true_and_rate_is_greater_than_0_then_continuation_will_call_suspend_and_dispatch_once() throws Exception {
+ mockParametersWithValues("0,5,thing");
+ mockContinuationSupport();
+ ThrottleFilter.configure();
+ mockServletInputStream();
+ FieldUtils.writeDeclaredStaticField(ThrottleFilter.class, "action", 1, true);
+ ThrottleFilter throttlefilter = new ThrottleFilter();
+ throttlefilter.doFilter(request, response, filterchain);
+ verify(continuation, times(1)).undispatch();
+ verify(continuation, times(1)).suspend();
+ }
+
+
+ @Test
+ public void Given_Do_Filter_Run_and_enabled_and_action_is_true_and_rate_is_greater_than_0_and_getFeedId_returns_id_then_continuation_will_call_suspend_and_dispatch_once() throws Exception {
+ mockParametersWithValues("0,5,thing");
+ PowerMockito.mockStatic(ContinuationSupport.class);
+ PowerMockito.when(continuationsupport.getContinuation(any())).thenReturn(continuation);
+ ThrottleFilter.configure();
+ mockServletInputStream();
+ FieldUtils.writeDeclaredStaticField(ThrottleFilter.class, "action", 1, true);
+ ThrottleFilter throttlefilter = new ThrottleFilter();
+ when(request.getPathInfo()).thenReturn("/123/fileName.txt");
+ throttlefilter.doFilter(request, response, filterchain);
+ verify(continuation, times(1)).undispatch();
+ verify(continuation, times(1)).suspend();
+ }
+
+ @Test
+ public void Given_Do_Filter_and_only_enabled_is_true_and_drop_filter_ran_then_request_will_call_getHttpChannel_and_HttpChannel_will_call_getEndPoint_once() throws Exception {
+ mockParametersWithValues("0,5,thing");
+ ServletInputStream serverinputstream = mock(ServletInputStream.class);
+ mockHttpConnectionHttpChannelAndRequest(serverinputstream);
+ ThrottleFilter.configure();
+ FieldUtils.writeDeclaredStaticField(ThrottleFilter.class, "action", 0, true);
+ ThrottleFilter throttlefilter = new ThrottleFilter();
+ throttlefilter.doFilter(request, response, filterchain);
+ verify(req, times(1)).getHttpChannel();
+ verify(httpchannel, times(1)).getEndPoint();
+ }
+
+ @Test
+ public void Given_run_is_called_then_continuation_will_call_prune_once() throws Exception {
+ ThrottleFilter tf = new ThrottleFilter();
+ Map<String, ThrottleFilter.Counter> map = new HashMap<String, ThrottleFilter.Counter>();
+ ThrottleFilter.Counter tfc = mock(ThrottleFilter.Counter.class);
+ map.put("Key", tfc);
+ when(tfc.prune()).thenReturn(-1);
+ FieldUtils.writeDeclaredField(tf, "map", map, true);
+ tf.run();
+ verify(tfc, times(1)).prune();
+ }
+
+ @Test
+ public void Given_destroy_is_called_then_map_is_empty() throws Exception
+ {
+ ThrottleFilter throttleFilter = new ThrottleFilter();
+ FilterConfig filterconfig = mock(FilterConfig.class);
+ mockParametersWithValues("0,5,thing");
+ PowerMockito.mockStatic(ContinuationSupport.class);
+ PowerMockito.when(continuationsupport.getContinuation(any())).thenReturn(continuation);
+
+ throttleFilter.init(filterconfig);
+ throttleFilter.destroy();
+ }
+
+ private Parameters getParameters() {
+ PowerMockito.mockStatic(Parameters.class);
+ return mock(Parameters.class);
+ }
+
+ private void mockServletInputStream() throws IOException {
+ ServletInputStream serverinputstream = mock(ServletInputStream.class);
+ when(serverinputstream.read(any())).thenReturn(2).thenReturn(1).thenReturn(0);
+ when(request.getInputStream()).thenReturn(serverinputstream);
+ }
+
+ private void mockParametersWithValues(String values) {
+ Parameters parameters = getParameters();
+ PowerMockito.when(parameters.getParameter(anyString())).thenReturn(new Parameters("key", values));
+ }
+
+ private void mockContinuationSupport() {
+ PowerMockito.mockStatic(ContinuationSupport.class);
+ PowerMockito.when(continuationsupport.getContinuation(any())).thenReturn(continuation);
+ }
+
+ private void mockHttpConnectionHttpChannelAndRequest(ServletInputStream serverinputstream) throws IOException {
+ PowerMockito.mockStatic(ContinuationSupport.class);
+ PowerMockito.when(continuationsupport.getContinuation(any())).thenReturn(continuation);
+ when(serverinputstream.read(any())).thenReturn(2).thenReturn(1).thenReturn(0);
+ when(request.getInputStream()).thenReturn(serverinputstream);
+ PowerMockito.mockStatic(HttpConnection.class);
+ EndPoint endpoint = mock(EndPoint.class);
+ PowerMockito.when(httpconnection.getCurrentConnection()).thenReturn(httpconnection);
+ PowerMockito.when(httpconnection.getHttpChannel()).thenReturn(httpchannel);
+ when(httpchannel.getRequest()).thenReturn(req);
+ when(req.getHttpChannel()).thenReturn(httpchannel);
+ when(httpchannel.getEndPoint()).thenReturn(endpoint);
+ }
+}
diff --git a/datarouter-prov/src/test/resources/integration_test.properties b/datarouter-prov/src/test/resources/integration_test.properties
index 36b2ac3c..9ac1850a 100644
--- a/datarouter-prov/src/test/resources/integration_test.properties
+++ b/datarouter-prov/src/test/resources/integration_test.properties
@@ -1,5 +1,5 @@
-test.keystore=self_signed/keystore.jks
-test.kspassword=changeit
-test.truststore=self_signed/cacerts.jks
-test.tspassword=changeit
-test.host=https://prov.datarouternew.com:8443 \ No newline at end of file
+test.keystore=aaf_certs/org.onap.dmaap-dr.jks
+test.kspassword=Qgw77oaQcdP*F8Pwa[&.,.Ab
+test.truststore=aaf_certs/org.onap.dmaap-dr.trust.jks
+test.tspassword=9M?)?:KAj1z6gpLhNrVUG@0T
+test.host=https://dmaap-dr-prov:8443 \ No newline at end of file
diff --git a/datarouter-subscriber/pom.xml b/datarouter-subscriber/pom.xml
new file mode 100755
index 00000000..52cb25c7
--- /dev/null
+++ b/datarouter-subscriber/pom.xml
@@ -0,0 +1,393 @@
+<!--
+ ============LICENSE_START==================================================
+ * org.onap.dmaap
+ * ===========================================================================
+ * Copyright © 2017 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.
+ * 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.
+ * ============LICENSE_END====================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.dmaap.datarouter</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>datarouter-subscriber</artifactId>
+ <packaging>jar</packaging>
+ <name>datarouter-subscriber</name>
+ <properties>
+ <sonar.language>java</sonar.language>
+ <sonar.skip>false</sonar.skip>
+ <sonar.jacoco.reportMissing.force.zero>true</sonar.jacoco.reportMissing.force.zero>
+ <sitePath>/content/sites/site/${project.groupId}/${project.artifactId}/${project.version}</sitePath>
+
+ <docker.location>${basedir}/target/${artifactId}</docker.location>
+ <datarouter.prov.image.name>onap/dmaap/datarouter-subscriber</datarouter.prov.image.name>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-continuation</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-deploy</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlets</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-http</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-websocket</artifactId>
+ <version>${jetty.websocket.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-io</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.http-testing-harness</groupId>
+ <artifactId>junit-runner</artifactId>
+ <version>0.11</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.databene</groupId>
+ <artifactId>contiperf</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <properties>
+ <skipDockerBuild>false</skipDockerBuild>
+ <skipDockerTag>false</skipDockerTag>
+ <skipTests>true</skipTests>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <imageName>${onap.nexus.dockerregistry.daily}/${datarouter.prov.image.name}</imageName>
+ <dockerDirectory>${docker.location}</dockerDirectory>
+ <serverId>${onap.nexus.dockerregistry.daily}</serverId>
+ <skipDockerBuild>false</skipDockerBuild>
+ <imageTags>
+ <imageTag>${project.version}</imageTag>
+ <imageTag>latest</imageTag>
+ </imageTags>
+ <forceTags>true</forceTags>
+ <resources>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.basedir}</directory>
+ <excludes>
+ <exclude>target/**/*</exclude>
+ <exclude>pom.xml</exclude>
+ </excludes>
+ </resource>
+
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>**/**</include>
+ </resource>
+ </resources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <build>
+ <finalName>datarouter-subscriber</finalName>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/subscriber.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/log4j.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/log4j.properties</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <outputDirectory>${basedir}/target/opt/app/subscriber/lib</outputDirectory>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <mainClass>org.onap.dmaap.datarouter.subscriber.Subscriber</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <!-- this is used for inheritance merges -->
+ <phase>package</phase>
+ <!-- bind to the packaging phase -->
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ <version>3.6.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version>
+ <executions>
+ <execution>
+ <id>copy-docker-file</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${docker.location}</outputDirectory>
+ <overwrite>true</overwrite>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources/docker</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-resources-1</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${basedir}/target/opt/app/subscriber/lib</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*.jar</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-resources-2</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${basedir}/target/opt/app/subscriber/etc</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <includes>
+ <include>*.properties</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.10</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/opt/app/subscriber/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco.version}</version>
+ <configuration>
+ <excludes>
+ <exclude>**/gen/**</exclude>
+ <exclude>**/generated-sources/**</exclude>
+ <exclude>**/yang-gen/**</exclude>
+ <exclude>**/pax/**</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>pre-unit-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>
+ <propertyName>surefireArgLine</propertyName>
+ </configuration>
+ </execution>
+ <execution>
+ <id>post-unit-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
+ <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pre-integration-test</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>
+ <propertyName>failsafeArgLine</propertyName>
+ </configuration>
+ </execution>
+ <execution>
+ <id>post-integration-test</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>
+ <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/Subscriber.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/Subscriber.java
new file mode 100644
index 00000000..b6edb670
--- /dev/null
+++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/Subscriber.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 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.
+ * * 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.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package org.onap.dmaap.datarouter.subscriber;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jetty.servlet.*;
+import org.eclipse.jetty.util.ssl.*;
+import org.eclipse.jetty.server.*;
+import org.eclipse.jetty.http.HttpVersion;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Properties;
+
+public class Subscriber {
+
+ private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.subscriber.Subscriber");
+
+ private static final String CONTEXT_PATH = "/";
+ private static final String URL_PATTERN = "/*";
+
+ static Properties props;
+
+ private static void loadProps() {
+ if (props == null) {
+ props = new Properties();
+ try {
+ props.load(new FileInputStream(System.getProperty(
+ "org.onap.dmaap.datarouter.subscriber.properties",
+ "/opt/app/subscriber/etc/subscriber.properties")));
+ } catch (IOException e) {
+ logger.fatal("SubServlet: Exception opening properties: " + e.getMessage());
+ System.exit(1);
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ //Load the properties
+ loadProps();
+
+ int httpsPort = Integer.parseInt(props.getProperty("org.onap.dmaap.datarouter.subscriber.https.port", "8443"));
+ int httpPort = Integer.parseInt(props.getProperty("org.onap.dmaap.datarouter.subscriber.http.port", "8080"));
+
+ Server server = new Server();
+ HttpConfiguration httpConfig = new HttpConfiguration();
+ httpConfig.setRequestHeaderSize(8192);
+
+ // HTTP connector
+ ServletContextHandler ctxt;
+ try (ServerConnector httpServerConnector = new ServerConnector(server,
+ new HttpConnectionFactory(httpConfig))) {
+ httpServerConnector.setPort(httpPort);
+ httpServerConnector.setIdleTimeout(30000);
+
+ // SSL Context Factory
+ SslContextFactory sslContextFactory = new SslContextFactory();
+
+ // SSL HTTP Configuration
+ HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
+ httpsConfig.addCustomizer(new SecureRequestCustomizer());
+
+ // SSL Connector
+ ServerConnector sslConnector = new ServerConnector(server,
+ new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
+ new HttpConnectionFactory(httpsConfig));
+ sslConnector.setPort(httpsPort);
+ server.addConnector(sslConnector);
+
+ /*Skip SSLv3 Fixes*/
+ sslContextFactory.addExcludeProtocols("SSLv3");
+ logger.info("Excluded protocols for Subscriber:" + Arrays.toString(sslContextFactory.getExcludeProtocols()));
+ /*End of SSLv3 Fixes*/
+
+ // HTTPS Configuration
+ try (ServerConnector https = new ServerConnector(server,
+ new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
+ new HttpConnectionFactory(httpsConfig))) {
+ https.setPort(httpsPort);
+ https.setIdleTimeout(30000);
+ }
+ server.setConnectors(new Connector[]{ httpServerConnector });
+ }
+ ctxt = new ServletContextHandler(0);
+ ctxt.setContextPath(CONTEXT_PATH);
+ server.setHandler(ctxt);
+
+ ctxt.addServlet(new ServletHolder(new SubscriberServlet()), URL_PATTERN);
+ try {
+ server.start();
+ } catch ( Exception e ) {
+ logger.info("Jetty failed to start. Reporting will be unavailable-"+e);
+ }
+ server.join();
+ logger.info("org.onap.dmaap.datarouter.subscriber.Subscriber started-"+ server.getState());
+
+ }
+} \ No newline at end of file
diff --git a/Subscriber/src/SubscriberServlet.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberServlet.java
index 1af62a63..72afcf06 100644
--- a/Subscriber/src/SubscriberServlet.java
+++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberServlet.java
@@ -7,9 +7,9 @@
* * 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.
@@ -21,67 +21,88 @@
* *
******************************************************************************/
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URLEncoder;
+package org.onap.dmaap.datarouter.subscriber;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.log4j.Logger;
import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.PosixFilePermissions;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
+import static org.onap.dmaap.datarouter.subscriber.Subscriber.props;
-/**
- * Example stand alone subscriber servlet with Authorization header checking
- */
-public class SubscriberServlet extends HttpServlet {
- private static Logger logger = Logger.getLogger("com.att.datarouter.pubsub.ssasubscribe.SubscriberServlet");
- private String Login = "LOGIN";
- private String Password = "PASSWORD";
- private String OutputDirectory = "/root/sub/received";
+public class SubscriberServlet extends HttpServlet {
- private String auth;
+ private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.subscriber.SubscriberServlet");
+ private String outputDirectory;
+ private String basicAuth;
- private static String gp(ServletConfig config, String param, String deflt) {
- param = config.getInitParameter(param);
- if (param == null || param.length() == 0) {
- param = deflt;
- }
- return(param);
- }
/**
* Configure this subscriberservlet. Configuration parameters from config.getInitParameter() are:
* <ul>
* <li>Login - The login expected in the Authorization header (default "LOGIN").
* <li>Password - The password expected in the Authorization header (default "PASSWORD").
- * <li>OutputDirectory - The directory where files are placed (default "received").
+ * <li>outputDirectory - The directory where files are placed (default "tmp").
* </ul>
*/
- public void init(ServletConfig config) throws ServletException {
- Login = gp(config, "Login", Login);
- Password = gp(config, "Password", Password);
- OutputDirectory = gp(config, "OutputDirectory", OutputDirectory);
- (new File(OutputDirectory)).mkdirs();
- auth = "Basic " + Base64.encodeBase64String((Login + ":" + Password).getBytes());
+ @Override
+ public void init(ServletConfig config) {
+ String login = props.getProperty("org.onap.dmaap.datarouter.subscriber.auth.user", "LOGIN");
+ String password = props.getProperty("org.onap.dmaap.datarouter.subscriber.auth.password", "PASSWORD");
+ outputDirectory = props.getProperty("org.onap.dmaap.datarouter.subscriber.delivery.dir", "/tmp");
+ try {
+ Files.createDirectory(Paths.get(outputDirectory), PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx")));
+ } catch (IOException e) {
+ logger.info("SubServlet: Failed to create delivery dir: " + e.getMessage());
+ e.printStackTrace();
+ }
+ basicAuth = "Basic " + Base64.encodeBase64String((login + ":" + password).getBytes());
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ File filesPath = new File(outputDirectory);
+ File[] filesArr = filesPath.listFiles();
+ assert filesArr != null;
+ for (File file: filesArr) {
+ try (BufferedReader in = new BufferedReader(new FileReader(file))) {
+ String line = in.readLine();
+ while (line != null) {
+ line = in.readLine();
+ }
+ }
+ }
}
/**
* Invoke common(req, resp, false).
*/
- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- common(req, resp, false);
- }
+ @Override
+ protected void doPut(HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ common(req, resp, false);
+ } catch (IOException e) {
+ logger.info("SubServlet: Failed to doPut: " + req.getRemoteAddr() + " : " + req.getPathInfo(), e);
+ }
+ }
/**
* Invoke common(req, resp, true).
*/
- protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- common(req, resp, true);
- }
+ @Override
+ protected void doDelete(HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ common(req, resp, true);
+ } catch (IOException e) {
+ logger.info("SubServlet: Failed to doDelete: " + req.getRemoteAddr() + " : " + req.getPathInfo(), e);
+ }
+ }
/**
* Process a PUT or DELETE request.
* <ol>
@@ -90,59 +111,57 @@ public class SubscriberServlet extends HttpServlet {
* <li>Verify that the Authorization header matches the configured
* Login and Password or else FORBIDDEN.
* <li>If the request is PUT, store the message body as a file
- * in the configured OutputDirectory directory protecting against
+ * in the configured outputDirectory directory protecting against
* evil characters in the received FileID. The file is created
* initially with its name prefixed with a ".", and once it is complete, it is
* renamed to remove the leading "." character.
- * <li>If the request is DELETE, instead delete the file (if it exists) from the configured OutputDirectory directory.
+ * <li>If the request is DELETE, instead delete the file (if it exists) from the configured outputDirectory directory.
* <li>Respond with NO_CONTENT.
* </ol>
*/
- protected void common(HttpServletRequest req, HttpServletResponse resp, boolean isdelete) throws ServletException, IOException {
- String ah = req.getHeader("Authorization");
- if (ah == null) {
+ private void common(HttpServletRequest req, HttpServletResponse resp, boolean isdelete) throws IOException {
+ String authHeader = req.getHeader("Authorization");
+ if (authHeader == null) {
logger.info("Rejecting request with no Authorization header from " + req.getRemoteAddr() + ": " + req.getPathInfo());
resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
- if (!auth.equals(ah)) {
+ if (!basicAuth.equals(authHeader)) {
logger.info("Rejecting request with incorrect Authorization header from " + req.getRemoteAddr() + ": " + req.getPathInfo());
resp.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
String fileid = req.getPathInfo();
fileid = fileid.substring(fileid.lastIndexOf('/') + 1);
- String qs = req.getQueryString();
- if (qs != null) {
- fileid = fileid + "?" + qs;
+ String queryString = req.getQueryString();
+ if (queryString != null) {
+ fileid = fileid + "?" + queryString;
}
String publishid = req.getHeader("X-ATT-DR-PUBLISH-ID");
String filename = URLEncoder.encode(fileid, "UTF-8").replaceAll("^\\.", "%2E").replaceAll("\\*", "%2A");
- String finalname = OutputDirectory + "/" + filename;
- String tmpname = OutputDirectory + "/." + filename;
+ String fullPath = outputDirectory + "/" + filename;
+ String tmpPath = outputDirectory + "/." + filename;
try {
if (isdelete) {
- (new File(finalname)).delete();
- logger.info("Received delete for file id " + fileid + " from " + req.getRemoteAddr() + " publish id " + publishid + " as " + finalname);
+ Files.deleteIfExists(Paths.get(fullPath));
+ logger.info("Received delete for file id " + fileid + " from " + req.getRemoteAddr() + " publish id " + publishid + " as " + fullPath);
} else {
- InputStream is = req.getInputStream();
- OutputStream os = new FileOutputStream(tmpname);
- byte[] buf = new byte[65536];
- int i;
- while ((i = is.read(buf)) > 0) {
- os.write(buf, 0, i);
- }
- is.close();
- os.close();
- (new File(tmpname)).renameTo(new File(finalname));
- logger.info("Received file id " + fileid + " from " + req.getRemoteAddr() + " publish id " + publishid + " as " + finalname);
+ new File(tmpPath).createNewFile();
+ try (InputStream is = req.getInputStream(); OutputStream os = new FileOutputStream(tmpPath)) {
+ byte[] buf = new byte[65536];
+ int i;
+ while ((i = is.read(buf)) > 0) {
+ os.write(buf, 0, i);
+ }
+ }
+ Files.move(Paths.get(tmpPath), Paths.get(fullPath), StandardCopyOption.REPLACE_EXISTING);
+ logger.info("Received file id " + fileid + " from " + req.getRemoteAddr() + " publish id " + publishid + " as " + fullPath);
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
- logger.info("Received file id " + fileid + " from " + req.getRemoteAddr() + " publish id " + publishid + " as " + finalname);
}
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
} catch (IOException ioe) {
- (new File(tmpname)).delete();
- logger.info("Failure to save file " + finalname + " from " + req.getRemoteAddr() + ": " + req.getPathInfo(), ioe);
+ Files.deleteIfExists(Paths.get(tmpPath));
+ logger.info("Failed to process file " + fullPath + " from " + req.getRemoteAddr() + ": " + req.getPathInfo());
throw ioe;
}
}
diff --git a/datarouter-subscriber/src/main/resources/docker/Dockerfile b/datarouter-subscriber/src/main/resources/docker/Dockerfile
new file mode 100644
index 00000000..6cc74cc3
--- /dev/null
+++ b/datarouter-subscriber/src/main/resources/docker/Dockerfile
@@ -0,0 +1,6 @@
+FROM java:8
+ADD opt /opt/
+ADD startup.sh /startup.sh
+RUN chmod 700 /startup.sh
+ENTRYPOINT ./startup.sh start
+EXPOSE 7070 \ No newline at end of file
diff --git a/datarouter-subscriber/src/main/resources/docker/startup.sh b/datarouter-subscriber/src/main/resources/docker/startup.sh
new file mode 100644
index 00000000..53b1053d
--- /dev/null
+++ b/datarouter-subscriber/src/main/resources/docker/startup.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+LIB=/opt/app/subscriber/lib
+ETC=/opt/app/subscriber/etc
+CLASSPATH=$ETC
+for FILE in `find $LIB -name *.jar`; do
+ CLASSPATH=$CLASSPATH:$FILE
+done
+java -classpath $CLASSPATH org.onap.dmaap.datarouter.subscriber.Subscriber
+
+runner_file="$LIB/subscriber-jar-with-dependencies.jar"
+echo "Starting using" $runner_file
+java -Dorg.onap.dmaap.datarouter.subscriber.properties=/opt/app/subscriber/etc/subscriber.properties -jar $runner_file \ No newline at end of file
diff --git a/datarouter-subscriber/src/main/resources/log4j.properties b/datarouter-subscriber/src/main/resources/log4j.properties
new file mode 100644
index 00000000..bb66ef42
--- /dev/null
+++ b/datarouter-subscriber/src/main/resources/log4j.properties
@@ -0,0 +1,31 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright � 2017 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.
+# * 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.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+
+log4j.rootLogger=info,Root
+
+log4j.appender.Root=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.Root.file=/opt/app/subscriber/logs/subscriber.log
+log4j.appender.Root.datePattern='.'yyyyMMdd
+log4j.appender.Root.append=true
+log4j.appender.Root.layout=org.apache.log4j.PatternLayout
+log4j.appender.Root.layout.ConversionPattern=%d %p %t %m%n
diff --git a/datarouter-subscriber/src/main/resources/subscriber.properties b/datarouter-subscriber/src/main/resources/subscriber.properties
new file mode 100644
index 00000000..771fdd34
--- /dev/null
+++ b/datarouter-subscriber/src/main/resources/subscriber.properties
@@ -0,0 +1,40 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright � 2017 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.
+# * 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.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+
+#Subscriber properties
+org.onap.dmaap.datarouter.subscriber.http.port = 7070
+org.onap.dmaap.datarouter.subscriber.https.port = 7443
+org.onap.dmaap.datarouter.subscriber.auth.user = LOGIN
+org.onap.dmaap.datarouter.subscriber.auth.password = PASSWORD
+org.onap.dmaap.datarouter.subscriber.delivery.dir = /opt/app/subscriber/delivery
+
+org.onap.dmaap.datarouter.subscriber.https.relaxation = true
+org.onap.dmaap.datarouter.subscriber.keystore.type = jks
+org.onap.dmaap.datarouter.subscriber.keymanager.password = changeit
+org.onap.dmaap.datarouter.subscriber.keystore.path = /opt/app/datartr/self_signed/keystore.jks
+org.onap.dmaap.datarouter.subscriber.keystore.password = changeit
+org.onap.dmaap.datarouter.subscriber.truststore.path = /opt/app/datartr/self_signed/cacerts.jks
+org.onap.dmaap.datarouter.subscriber.truststore.password = changeit
+
+
+
diff --git a/datarouter-prov/src/main/resources/docker-compose/database/sql_init_01.sql b/docker-compose/database/sql_init_01.sql
index e01ce3b0..356a67a9 100644..100755
--- a/datarouter-prov/src/main/resources/docker-compose/database/sql_init_01.sql
+++ b/docker-compose/database/sql_init_01.sql
@@ -124,18 +124,18 @@ CREATE TABLE GROUPS (
);
INSERT INTO PARAMETERS VALUES
- ('ACTIVE_POD', 'prov.datarouternew.com'),
- ('PROV_ACTIVE_NAME', 'prov.datarouternew.com'),
+ ('ACTIVE_POD', 'dmaap-dr-prov'),
+ ('PROV_ACTIVE_NAME', 'dmaap-dr-prov'),
('STANDBY_POD', ''),
- ('PROV_NAME', 'prov.datarouternew.com'),
- ('NODES', '172.100.0.1|node.datarouternew.com'),
- ('PROV_DOMAIN', 'datarouternew.com'),
+ ('PROV_NAME', 'dmaap-dr-prov'),
+ ('NODES', 'dmaap-dr-node'),
+ ('PROV_DOMAIN', ''),
('DELIVERY_INIT_RETRY_INTERVAL', '10'),
('DELIVERY_MAX_AGE', '86400'),
('DELIVERY_MAX_RETRY_INTERVAL', '3600'),
('DELIVERY_RETRY_RATIO', '2'),
('LOGROLL_INTERVAL', '300'),
- ('PROV_AUTH_ADDRESSES', '172.100.0.1|prov.datarouternew.com|node.datarouternew.com'),
+ ('PROV_AUTH_ADDRESSES', 'dmaap-dr-prov|dmaap-dr-node'),
('PROV_AUTH_SUBJECTS', ''),
('PROV_MAXFEED_COUNT', '10000'),
('PROV_MAXSUB_COUNT', '100000'),
diff --git a/datarouter-prov/src/main/resources/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
index 6aee4dbd..35ed74c3 100644
--- a/datarouter-prov/src/main/resources/docker-compose/docker-compose.yml
+++ b/docker-compose/docker-compose.yml
@@ -1,96 +1,109 @@
-#-------------------------------------------------------------------------------
-# ============LICENSE_START==================================================
-# * org.onap.dmaap
-# * ===========================================================================
-# * Copyright © 2017 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.
-# * 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.
-# * ============LICENSE_END====================================================
-# *
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# *
-#-------------------------------------------------------------------------------
-version: '2.1'
-services:
- datarouter-prov:
- image: nexus3.onap.org:10003/onap/dmaap/datarouter-prov
- container_name: datarouter-prov
- hostname: prov.datarouternew.com
- ports:
- - "8443:8443"
- - "8080:8080"
- volumes:
- - ./prov_data/provserver.properties:/opt/app/datartr/etc/provserver.properties
- - ./prov_data/addSubscriber.txt:/opt/app/datartr/addSubscriber.txt
- - ./prov_data/addFeed3.txt:/opt/app/datartr/addFeed3.txt
- depends_on:
- mariadb_container:
- condition: service_healthy
- healthcheck:
- test: ["CMD", "curl", "-f", "http://prov.datarouternew.com:8080/internal/prov"]
- interval: 10s
- timeout: 10s
- retries: 5
- extra_hosts:
- - "node.datarouternew.com:172.100.0.4"
- networks:
- testing_net:
- ipv4_address: 172.100.0.3
-
- datarouter-node:
- image: nexus3.onap.org:10003/onap/dmaap/datarouter-node
- container_name: datarouter-node
- hostname: node.datarouternew.com
- ports:
- - "9443:8443"
- - "9090:8080"
- volumes:
- - ./node_data/node.properties:/opt/app/datartr/etc/node.properties
- depends_on:
- datarouter-prov:
- condition: service_healthy
- extra_hosts:
- - "prov.datarouternew.com:172.100.0.3"
- networks:
- testing_net:
- ipv4_address: 172.100.0.4
-
- mariadb_container:
- image: mariadb:10.2.14
- container_name: mariadb
- ports:
- - "3306:3306"
-# volumes:
-# - ./database/sql_init_01.sql:/docker-entrypoint-initdb.d/sql_init_01.sql
- environment:
- MYSQL_ROOT_PASSWORD: datarouter
- MYSQL_DATABASE: datarouter
- MYSQL_USER: datarouter
- MYSQL_PASSWORD: datarouter
- healthcheck:
- test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "--silent"]
- interval: 10s
- timeout: 30s
- retries: 5
-
- networks:
- testing_net:
- ipv4_address: 172.100.0.2
-
-networks:
- testing_net:
- driver: bridge
- ipam:
- driver: default
- config:
- - subnet: 172.100.0.0/16
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright © 2017 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.
+# * 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.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+version: '2.1'
+services:
+ datarouter-prov:
+ image: nexus3.onap.org:10003/onap/dmaap/datarouter-prov
+ container_name: datarouter-prov
+ hostname: dmaap-dr-prov
+ ports:
+ - "443:8443"
+ - "8443:8443"
+ - "8080:8080"
+ volumes:
+ - ./prov_data/provserver.properties:/opt/app/datartr/etc/provserver.properties
+ - ./prov_data/addSubscriber.txt:/opt/app/datartr/addSubscriber.txt
+ - ./prov_data/addFeed3.txt:/opt/app/datartr/addFeed3.txt
+ depends_on:
+ mariadb_container:
+ condition: service_healthy
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://dmaap-dr-prov:8080/internal/prov"]
+ interval: 10s
+ timeout: 10s
+ retries: 5
+ extra_hosts:
+ - "dmaap-dr-node:172.100.0.4"
+ networks:
+ testing_net:
+ ipv4_address: 172.100.0.3
+
+ datarouter-node:
+ image: nexus3.onap.org:10003/onap/dmaap/datarouter-node
+ container_name: datarouter-node
+ hostname: dmaap-dr-node
+ ports:
+ - "9443:8443"
+ - "9090:8080"
+ volumes:
+ - ./node_data/node.properties:/opt/app/datartr/etc/node.properties
+ depends_on:
+ datarouter-prov:
+ condition: service_healthy
+ extra_hosts:
+ - "dmaap-dr-prov:172.100.0.3"
+ networks:
+ testing_net:
+ ipv4_address: 172.100.0.4
+
+ datarouter-subscriber:
+ image: nexus3.onap.org:10003/onap/dmaap/datarouter-subscriber
+ container_name: subscriber-node
+ hostname: subscriber.com
+ ports:
+ - "7070:7070"
+ volumes:
+ - ./subscriber_data/subscriber.properties:/opt/app/subscriber/etc/subscriber.properties
+ networks:
+ testing_net:
+ ipv4_address: 172.100.0.5
+
+ mariadb_container:
+ image: mariadb:10.2.14
+ container_name: mariadb
+ ports:
+ - "3306:3306"
+# volumes:
+# - ./database/sql_init_01.sql:/docker-entrypoint-initdb.d/sql_init_01.sql
+ environment:
+ MYSQL_ROOT_PASSWORD: datarouter
+ MYSQL_DATABASE: datarouter
+ MYSQL_USER: datarouter
+ MYSQL_PASSWORD: datarouter
+ healthcheck:
+ test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "--silent"]
+ interval: 10s
+ timeout: 30s
+ retries: 5
+
+ networks:
+ testing_net:
+ ipv4_address: 172.100.0.2
+
+networks:
+ testing_net:
+ driver: bridge
+ ipam:
+ driver: default
+ config:
+ - subnet: 172.100.0.0/16
diff --git a/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.jks b/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.jks
new file mode 100755
index 00000000..4529cccb
--- /dev/null
+++ b/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.jks
Binary files differ
diff --git a/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.trust.jks b/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.trust.jks
new file mode 100755
index 00000000..096fbb26
--- /dev/null
+++ b/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.trust.jks
Binary files differ
diff --git a/datarouter-node/src/main/resources/misc/node.properties b/docker-compose/node_data/node.properties
index fc707413..de38cb6f 100644
--- a/datarouter-node/src/main/resources/misc/node.properties
+++ b/docker-compose/node_data/node.properties
@@ -1,111 +1,111 @@
-#-------------------------------------------------------------------------------
-# ============LICENSE_START==================================================
-# * org.onap.dmaap
-# * ===========================================================================
-# * Copyright 2017 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.
-# * 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.
-# * ============LICENSE_END====================================================
-# *
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# *
-#-------------------------------------------------------------------------------
-#
-# Configuration parameters fixed at startup for the DataRouter node
-#
-# URL to retrieve dynamic configuration
-#
-#ProvisioningURL: ${DRTR_PROV_INTURL}
-ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov
-
-#
-# URL to upload PUB/DEL/EXP logs
-#
-#LogUploadURL: ${DRTR_LOG_URL}
-LogUploadURL=https://prov.datarouternew.com:8443/internal/logs
-
-#
-# The port number for http as seen within the server
-#
-#IntHttpPort: ${DRTR_NODE_INTHTTPPORT:-8080}
-IntHttpPort=8080
-#
-# The port number for https as seen within the server
-#
-IntHttpsPort=8443
-#
-# The external port number for https taking port mapping into account
-#
-ExtHttpsPort=443
-#
-# The minimum interval between fetches of the dynamic configuration
-# from the provisioning server
-#
-MinProvFetchInterval=10000
-#
-# The minimum interval between saves of the redirection data file
-#
-MinRedirSaveInterval=10000
-#
-# The path to the directory where log files are stored
-#
-LogDir=/opt/app/datartr/logs
-#
-# The retention interval (in days) for log files
-#
-LogRetention=30
-#
-# The path to the directories where data and meta data files are stored
-#
-SpoolDir=/opt/app/datartr/spool
-#
-# The path to the redirection data file
-#
-#RedirectionFile: etc/redirections.dat
-#
-# The type of keystore for https
-KeyStoreType: jks
-#
-# The path to the keystore for https
-#
-KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks
-#
-# The password for the https keystore
-#
-KeyStorePassword=changeit
-#
-# The password for the private key in the https keystore
-#
-KeyPassword=changeit
-#
-# The type of truststore for https
-#
-TrustStoreType=jks
-#
-# The path to the truststore for https
-#
-#TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
-TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks
-#
-# The password for the https truststore
-#
-TrustStorePassword=changeit
-#
-# The path to the file used to trigger an orderly shutdown
-#
-QuiesceFile=etc/SHUTDOWN
-#
-# The key used to generate passwords for node to node transfers
-#
-NodeAuthKey=Node123!
-
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright 2017 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.
+# * 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.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+#
+# Configuration parameters fixed at startup for the DataRouter node
+#
+# URL to retrieve dynamic configuration
+#
+#ProvisioningURL: ${DRTR_PROV_INTURL}
+ProvisioningURL=https://dmaap-dr-prov:8443/internal/prov
+
+#
+# URL to upload PUB/DEL/EXP logs
+#
+#LogUploadURL: ${DRTR_LOG_URL}
+LogUploadURL=https://dmaap-dr-prov:8443/internal/logs
+
+#
+# The port number for http as seen within the server
+#
+#IntHttpPort: ${DRTR_NODE_INTHTTPPORT:-8080}
+IntHttpPort=8080
+#
+# The port number for https as seen within the server
+#
+IntHttpsPort=8443
+#
+# The external port number for https taking port mapping into account
+#
+ExtHttpsPort=443
+#
+# The minimum interval between fetches of the dynamic configuration
+# from the provisioning server
+#
+MinProvFetchInterval=10000
+#
+# The minimum interval between saves of the redirection data file
+#
+MinRedirSaveInterval=10000
+#
+# The path to the directory where log files are stored
+#
+LogDir=/opt/app/datartr/logs
+#
+# The retention interval (in days) for log files
+#
+LogRetention=30
+#
+# The path to the directories where data and meta data files are stored
+#
+SpoolDir=/opt/app/datartr/spool
+#
+# The path to the redirection data file
+#
+#RedirectionFile: etc/redirections.dat
+#
+# The type of keystore for https
+KeyStoreType: jks
+#
+# The path to the keystore for https
+#
+KeyStoreFile:/opt/app/datartr/aaf_certs/org.onap.dmaap-dr.jks
+#
+# The password for the https keystore
+#
+KeyStorePassword=4*&GD+w58RUM]01No.CYY;z6
+#
+# The password for the private key in the https keystore
+#
+KeyPassword=4*&GD+w58RUM]01No.CYY;z6
+#
+# The type of truststore for https
+#
+TrustStoreType=jks
+#
+# The path to the truststore for https
+#
+#TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
+TrustStoreFile=/opt/app/datartr/aaf_certs/org.onap.dmaap-dr.trust.jks
+#
+# The password for the https truststore
+#
+TrustStorePassword=UDXlT6Iu[F)k,Htk92+B,0Xj
+#
+# The path to the file used to trigger an orderly shutdown
+#
+QuiesceFile=etc/SHUTDOWN
+#
+# The key used to generate passwords for node to node transfers
+#
+NodeAuthKey=Node123!
+
diff --git a/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.jks b/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.jks
new file mode 100755
index 00000000..155991ab
--- /dev/null
+++ b/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.jks
Binary files differ
diff --git a/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.trust.jks b/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.trust.jks
new file mode 100755
index 00000000..c8f9ee66
--- /dev/null
+++ b/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.trust.jks
Binary files differ
diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/addFeed3.txt b/docker-compose/prov_data/addFeed3.txt
index 21000d0a..21000d0a 100644
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/addFeed3.txt
+++ b/docker-compose/prov_data/addFeed3.txt
diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/addSubscriber.txt b/docker-compose/prov_data/addSubscriber.txt
index 45e12732..45e12732 100644
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/addSubscriber.txt
+++ b/docker-compose/prov_data/addSubscriber.txt
diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties b/docker-compose/prov_data/provserver.properties
index 7758a64d..744bc9ce 100644..100755
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
+++ b/docker-compose/prov_data/provserver.properties
@@ -27,11 +27,11 @@ org.onap.dmaap.datarouter.provserver.https.port = 8443
org.onap.dmaap.datarouter.provserver.https.relaxation = true
org.onap.dmaap.datarouter.provserver.keystore.type = jks
-org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
-org.onap.dmaap.datarouter.provserver.keystore.path = /opt/app/datartr/self_signed/keystore.jks
-org.onap.dmaap.datarouter.provserver.keystore.password = changeit
-org.onap.dmaap.datarouter.provserver.truststore.path = /opt/app/datartr/self_signed/cacerts.jks
-org.onap.dmaap.datarouter.provserver.truststore.password = changeit
+org.onap.dmaap.datarouter.provserver.keymanager.password = Qgw77oaQcdP*F8Pwa[&.,.Ab
+org.onap.dmaap.datarouter.provserver.keystore.path = /opt/app/datartr/aaf_certs/org.onap.dmaap-dr.jks
+org.onap.dmaap.datarouter.provserver.keystore.password = Qgw77oaQcdP*F8Pwa[&.,.Ab
+org.onap.dmaap.datarouter.provserver.truststore.path = /opt/app/datartr/aaf_certs/org.onap.dmaap-dr.trust.jks
+org.onap.dmaap.datarouter.provserver.truststore.password = 9M?)?:KAj1z6gpLhNrVUG@0T
org.onap.dmaap.datarouter.provserver.accesslog.dir = /opt/app/datartr/logs
org.onap.dmaap.datarouter.provserver.spooldir = /opt/app/datartr/spool
diff --git a/docker-compose/subscriber_data/subscriber.properties b/docker-compose/subscriber_data/subscriber.properties
new file mode 100644
index 00000000..771fdd34
--- /dev/null
+++ b/docker-compose/subscriber_data/subscriber.properties
@@ -0,0 +1,40 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright � 2017 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.
+# * 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.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+
+#Subscriber properties
+org.onap.dmaap.datarouter.subscriber.http.port = 7070
+org.onap.dmaap.datarouter.subscriber.https.port = 7443
+org.onap.dmaap.datarouter.subscriber.auth.user = LOGIN
+org.onap.dmaap.datarouter.subscriber.auth.password = PASSWORD
+org.onap.dmaap.datarouter.subscriber.delivery.dir = /opt/app/subscriber/delivery
+
+org.onap.dmaap.datarouter.subscriber.https.relaxation = true
+org.onap.dmaap.datarouter.subscriber.keystore.type = jks
+org.onap.dmaap.datarouter.subscriber.keymanager.password = changeit
+org.onap.dmaap.datarouter.subscriber.keystore.path = /opt/app/datartr/self_signed/keystore.jks
+org.onap.dmaap.datarouter.subscriber.keystore.password = changeit
+org.onap.dmaap.datarouter.subscriber.truststore.path = /opt/app/datartr/self_signed/cacerts.jks
+org.onap.dmaap.datarouter.subscriber.truststore.password = changeit
+
+
+
diff --git a/pom.xml b/pom.xml
index d3327ba9..43aeca21 100755
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@
<modules>
<module>datarouter-prov</module>
<module>datarouter-node</module>
+ <module>datarouter-subscriber</module>
</modules>
<build>
<plugins>