Merge "Unit tests for ExpiryRecord"
authorRam Koya <rk541m@att.com>
Fri, 31 Aug 2018 15:18:00 +0000 (15:18 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 31 Aug 2018 15:18:00 +0000 (15:18 +0000)
63 files changed:
README.md
datarouter-node/aaf_certs/org.onap.dmaap-dr.jks [new file with mode: 0644]
datarouter-node/aaf_certs/org.onap.dmaap-dr.trust.jks [new file with mode: 0644]
datarouter-node/pom.xml
datarouter-node/self_signed/cacerts.jks [deleted file]
datarouter-node/self_signed/keystore.jks [deleted file]
datarouter-node/self_signed/mykey.cer [deleted file]
datarouter-node/self_signed/nodekey.cer [deleted file]
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java
datarouter-node/src/main/resources/misc/node.properties [deleted file]
datarouter-node/src/main/resources/node.properties
datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java [new file with mode: 0644]
datarouter-prov/aaf_certs/org.onap.dmaap-dr.jks [new file with mode: 0755]
datarouter-prov/aaf_certs/org.onap.dmaap-dr.trust.jks [new file with mode: 0755]
datarouter-prov/pom.xml
datarouter-prov/self_signed/cacerts.jks [deleted file]
datarouter-prov/self_signed/keystore.jks [deleted file]
datarouter-prov/self_signed/mykey.cer [deleted file]
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java [changed mode: 0644->0755]
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java [changed mode: 0644->0755]
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Group.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java [changed mode: 0644->0755]
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObject.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/DailyLatencyReport.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/LatencyReport.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/SubscriberReport.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/reports/VolumeReport.java
datarouter-prov/src/main/resources/misc/sql_init_01.sql [changed mode: 0644->0755]
datarouter-prov/src/main/resources/provserver.properties [changed mode: 0644->0755]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java [changed mode: 0644->0755]
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java [changed mode: 0644->0755]
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DrServletTestBase.java
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java [changed mode: 0644->0755]
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java [changed mode: 0755->0644]
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java [changed mode: 0644->0755]
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecordTest.java [new file with mode: 0644]
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/GroupTest.java
datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecordTest.java [new file with mode: 0644]
datarouter-prov/src/test/resources/META-INF/persistence.xml [new file with mode: 0755]
datarouter-prov/src/test/resources/create.sql [new file with mode: 0755]
datarouter-prov/src/test/resources/h2Database.properties [new file with mode: 0755]
datarouter-prov/src/test/resources/integration_test.properties
docker-compose/database/sql_init_01.sql [changed mode: 0644->0755]
docker-compose/docker-compose.yml
docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.jks [new file with mode: 0755]
docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.trust.jks [new file with mode: 0755]
docker-compose/node_data/node.properties
docker-compose/node_data/self_signed/cacerts.jks [deleted file]
docker-compose/node_data/self_signed/keystore.jks [deleted file]
docker-compose/node_data/self_signed/mykey.cer [deleted file]
docker-compose/node_data/self_signed/nodekey.cer [deleted file]
docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.jks [new file with mode: 0755]
docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.trust.jks [new file with mode: 0755]
docker-compose/prov_data/provserver.properties [changed mode: 0644->0755]
docker-compose/prov_data/self_signed/cacerts.jks [deleted file]
docker-compose/prov_data/self_signed/keystore.jks [deleted file]
docker-compose/prov_data/self_signed/mykey.cer [deleted file]

index 559b03d..6e45867 100644 (file)
--- a/README.md
+++ b/README.md
 # DMAAP_DATAROUTER\r
-                              \r
+\r
 ## OVERVIEW\r
-  \r
-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.  \r
+\r
+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.\r
 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.\r
 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\r
 \r
    Provisioning is implemented as a Java servlet running under Jetty in one JVM\r
-   \r
+\r
    Provisioning data is stored in a MariaDB database\r
-   \r
+\r
    The backup provisioning server and each node is informed any time provisioning data changes\r
-   \r
+\r
    The backup provisioning server and each node may request the complete set of provisioning data at any time\r
-   \r
+\r
    A Node is implemented as a Java servlet running under Jetty in one JVM\r
 \r
 Assumptions\r
     For 95% of all feeds (there will be some exceptions):\r
-       \r
+\r
     Number of Publishing Endpoints per Feed: 1 – 10\r
-       \r
+\r
     Number of Subscribers per Feed: 2 – 10\r
-       \r
+\r
     File Size: 105 – 1010 bytes\r
-       \r
+\r
     with a distribution towards the high end\r
-       \r
+\r
     Frequency of Publishing: 1/day – 10/minute\r
-       \r
+\r
     Lifetime of a Feed: months to years\r
-       \r
+\r
     Lifetime of a Subscription: months to years\r
-       \r
\r
+\r
+\r
 Data Router and Sensitive Data Handling\r
\r
+\r
     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\r
-       \r
+\r
     The Data Router will distribute that data to all of the subscribers of that feed.\r
-       \r
+\r
     Data Router does not examine the Feed content or enforce any restrictions or Validations on the Feed Content in any way\r
-       \r
+\r
     It is the responsibility of the subscribers to work with the publisher to determine how to decrypt that data\r
-       \r
 \r
 \r
\r
+\r
+\r
 \r
 What the Data Router is NOT:\r
 \r
     Does not support streaming data\r
-       \r
+\r
     Does not tightly couple to any specific publish endpoint or subscriber\r
-       \r
+\r
     Agnostic as to source and sink of data residing in an RDBMS, NoSQL DB, Other DBMS, Flat Files, etc.\r
-       \r
+\r
     Does not transform any published data\r
-       \r
+\r
     Does not “examine” any published data\r
-       \r
+\r
     Does not verify the integrity of a published file\r
-       \r
+\r
     Does not perform any data “cleansing”\r
-       \r
+\r
     Does not store feeds (not a repository or archive)\r
-       \r
+\r
     There is no long-term storage – assumes subscribers are responsive most of the time\r
-       \r
+\r
     Does not encrypt data when queued on a node\r
-       \r
+\r
     Does not provide guaranteed order of delivery\r
-       \r
+\r
     Per-file metadata can be used for ordering\r
-       \r
-   External customers supported is via DITREX (MOTS 18274)\r
\r
\r
\r
 \r
-## BUILD  \r
\r
-Datarouter can be cloned and repository and builb using Maven \r
-In the repository \r
+\r
+\r
+\r
+## BUILD\r
+\r
+Datarouter can be cloned and repository and builb using Maven\r
+In the repository\r
 \r
 Go to datarouter-prov in the root\r
 \r
        mvn clean install\r
-       \r
+\r
 Go to datarouter-node in the root\r
 \r
        mvn clean install\r
-        \r
+\r
 Project Build will be Successful\r
 \r
 \r
 \r
 \r
-## RUN \r
+## RUN\r
 \r
-Datarouter is a Unix based service \r
+Datarouter is a Unix based service\r
 \r
 Pre-requisites to run the service\r
 \r
@@ -111,39 +109,39 @@ Install MariaDB and load needed table into the database
 \r
 Sample sql_init_01.sql is provided in the datarouter-prov/src/main/resources/misc\r
 \r
-Go to datarouter-prov module and run the service using main.java \r
\r
-Go to datarouter-node module and run the service using nodemain.java \r
+Go to datarouter-prov module and run the service using main.java\r
+\r
+Go to datarouter-node module and run the service using nodemain.java\r
 \r
 Curl Commands to test:\r
 \r
 create a feed:\r
 \r
-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\r
+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\r
 \r
 Subscribe to feed:\r
 \r
-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\r
+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\r
 \r
 Publish to feed:\r
 \r
-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\r
+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\r
+\r
 \r
 \r
\r
 \r
- ## CONFIGURATION \r
+ ## CONFIGURATION\r
 \r
-Recommended \r
+Recommended\r
 \r
 Environment - Unix based\r
 \r
 Java - 1.8\r
 \r
-Maven - 3.2.5 \r
+Maven - 3.2.5\r
 \r
 MariaDB - 10.2.14\r
 \r
 Self Signed SSL certificates\r
\r
\r
+\r
+\r
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 (file)
index 0000000..4529ccc
Binary files /dev/null and b/datarouter-node/aaf_certs/org.onap.dmaap-dr.jks 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 (file)
index 0000000..096fbb2
Binary files /dev/null and b/datarouter-node/aaf_certs/org.onap.dmaap-dr.trust.jks differ
index c6bd3e9..18743db 100755 (executable)
                             <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 (file)
index dfd8143..0000000
Binary files a/datarouter-node/self_signed/cacerts.jks and /dev/null differ
diff --git a/datarouter-node/self_signed/keystore.jks b/datarouter-node/self_signed/keystore.jks
deleted file mode 100644 (file)
index e5a4e78..0000000
Binary files a/datarouter-node/self_signed/keystore.jks and /dev/null differ
diff --git a/datarouter-node/self_signed/mykey.cer b/datarouter-node/self_signed/mykey.cer
deleted file mode 100644 (file)
index 2a5c9d7..0000000
Binary files a/datarouter-node/self_signed/mykey.cer and /dev/null differ
diff --git a/datarouter-node/self_signed/nodekey.cer b/datarouter-node/self_signed/nodekey.cer
deleted file mode 100644 (file)
index 4cdfdfe..0000000
Binary files a/datarouter-node/self_signed/nodekey.cer and /dev/null differ
index 375a38e..2c013ca 100644 (file)
@@ -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/misc/node.properties b/datarouter-node/src/main/resources/misc/node.properties
deleted file mode 100644 (file)
index fc70741..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#-------------------------------------------------------------------------------\r
-# ============LICENSE_START==================================================\r
-# * org.onap.dmaap\r
-# * ===========================================================================\r
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
-# * ===========================================================================\r
-# * Licensed under the Apache License, Version 2.0 (the "License");\r
-# * you may not use this file except in compliance with the License.\r
-# * You may obtain a copy of the License at\r
-# *\r
-#  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# *\r
-#  * Unless required by applicable law or agreed to in writing, software\r
-# * distributed under the License is distributed on an "AS IS" BASIS,\r
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# * See the License for the specific language governing permissions and\r
-# * limitations under the License.\r
-# * ============LICENSE_END====================================================\r
-# *\r
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-# *\r
-#-------------------------------------------------------------------------------\r
-#\r
-#    Configuration parameters fixed at startup for the DataRouter node\r
-#\r
-#    URL to retrieve dynamic configuration\r
-#\r
-#ProvisioningURL:    ${DRTR_PROV_INTURL}\r
-ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov\r
-\r
-#\r
-#    URL to upload PUB/DEL/EXP logs\r
-#\r
-#LogUploadURL:    ${DRTR_LOG_URL}\r
-LogUploadURL=https://prov.datarouternew.com:8443/internal/logs\r
-\r
-#\r
-#    The port number for http as seen within the server\r
-#\r
-#IntHttpPort:    ${DRTR_NODE_INTHTTPPORT:-8080}\r
-IntHttpPort=8080\r
-#\r
-#    The port number for https as seen within the server\r
-#\r
-IntHttpsPort=8443\r
-#\r
-#    The external port number for https taking port mapping into account\r
-#\r
-ExtHttpsPort=443\r
-#\r
-#    The minimum interval between fetches of the dynamic configuration\r
-#    from the provisioning server\r
-#\r
-MinProvFetchInterval=10000\r
-#\r
-#    The minimum interval between saves of the redirection data file\r
-#\r
-MinRedirSaveInterval=10000\r
-#\r
-#    The path to the directory where log files are stored\r
-#\r
-LogDir=/opt/app/datartr/logs\r
-#\r
-#    The retention interval (in days) for log files\r
-#\r
-LogRetention=30\r
-#\r
-#    The path to the directories where data and meta data files are stored\r
-#\r
-SpoolDir=/opt/app/datartr/spool\r
-#\r
-#    The path to the redirection data file\r
-#\r
-#RedirectionFile:    etc/redirections.dat\r
-#\r
-#    The type of keystore for https\r
-KeyStoreType:    jks\r
-#\r
-#    The path to the keystore for https\r
-#\r
-KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks\r
-#\r
-#    The password for the https keystore\r
-#\r
-KeyStorePassword=changeit\r
-#\r
-#    The password for the private key in the https keystore\r
-#\r
-KeyPassword=changeit\r
-#\r
-#    The type of truststore for https\r
-#\r
-TrustStoreType=jks\r
-#\r
-#    The path to the truststore for https\r
-#\r
-#TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts\r
-TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks\r
-#\r
-#    The password for the https truststore\r
-#\r
-TrustStorePassword=changeit\r
-#\r
-#    The path to the file used to trigger an orderly shutdown\r
-#\r
-QuiesceFile=etc/SHUTDOWN\r
-#\r
-#    The key used to generate passwords for node to node transfers\r
-#\r
-NodeAuthKey=Node123!\r
-\r
index 411cc2b..de38cb6 100644 (file)
-#-------------------------------------------------------------------------------\r
-# ============LICENSE_START==================================================\r
-# * org.onap.dmaap\r
-# * ===========================================================================\r
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
-# * ===========================================================================\r
-# * Licensed under the Apache License, Version 2.0 (the "License");\r
-# * you may not use this file except in compliance with the License.\r
-# * You may obtain a copy of the License at\r
-# *\r
-#  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# *\r
-#  * Unless required by applicable law or agreed to in writing, software\r
-# * distributed under the License is distributed on an "AS IS" BASIS,\r
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# * See the License for the specific language governing permissions and\r
-# * limitations under the License.\r
-# * ============LICENSE_END====================================================\r
-# *\r
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-# *\r
-#-------------------------------------------------------------------------------\r
-#\r
-#    Configuration parameters fixed at startup for the DataRouter node\r
-#\r
-#    URL to retrieve dynamic configuration\r
-#\r
-#ProvisioningURL:    ${DRTR_PROV_INTURL}\r
-ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov\r
-\r
-#\r
-#    URL to upload PUB/DEL/EXP logs\r
-#\r
-#LogUploadURL:    ${DRTR_LOG_URL}\r
-LogUploadURL=https://prov.datarouternew.com:8443/internal/logs\r
-\r
-#\r
-#    The port number for http as seen within the server\r
-#\r
-#IntHttpPort:    ${DRTR_NODE_INTHTTPPORT:-8080}\r
-IntHttpPort=8080\r
-#\r
-#    The port number for https as seen within the server\r
-#\r
-IntHttpsPort=8443\r
-#\r
-#    The external port number for https taking port mapping into account\r
-#\r
-ExtHttpsPort=443\r
-#\r
-#    The minimum interval between fetches of the dynamic configuration\r
-#    from the provisioning server\r
-#\r
-MinProvFetchInterval=10000\r
-#\r
-#    The minimum interval between saves of the redirection data file\r
-#\r
-MinRedirSaveInterval=10000\r
-#\r
-#    The path to the directory where log files are stored\r
-#\r
-LogDir=/opt/app/datartr/logs\r
-#\r
-#    The retention interval (in days) for log files\r
-#\r
-LogRetention=30\r
-#\r
-#    The path to the directories where data and meta data files are stored\r
-#\r
-SpoolDir=/opt/app/datartr/spool\r
-#\r
-#    The path to the redirection data file\r
-#\r
-#RedirectionFile:    etc/redirections.dat\r
-#\r
-#    The type of keystore for https\r
-#\r
-KeyStoreType:    jks\r
-#\r
-#    The path to the keystore for https\r
-#\r
-KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks\r
-#\r
-#    The password for the https keystore\r
-#\r
-KeyStorePassword=changeit\r
-#\r
-#    The password for the private key in the https keystore\r
-#\r
-KeyPassword=changeit\r
-#\r
-#    The type of truststore for https\r
-#\r
-TrustStoreType=jks\r
-#\r
-#    The path to the truststore for https\r
-#\r
-#TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts\r
-TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks\r
-#\r
-#    The password for the https truststore\r
-#\r
-TrustStorePassword=changeit\r
-#\r
-#    The path to the file used to trigger an orderly shutdown\r
-#\r
-QuiesceFile=etc/SHUTDOWN\r
-#\r
-#    The key used to generate passwords for node to node transfers\r
-#\r
-NodeAuthKey=Node123!\r
-\r
+#-------------------------------------------------------------------------------
+# ============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/DeliveryTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java
new file mode 100644 (file)
index 0000000..8a7460e
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * ============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.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+@RunWith(PowerMockRunner.class)
+@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeConfigManager")
+public class DeliveryTest {
+
+  @Mock
+  private DeliveryQueue deliveryQueue;
+
+  private File nDir = new File("tmp/n");
+  private File sDir = new File("tmp/s");
+
+  @Before
+  public void setUp() throws IOException {
+    nDir.mkdirs();
+    sDir.mkdirs();
+    File newNDir = new File("tmp/n/0");
+    newNDir.mkdirs();
+    File newNFile = new File("tmp/n/0/testN.txt");
+    newNFile.createNewFile();
+    File newSDir = new File("tmp/s/0/1");
+    newSDir.mkdirs();
+    File newSpoolFile = new File("tmp/s/0/1/testSpool.txt");
+    newSpoolFile.createNewFile();
+  }
+
+  @Test
+  public void Validate_Reset_Queue_Calls_Reset_Queue_On_Delivery_Queue_Object() throws IllegalAccessException {
+    NodeConfigManager config = mockNodeConfigManager();
+    Delivery delivery = new Delivery(config);
+    Hashtable<String, DeliveryQueue> dqs = new Hashtable<>();
+    dqs.put("spool/s/0/1", deliveryQueue);
+    FieldUtils.writeDeclaredField(delivery, "dqs", dqs, true);
+    delivery.resetQueue("spool/s/0/1");
+    verify(deliveryQueue, times(1)).resetQueue();
+  }
+
+  @After
+  public void tearDown() {
+    nDir.delete();
+    sDir.delete();
+    File tmpDir = new File("tmp");
+    tmpDir.delete();
+  }
+
+  private NodeConfigManager mockNodeConfigManager() {
+    PowerMockito.mockStatic(NodeConfigManager.class);
+    NodeConfigManager config = mock(NodeConfigManager.class);
+    PowerMockito.when(config.isConfigured()).thenReturn(true);
+    PowerMockito.when(config.getAllDests()).thenReturn(createDestInfoObjects());
+    PowerMockito.when(config.getFreeDiskStart()).thenReturn(0.49);
+    PowerMockito.when(config.getFreeDiskStop()).thenReturn(0.5);
+    PowerMockito.when(config.getDeliveryThreads()).thenReturn(0);
+    PowerMockito.when(config.getSpoolBase()).thenReturn("tmp");
+    return config;
+  }
+
+  private DestInfo[] createDestInfoObjects() {
+    DestInfo[] destInfos = new DestInfo[1];
+    DestInfo destInfo = new DestInfo("node.datarouternew.com", "spool/s/0/1", "1", "logs/", "/subs/1", "user1", "Basic dXNlcjE6cGFzc3dvcmQx", false, true);
+    destInfos[0] = destInfo;
+    return destInfos;
+  }
+}
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 (executable)
index 0000000..155991a
Binary files /dev/null and b/datarouter-prov/aaf_certs/org.onap.dmaap-dr.jks 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 (executable)
index 0000000..c8f9ee6
Binary files /dev/null and b/datarouter-prov/aaf_certs/org.onap.dmaap-dr.trust.jks differ
index a970f71..7613757 100755 (executable)
             <version>1.2.17</version>\r
             <scope>compile</scope>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>com.h2database</groupId>\r
+            <artifactId>h2</artifactId>\r
+            <version>1.4.197</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.hibernate</groupId>\r
+            <artifactId>hibernate-entitymanager</artifactId>\r
+            <version>5.2.9.Final</version>\r
+        </dependency>\r
     </dependencies>\r
     <profiles>\r
         <profile>\r
                             <goal>copy-resources</goal>\r
                         </goals>\r
                         <configuration>\r
-                            <outputDirectory>${basedir}/target/opt/app/datartr/self_signed</outputDirectory>\r
+                            <outputDirectory>${basedir}/target/opt/app/datartr/aaf_certs</outputDirectory>\r
                             <resources>\r
                                 <resource>\r
-                                    <directory>${basedir}/self_signed</directory>\r
+                                    <directory>${basedir}/aaf_certs</directory>\r
                                     <includes>\r
                                         <include>misc/**</include>\r
                                         <include>**/**</include>\r
diff --git a/datarouter-prov/self_signed/cacerts.jks b/datarouter-prov/self_signed/cacerts.jks
deleted file mode 100644 (file)
index 76a480a..0000000
Binary files a/datarouter-prov/self_signed/cacerts.jks and /dev/null differ
diff --git a/datarouter-prov/self_signed/keystore.jks b/datarouter-prov/self_signed/keystore.jks
deleted file mode 100644 (file)
index 2c22b4a..0000000
Binary files a/datarouter-prov/self_signed/keystore.jks and /dev/null differ
diff --git a/datarouter-prov/self_signed/mykey.cer b/datarouter-prov/self_signed/mykey.cer
deleted file mode 100644 (file)
index 2a5c9d7..0000000
Binary files a/datarouter-prov/self_signed/mykey.cer and /dev/null differ
old mode 100644 (file)
new mode 100755 (executable)
index 412e132..047043b
@@ -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());
index 87979be..800bd9a 100644 (file)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index c560299..8d6bfcf
@@ -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,58 +179,61 @@ 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);
-            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();
+            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);
-            try(AbstractHttpClient httpclient = new DefaultHttpClient()) {
+            intlogger.info("ProxyServlet: proxying " + method + " " + url);
+            try (AbstractHttpClient httpclient = new DefaultHttpClient()) {
                 ProxyHttpRequest proxy = new ProxyHttpRequest(method, url);
                 try {
                     httpclient.getConnectionManager().getSchemeRegistry().register(sch);
@@ -264,33 +275,40 @@ public class ProxyServlet extends BaseServlet {
             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) {
@@ -298,6 +316,7 @@ public class ProxyServlet extends BaseServlet {
             this.method = method;
             setURI(URI.create(uri));
         }
+
         @Override
         public String getMethod() {
             return method;
index 134a595..e79d470 100755 (executable)
@@ -293,13 +293,13 @@ public class StatisticsServlet extends BaseServlet {
   /**\r
    * getFeedIdsByGroupId - Getting FEEDID's by GROUP ID.\r
    *\r
-   * @throws SQL Query SQLException.\r
+   * @throws SQLException Query SQLException.\r
    */\r
   public StringBuffer getFeedIdsByGroupId(int groupIds) throws SQLException {\r
 \r
     DB db = null;\r
     Connection conn = null;\r
-    PreparedStatement prepareStatement = null;\r
+    //PreparedStatement prepareStatement = null;\r
     ResultSet resultSet = null;\r
     String sqlGoupid = null;\r
     StringBuffer feedIds = new StringBuffer();\r
@@ -308,16 +308,16 @@ public class StatisticsServlet extends BaseServlet {
       db = new DB();\r
       conn = db.getConnection();\r
       sqlGoupid = " SELECT FEEDID from FEEDS  WHERE GROUPID = ?";\r
-      prepareStatement = conn.prepareStatement(sqlGoupid);\r
-      prepareStatement.setInt(1, groupIds);\r
-      resultSet = prepareStatement.executeQuery();\r
-      while (resultSet.next()) {\r
-        feedIds.append(resultSet.getInt("FEEDID"));\r
-        feedIds.append(",");\r
+      try(PreparedStatement prepareStatement = conn.prepareStatement(sqlGoupid)) {\r
+          prepareStatement.setInt(1, groupIds);\r
+          resultSet = prepareStatement.executeQuery();\r
+          while (resultSet.next()) {\r
+              feedIds.append(resultSet.getInt("FEEDID"));\r
+              feedIds.append(",");\r
+          }\r
+          feedIds.deleteCharAt(feedIds.length() - 1);\r
+          System.out.println("feedIds" + feedIds.toString());\r
       }\r
-      feedIds.deleteCharAt(feedIds.length() - 1);\r
-      System.out.println("feedIds" + feedIds.toString());\r
-\r
     } catch (SQLException e) {\r
       e.printStackTrace();\r
     } finally {\r
@@ -326,13 +326,7 @@ public class StatisticsServlet extends BaseServlet {
           resultSet.close();\r
           resultSet = null;\r
         }\r
-\r
-        if (prepareStatement != null) {\r
-          prepareStatement.close();\r
-          prepareStatement = null;\r
-        }\r
-\r
-        if (conn != null) {\r
+          if (conn != null) {\r
           db.release(conn);\r
         }\r
       } catch (Exception e) {\r
@@ -571,33 +565,44 @@ public class StatisticsServlet extends BaseServlet {
     intlogger.info("Error parsing time=" + s);\r
     return -1;\r
   }\r
-\r
-\r
   private ResultSet getRecordsForSQL(String sql) {\r
-    intlogger.debug(sql);\r
-    long start = System.currentTimeMillis();\r
-    DB db = new DB();\r
-    Connection conn = null;\r
-    ResultSet rs = null;\r
-\r
-    try {\r
-      conn = db.getConnection();\r
-      Statement stmt = conn.createStatement();\r
-      PreparedStatement pst = conn.prepareStatement(sql);\r
-      rs = pst.executeQuery();\r
-      //this.rsToJson(rs)\r
-      //rs.close();\r
-      stmt.close();\r
-    } catch (SQLException e) {\r
-      e.printStackTrace();\r
-    } finally {\r
-      if (conn != null) {\r
-        db.release(conn);\r
-      }\r
-    }\r
+      intlogger.debug(sql);\r
+      long start = System.currentTimeMillis();\r
+      DB db = new DB();\r
+      Connection conn = null;\r
+      ResultSet rs = null;\r
+      Statement stmt = null;\r
+      PreparedStatement pst = null;\r
+      try {\r
+          conn = db.getConnection();\r
+          stmt = conn.createStatement();\r
+          pst = conn.prepareStatement(sql);\r
+          rs = pst.executeQuery();\r
+      } catch (SQLException e) {\r
+          e.printStackTrace();\r
+      } finally {\r
+\r
+          try {\r
+              if (conn != null) {\r
+                  db.release(conn);\r
+              }\r
+              if (stmt != null) {\r
+                  stmt.close();\r
+              }\r
+              if (pst != null) {\r
+                  pst.close();\r
+              }\r
+              if (rs != null) {\r
+                  rs.close();\r
+              }\r
+\r
+          } catch (SQLException sqlException) {\r
+              intlogger.error("Exception in getting SQl Records",sqlException);\r
+          }\r
 \r
-    intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");\r
+          intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");\r
 \r
-    return rs;\r
+          return rs;\r
+      }\r
   }\r
 }\r
index 2ea60d2..a021a60 100644 (file)
@@ -60,7 +60,7 @@ public class Group extends Syncable {
 \r
     public static Group getGroupMatching(Group gup) {\r
         String sql = String.format(\r
-                "select * from GROUPS where  NAME = \"%s\"",\r
+                "select * from GROUPS where NAME='%s'",\r
                 gup.getName()\r
         );\r
         List<Group> list = getGroupsForSQL(sql);\r
@@ -69,7 +69,7 @@ public class Group extends Syncable {
 \r
     public static Group getGroupMatching(Group gup, int groupid) {\r
         String sql = String.format(\r
-                "select * from GROUPS where  NAME = \"%s\" and GROUPID != %d ",\r
+                "select * from GROUPS where  NAME = '%s' and GROUPID != %d ",\r
                 gup.getName(),\r
                 gup.getGroupid()\r
         );\r
old mode 100644 (file)
new mode 100755 (executable)
index 4c14049..f3eb1eb
@@ -32,7 +32,6 @@ import java.util.HashMap;
 import java.util.Map;\r
 import java.util.Set;\r
 import java.util.TreeSet;\r
-\r
 import org.apache.log4j.Logger;\r
 import org.onap.dmaap.datarouter.provisioning.utils.DB;\r
 \r
@@ -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 $\r
  */\r
 public abstract class NodeClass extends Syncable {\r
+\r
     private static Map<String, Integer> map;\r
     private static Logger intLogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");\r
     public NodeClass() {\r
@@ -53,19 +53,20 @@ public abstract class NodeClass extends Syncable {
     }\r
 \r
     /**\r
-     * Add nodes to the NODES table, when the NODES parameter value is changed.\r
-     * Nodes are only added to the table, they are never deleted.  The node name is normalized\r
-     * to contain the domain (if missing).\r
+     * Add nodes to the NODES table, when the NODES parameter value is changed. Nodes are only added to the table, they\r
+     * are never deleted.  The node name is normalized to contain the domain (if missing).\r
      *\r
      * @param nodes a pipe separated list of the current nodes\r
      */\r
     public static void setNodes(String[] nodes) {\r
-        if (map == null)\r
+        if (map == null) {\r
             reload();\r
+        }\r
         int nextid = 0;\r
         for (Integer n : map.values()) {\r
-            if (n >= nextid)\r
+            if (n >= nextid) {\r
                 nextid = n + 1;\r
+            }\r
         }\r
         // take | separated list, add domain if needed.\r
 \r
@@ -136,8 +137,9 @@ public abstract class NodeClass extends Syncable {
 \r
     public static Integer lookupNodeName(final String name) {\r
         Integer n = map.get(name);\r
-        if (n == null)\r
+        if (n == null) {\r
             throw new IllegalArgumentException("Invalid node name: " + name);\r
+        }\r
         return n;\r
     }\r
 \r
@@ -148,8 +150,9 @@ public abstract class NodeClass extends Syncable {
             if (s.endsWith("*")) {\r
                 s = s.substring(0, s.length() - 1);\r
                 for (String s2 : keyset) {\r
-                    if (s2.startsWith(s))\r
+                    if (s2.startsWith(s)) {\r
                         coll.add(s2);\r
+                    }\r
                 }\r
             } else if (keyset.contains(s)) {\r
                 coll.add(s);\r
@@ -162,14 +165,6 @@ public abstract class NodeClass extends Syncable {
         return coll;\r
     }\r
 \r
-    protected String lookupNodeID(int n) {\r
-        for (String s : map.keySet()) {\r
-            if (map.get(s) == n)\r
-                return s;\r
-        }\r
-        return null;\r
-    }\r
-\r
     public static String normalizeNodename(String s) {\r
         if (s != null && s.indexOf('.') <= 0) {\r
             Parameters p = Parameters.getParameter(Parameters.PROV_DOMAIN);\r
@@ -184,4 +179,13 @@ public abstract class NodeClass extends Syncable {
         }\r
 \r
     }\r
+\r
+    protected String lookupNodeID(int n) {\r
+        for (String s : map.keySet()) {\r
+            if (map.get(s) == n) {\r
+                return s;\r
+            }\r
+        }\r
+        return null;\r
+    }\r
 }\r
index afb0de2..dec3cc1 100644 (file)
@@ -29,14 +29,7 @@ import java.io.Writer;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.Set;
+import java.util.*;
 
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -139,6 +132,46 @@ public class LOGJSONObject {
             return object == null || object == this;
         }
 
+        /**
+         * Returns a hash code value for the object. This method is
+         * supported for the benefit of hash tables such as those provided by
+         * {@link HashMap}.
+         * <p>
+         * The general contract of {@code hashCode} is:
+         * <ul>
+         * <li>Whenever it is invoked on the same object more than once during
+         * an execution of a Java application, the {@code hashCode} method
+         * must consistently return the same integer, provided no information
+         * used in {@code equals} comparisons on the object is modified.
+         * This integer need not remain consistent from one execution of an
+         * application to another execution of the same application.
+         * <li>If two objects are equal according to the {@code equals(Object)}
+         * method, then calling the {@code hashCode} method on each of
+         * the two objects must produce the same integer result.
+         * <li>It is <em>not</em> required that if two objects are unequal
+         * according to the {@link Object#equals(Object)}
+         * method, then calling the {@code hashCode} method on each of the
+         * two objects must produce distinct integer results.  However, the
+         * programmer should be aware that producing distinct integer results
+         * for unequal objects may improve the performance of hash tables.
+         * </ul>
+         * <p>
+         * As much as is reasonably practical, the hashCode method defined by
+         * class {@code Object} does return distinct integers for distinct
+         * objects. (This is typically implemented by converting the internal
+         * address of the object into an integer, but this implementation
+         * technique is not required by the
+         * Java&trade; programming language.)
+         *
+         * @return a hash code value for this object.
+         * @see Object#equals(Object)
+         * @see System#identityHashCode
+         */
+        @Override
+        public int hashCode() {
+            return super.hashCode();
+        }
+
         /**
          * Get the "null" string value.
          *
index a5281c0..28740c0 100644 (file)
@@ -152,41 +152,40 @@ public class DailyLatencyReport extends ReportBase {
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            PreparedStatement ps = conn.prepareStatement(SELECT_SQL);\r
-            ps.setLong(1, from);\r
-            ps.setLong(2, to);\r
-            ResultSet rs = ps.executeQuery();\r
-            while (rs.next()) {\r
-                String id   = rs.getString("PUBLISH_ID");\r
-                int feed    = rs.getInt("FEEDID");\r
-                long etime  = rs.getLong("EVENT_TIME");\r
-                String type = rs.getString("TYPE");\r
-                String fid  = rs.getString("FEED_FILEID");\r
-                long clen   = rs.getLong("CONTENT_LENGTH");\r
-                String date = sdf.format(new Date(getPstart(id)));\r
-                String key  = date + "," + feed;\r
-                Counters c = map.get(key);\r
-                if (c == null) {\r
-                    c = new Counters(date, feed);\r
-                    map.put(key, c);\r
+            try(PreparedStatement ps = conn.prepareStatement(SELECT_SQL)) {\r
+                ps.setLong(1, from);\r
+                ps.setLong(2, to);\r
+                try(ResultSet rs = ps.executeQuery()) {\r
+                    while (rs.next()) {\r
+                        String id = rs.getString("PUBLISH_ID");\r
+                        int feed = rs.getInt("FEEDID");\r
+                        long etime = rs.getLong("EVENT_TIME");\r
+                        String type = rs.getString("TYPE");\r
+                        String fid = rs.getString("FEED_FILEID");\r
+                        long clen = rs.getLong("CONTENT_LENGTH");\r
+                        String date = sdf.format(new Date(getPstart(id)));\r
+                        String key = date + "," + feed;\r
+                        Counters c = map.get(key);\r
+                        if (c == null) {\r
+                            c = new Counters(date, feed);\r
+                            map.put(key, c);\r
+                        }\r
+                        c.addEvent(etime, type, id, fid, clen);\r
+                    }\r
                 }\r
-                c.addEvent(etime, type, id, fid, clen);\r
+\r
+                db.release(conn);\r
             }\r
-            rs.close();\r
-            ps.close();\r
-            db.release(conn);\r
         } catch (SQLException e) {\r
             e.printStackTrace();\r
         }\r
         logger.debug("Query time: " + (System.currentTimeMillis()-start) + " ms");\r
-        try {\r
-            PrintWriter os = new PrintWriter(outfile);\r
+        try (PrintWriter os = new PrintWriter(outfile)){\r
             os.println("date,feedid,minsize,maxsize,avgsize,minlat,maxlat,avglat,fanout");\r
             for (String key : new TreeSet<String>(map.keySet())) {\r
                 Counters c = map.get(key);\r
                 os.println(c.toString());\r
             }\r
-            os.close();\r
         } catch (FileNotFoundException e) {\r
             System.err.println("File cannot be written: "+outfile);\r
         }\r
index ba8f15a..549511b 100644 (file)
@@ -145,40 +145,38 @@ public class LatencyReport extends ReportBase {
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            PreparedStatement ps = conn.prepareStatement(SELECT_SQL);\r
+            try(PreparedStatement ps = conn.prepareStatement(SELECT_SQL)){\r
             ps.setLong(1, from);\r
             ps.setLong(2, to);\r
-            ResultSet rs = ps.executeQuery();\r
-            PrintWriter os = new PrintWriter(outfile);\r
-            os.println("recordid,feedid,uri,size,min,max,avg,fanout");\r
-            Counters c = null;\r
-            while (rs.next()) {\r
-                long etime = rs.getLong("EVENT_TIME");\r
-                String type = rs.getString("TYPE");\r
-                String id = rs.getString("PUBLISH_ID");\r
-                String fid = rs.getString("FEED_FILEID");\r
-                int feed = rs.getInt("FEEDID");\r
-                long clen = rs.getLong("CONTENT_LENGTH");\r
-                if (c != null && !id.equals(c.id)) {\r
-                    String line = id + "," + c.toString();\r
-                    os.println(line);\r
-                    c = null;\r
+            try(ResultSet rs = ps.executeQuery()) {\r
+                try(PrintWriter os = new PrintWriter(outfile)) {\r
+                    os.println("recordid,feedid,uri,size,min,max,avg,fanout");\r
+                    Counters c = null;\r
+                    while (rs.next()) {\r
+                        long etime = rs.getLong("EVENT_TIME");\r
+                        String type = rs.getString("TYPE");\r
+                        String id = rs.getString("PUBLISH_ID");\r
+                        String fid = rs.getString("FEED_FILEID");\r
+                        int feed = rs.getInt("FEEDID");\r
+                        long clen = rs.getLong("CONTENT_LENGTH");\r
+                        if (c != null && !id.equals(c.id)) {\r
+                            String line = id + "," + c.toString();\r
+                            os.println(line);\r
+                            c = null;\r
+                        }\r
+                        if (c == null) {\r
+                            c = new Counters(id, feed, clen, fid);\r
+                        }\r
+                        if (feed != c.feedid)\r
+                            System.err.println("Feed ID mismatch, " + feed + " <=> " + c.feedid);\r
+                        if (clen != c.clen)\r
+                            System.err.println("Cont Len mismatch, " + clen + " <=> " + c.clen);\r
+                        c.addEvent(type, etime);\r
+                    }\r
                 }\r
-                if (c == null) {\r
-                    c = new Counters(id, feed, clen, fid);\r
-                }\r
-                if (feed != c.feedid)\r
-                    System.err.println("Feed ID mismatch, " + feed + " <=> " + c.feedid);\r
-                if (clen != c.clen)\r
-                    System.err.println("Cont Len mismatch, " + clen + " <=> " + c.clen);\r
-//                if (fid != c.fileid)\r
-//                    System.err.println("File ID mismatch, "+fid+" <=> "+c.fileid);\r
-                c.addEvent(type, etime);\r
+             db.release(conn);\r
+            }\r
             }\r
-            rs.close();\r
-            ps.close();\r
-            db.release(conn);\r
-            os.close();\r
         } catch (FileNotFoundException e) {\r
             System.err.println("File cannot be written: " + outfile);\r
         } catch (SQLException e) {\r
index e00c394..51beac9 100644 (file)
@@ -98,62 +98,61 @@ public class SubscriberReport extends ReportBase {
     public void run() {\r
         Map<String, Counters> map = new HashMap<String, Counters>();\r
         long start = System.currentTimeMillis();\r
+\r
         try {\r
             DB db = new DB();\r
             @SuppressWarnings("resource")\r
             Connection conn = db.getConnection();\r
-            PreparedStatement ps = conn.prepareStatement(SELECT_SQL);\r
-            ps.setLong(1, from);\r
-            ps.setLong(2, to);\r
-            ResultSet rs = ps.executeQuery();\r
-            while (rs.next()) {\r
-                String date = rs.getString("DATE");\r
-                int sub = rs.getInt("DELIVERY_SUBID");\r
-                int res = rs.getInt("RESULT");\r
-                int count = rs.getInt("COUNT");\r
-                String key = date + "," + sub;\r
-                Counters c = map.get(key);\r
-                if (c == null) {\r
-                    c = new Counters(date, sub);\r
-                    map.put(key, c);\r
+            try(PreparedStatement ps = conn.prepareStatement(SELECT_SQL)) {\r
+                ps.setLong(1, from);\r
+                ps.setLong(2, to);\r
+                try(ResultSet rs = ps.executeQuery()) {\r
+                    while (rs.next()) {\r
+                        String date = rs.getString("DATE");\r
+                        int sub = rs.getInt("DELIVERY_SUBID");\r
+                        int res = rs.getInt("RESULT");\r
+                        int count = rs.getInt("COUNT");\r
+                        String key = date + "," + sub;\r
+                        Counters c = map.get(key);\r
+                        if (c == null) {\r
+                            c = new Counters(date, sub);\r
+                            map.put(key, c);\r
+                        }\r
+                        c.addCounts(res, count);\r
+                    }\r
                 }\r
-                c.addCounts(res, count);\r
             }\r
-            rs.close();\r
-            ps.close();\r
 \r
-            ps = conn.prepareStatement(SELECT_SQL2);\r
-            ps.setLong(1, from);\r
-            ps.setLong(2, to);\r
-            rs = ps.executeQuery();\r
-            while (rs.next()) {\r
-                String date = rs.getString("DATE");\r
-                int sub = rs.getInt("DELIVERY_SUBID");\r
-                int count = rs.getInt("COUNT");\r
-                String key = date + "," + sub;\r
-                Counters c = map.get(key);\r
-                if (c == null) {\r
-                    c = new Counters(date, sub);\r
-                    map.put(key, c);\r
-                }\r
-                c.addDlxCount(count);\r
-            }\r
-            rs.close();\r
-            ps.close();\r
+           try( PreparedStatement ps2 = conn.prepareStatement(SELECT_SQL2)) {\r
+               ps2.setLong(1, from);\r
+               ps2.setLong(2, to);\r
+               try(ResultSet rs2 = ps2.executeQuery()) {\r
+                   while (rs2.next()) {\r
+                       String date = rs2.getString("DATE");\r
+                       int sub = rs2.getInt("DELIVERY_SUBID");\r
+                       int count = rs2.getInt("COUNT");\r
+                       String key = date + "," + sub;\r
+                       Counters c = map.get(key);\r
+                       if (c == null) {\r
+                           c = new Counters(date, sub);\r
+                           map.put(key, c);\r
+                       }\r
+                       c.addDlxCount(count);\r
+                   }\r
+                  }\r
+           }\r
 \r
             db.release(conn);\r
         } catch (SQLException e) {\r
             e.printStackTrace();\r
         }\r
         logger.debug("Query time: " + (System.currentTimeMillis() - start) + " ms");\r
-        try {\r
-            PrintWriter os = new PrintWriter(outfile);\r
+        try (PrintWriter os = new PrintWriter(outfile)){\r
             os.println("date,subid,count100,count200,count300,count400,count500,countminus1,countdlx");\r
             for (String key : new TreeSet<String>(map.keySet())) {\r
                 Counters c = map.get(key);\r
                 os.println(c.toString());\r
             }\r
-            os.close();\r
         } catch (FileNotFoundException e) {\r
             System.err.println("File cannot be written: " + outfile);\r
         }\r
index 169db0d..34e158a 100644 (file)
@@ -36,6 +36,7 @@ import java.util.HashMap;
 import java.util.Map;\r
 import java.util.TreeSet;\r
 \r
+import org.apache.log4j.Logger;\r
 import org.onap.dmaap.datarouter.provisioning.utils.DB;\r
 \r
 /**\r
@@ -57,7 +58,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
 public class VolumeReport extends ReportBase {\r
     private static final String SELECT_SQL = "select EVENT_TIME, TYPE, FEEDID, CONTENT_LENGTH, RESULT" +\r
             " from LOG_RECORDS where EVENT_TIME >= ? and EVENT_TIME <= ? LIMIT ?, ?";\r
-\r
+    private Logger loggerVolumeReport=Logger.getLogger("org.onap.dmaap.datarouter.reports");\r
     private class Counters {\r
         public int filespublished, filesdelivered, filesexpired;\r
         public long bytespublished, bytesdelivered, bytesexpired;\r
@@ -83,58 +84,64 @@ public class VolumeReport extends ReportBase {
             final long stepsize = 6000000L;\r
             boolean go_again = true;\r
             for (long i = 0; go_again; i += stepsize) {\r
-                PreparedStatement ps = conn.prepareStatement(SELECT_SQL);\r
-                ps.setLong(1, from);\r
-                ps.setLong(2, to);\r
-                ps.setLong(3, i);\r
-                ps.setLong(4, stepsize);\r
-                ResultSet rs = ps.executeQuery();\r
-                go_again = false;\r
-                while (rs.next()) {\r
-                    go_again = true;\r
-                    long etime = rs.getLong("EVENT_TIME");\r
-                    String type = rs.getString("TYPE");\r
-                    int feed = rs.getInt("FEEDID");\r
-                    long clen = rs.getLong("CONTENT_LENGTH");\r
-                    String key = sdf.format(new Date(etime)) + ":" + feed;\r
-                    Counters c = map.get(key);\r
-                    if (c == null) {\r
-                        c = new Counters();\r
-                        map.put(key, c);\r
-                    }\r
-                    if (type.equalsIgnoreCase("pub")) {\r
-                        c.filespublished++;\r
-                        c.bytespublished += clen;\r
-                    } else if (type.equalsIgnoreCase("del")) {\r
-                        // Only count successful deliveries\r
-                        int statusCode = rs.getInt("RESULT");\r
-                        if (statusCode >= 200 && statusCode < 300) {\r
-                            c.filesdelivered++;\r
-                            c.bytesdelivered += clen;\r
+                try (PreparedStatement ps = conn.prepareStatement(SELECT_SQL)) {\r
+                    ps.setLong(1, from);\r
+                    ps.setLong(2, to);\r
+                    ps.setLong(3, i);\r
+                    ps.setLong(4, stepsize);\r
+                    try(ResultSet rs = ps.executeQuery()) {\r
+                        go_again = false;\r
+                        while (rs.next()) {\r
+                            go_again = true;\r
+                            long etime = rs.getLong("EVENT_TIME");\r
+                            String type = rs.getString("TYPE");\r
+                            int feed = rs.getInt("FEEDID");\r
+                            long clen = rs.getLong("CONTENT_LENGTH");\r
+                            String key = sdf.format(new Date(etime)) + ":" + feed;\r
+                            Counters c = map.get(key);\r
+                            if (c == null) {\r
+                                c = new Counters();\r
+                                map.put(key, c);\r
+                            }\r
+                            if (type.equalsIgnoreCase("pub")) {\r
+                                c.filespublished++;\r
+                                c.bytespublished += clen;\r
+                            } else if (type.equalsIgnoreCase("del")) {\r
+                                // Only count successful deliveries\r
+                                int statusCode = rs.getInt("RESULT");\r
+                                if (statusCode >= 200 && statusCode < 300) {\r
+                                    c.filesdelivered++;\r
+                                    c.bytesdelivered += clen;\r
+                                }\r
+                            } else if (type.equalsIgnoreCase("exp")) {\r
+                                c.filesexpired++;\r
+                                c.bytesexpired += clen;\r
+                            }\r
                         }\r
-                    } else if (type.equalsIgnoreCase("exp")) {\r
-                        c.filesexpired++;\r
-                        c.bytesexpired += clen;\r
                     }\r
+\r
+                }\r
+                catch (SQLException sqlException)\r
+                {\r
+                    loggerVolumeReport.error("SqlException",sqlException);\r
                 }\r
-                rs.close();\r
-                ps.close();\r
             }\r
+\r
             db.release(conn);\r
         } catch (SQLException e) {\r
             e.printStackTrace();\r
         }\r
         logger.debug("Query time: " + (System.currentTimeMillis() - start) + " ms");\r
-        try {\r
-            PrintWriter os = new PrintWriter(outfile);\r
+        try (PrintWriter os = new PrintWriter(outfile)) {\r
             os.println("date,feedid,filespublished,bytespublished,filesdelivered,bytesdelivered,filesexpired,bytesexpired");\r
-            for (String key : new TreeSet<String>(map.keySet())) {\r
+            for(String key :new TreeSet<String>(map.keySet()))\r
+            {\r
                 Counters c = map.get(key);\r
                 String[] p = key.split(":");\r
                 os.println(String.format("%s,%s,%s", p[0], p[1], c.toString()));\r
             }\r
-            os.close();\r
-        catch (FileNotFoundException e) {\r
+        }\r
+        catch (FileNotFoundException e) {\r
             System.err.println("File cannot be written: " + outfile);\r
         }\r
     }\r
old mode 100644 (file)
new mode 100755 (executable)
index e01ce3b..356a67a
@@ -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'),
old mode 100644 (file)
new mode 100755 (executable)
index 7758a64..744bc9c
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index 7144621..3e5e1d0
@@ -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) {
index 61d030d..8cc4868 100755 (executable)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index 35bc85d..87390bc
  ******************************************************************************/
 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);
     }
index 414fc18..c7f639e 100644 (file)
@@ -38,8 +38,8 @@ public class DrServletTestBase {
     public void setUp() throws Exception {
         Properties props = new Properties();
         props.setProperty("org.onap.dmaap.datarouter.provserver.isaddressauthenabled", "false");
-        props.setProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir", "datarouter-prov/unit-test-logs");
-        props.setProperty("org.onap.dmaap.datarouter.provserver.spooldir", "resources/spooldir");
+        props.setProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir", "unit-test-logs");
+        props.setProperty("org.onap.dmaap.datarouter.provserver.spooldir", "unit-test-logs/spool");
         props.setProperty("org.onap.dmaap.datarouter.provserver.https.relaxation", "false");
         FieldUtils.writeDeclaredStaticField(DB.class, "props", props, true);
         FieldUtils.writeDeclaredStaticField(BaseServlet.class, "startmsgFlag", false, true);
index f5302cb..cb8a28d 100755 (executable)
@@ -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)));
     }
old mode 100644 (file)
new mode 100755 (executable)
index a0831b7..fa0caea
@@ -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)));
     }
old mode 100755 (executable)
new mode 100644 (file)
index f834244..5f6b7ae
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
 
+import java.io.File;
 import java.net.InetAddress;
 import java.util.HashMap;
 import java.util.Map;
@@ -89,6 +90,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)));
@@ -151,6 +154,19 @@ public class InternalServletTest extends DrServletTestBase {
         .sendError(eq(HttpServletResponse.SC_NO_CONTENT), argThat(notNullValue(String.class)));
   }
 
+  @Test
+  public void Given_Request_Is_HTTP_GET_Starts_With_Logs_In_Endpoint_And_File_Exists_Then_Request_Returns_Ok()
+      throws Exception {
+    when(request.getPathInfo()).thenReturn("/logs/testFile.txt");
+    File testFile = new File("unit-test-logs/testFile.txt");
+    testFile.createNewFile();
+    testFile.deleteOnExit();
+    ServletOutputStream outStream = mock(ServletOutputStream.class);
+    when(response.getOutputStream()).thenReturn(outStream);
+    internalServlet.doGet(request, response);
+    verify(response).setStatus(eq(HttpServletResponse.SC_OK));
+  }
+
   @Test
   public void Given_Request_Is_HTTP_GET_With_Api_In_Endpoint_Request_Succeeds() throws Exception {
     when(request.getPathInfo()).thenReturn("/api/Key");
@@ -165,10 +181,7 @@ public class InternalServletTest extends DrServletTestBase {
   public void Given_Request_Is_HTTP_GET_With_Drlogs_In_Endpoint_Request_Succeeds()
       throws Exception {
     when(request.getPathInfo()).thenReturn("/drlogs/");
-    PowerMockito.mockStatic(LogfileLoader.class);
-    LogfileLoader logfileLoader = mock(LogfileLoader.class);
-    when(logfileLoader.getBitSet()).thenReturn(new RLEBitSet());
-    PowerMockito.when(LogfileLoader.getLoader()).thenReturn(logfileLoader);
+    mockLogfileLoader();
     ServletOutputStream outStream = mock(ServletOutputStream.class);
     when(response.getOutputStream()).thenReturn(outStream);
     internalServlet.doGet(request, response);
@@ -188,6 +201,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 +246,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 +293,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)));
   }
@@ -326,6 +342,21 @@ public class InternalServletTest extends DrServletTestBase {
     verify(response).setStatus(eq(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE));
   }
 
+  @Test
+  public void Given_Request_Is_HTTP_POST_To_Logs_Then_Request_Succeeds()
+      throws Exception {
+    when(request.getHeader("Content-Encoding")).thenReturn("gzip");
+    when(request.getPathInfo()).thenReturn("/logs/");
+    ServletInputStream inStream = mock(ServletInputStream.class);
+    when(request.getInputStream()).thenReturn(inStream);
+    File testDir = new File("unit-test-logs/spool");
+    testDir.mkdirs();
+    testDir.deleteOnExit();
+    mockLogfileLoader();
+    internalServlet.doPost(request, response);
+    verify(response).setStatus(eq(HttpServletResponse.SC_CREATED));
+  }
+
   @Test
   public void Given_Request_Is_HTTP_POST_To_Drlogs_And_Then_Unsupported_Media_Type_Response_Is_Generated()
       throws Exception {
@@ -447,4 +478,11 @@ public class InternalServletTest extends DrServletTestBase {
     Map<String, Integer> map = new HashMap<>();
     FieldUtils.writeDeclaredStaticField(NodeClass.class, "map", map, true);
   }
+
+  private void mockLogfileLoader() {
+    PowerMockito.mockStatic(LogfileLoader.class);
+    LogfileLoader logfileLoader = mock(LogfileLoader.class);
+    when(logfileLoader.getBitSet()).thenReturn(new RLEBitSet());
+    PowerMockito.when(LogfileLoader.getLoader()).thenReturn(logfileLoader);
+  }
 }
index 6371580..34421f5 100755 (executable)
@@ -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)));
     }
 
index cdf96ba..25341d4 100755 (executable)
@@ -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)));
     }
old mode 100644 (file)
new mode 100755 (executable)
index b42e3a7..c566067
@@ -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/DeliveryRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/DeliveryRecordTest.java
new file mode 100644 (file)
index 0000000..3329b73
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * ============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.Test;
+import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
+
+import java.text.ParseException;
+
+public class DeliveryRecordTest {
+    
+    private DeliveryRecord deliveryRecord;
+    
+    @Test
+    public void Validate_Constructor_Creates_Object_With_Get_Methods() throws ParseException {
+        String[] args = {"2018-08-29-10-10-10-543.", "del", "238465493.fileName", "1","285", "123/file.txt","GET","application/json","2000","example","100"};
+        deliveryRecord = new DeliveryRecord(args);
+        Assert.assertEquals("238465493.fileName", deliveryRecord.getPublishId());
+        Assert.assertEquals(1, deliveryRecord.getFeedid());
+        Assert.assertEquals(285, deliveryRecord.getSubid());
+        Assert.assertEquals("123/file.txt", deliveryRecord.getRequestUri());
+        Assert.assertEquals("GET", deliveryRecord.getMethod());
+        Assert.assertEquals("file.txt", deliveryRecord.getFileid());
+        Assert.assertEquals("application/json", deliveryRecord.getContentType());
+        Assert.assertEquals(2000, deliveryRecord.getContentLength());
+        Assert.assertEquals("example", deliveryRecord.getUser());
+        Assert.assertEquals(100, deliveryRecord.getResult());
+    }
+
+    @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","285", "123/file.txt","GET","application/json","2000","example","100"};
+        deliveryRecord = new DeliveryRecord(args);
+        deliveryRecord.setContentLength(265);
+        deliveryRecord.setEventTime(1535533810543L);
+        deliveryRecord.setPublishId("2345657324.fileName");
+        deliveryRecord.setSubid(287);
+        deliveryRecord.setFeedid(2);
+        deliveryRecord.setRequestUri("/delete/2");
+        deliveryRecord.setMethod("PUT");
+        deliveryRecord.setContentType("application/json");
+        deliveryRecord.setFileid("file2.txt");
+        deliveryRecord.setUser("example2");
+        deliveryRecord.setResult(300);
+        LOGJSONObject deliveryRecordJson = createBaseLogRecordJson();
+        String deliveryRecordString = stripBracketFromJson(deliveryRecordJson);
+        String deliveryRecordStringObject = stripBracketFromJson(deliveryRecord.asJSONObject());
+        Assert.assertTrue(deliveryRecordStringObject.matches(deliveryRecordString));
+    }
+
+    private LOGJSONObject createBaseLogRecordJson() {
+        LOGJSONObject deliveryRecordJson = new LOGJSONObject();
+        deliveryRecordJson.put("statusCode", 300);
+        deliveryRecordJson.put("deliveryId", "example2");
+        deliveryRecordJson.put("publishId", "2345657324.fileName");
+        deliveryRecordJson.put("requestURI", "/delete/2");
+        deliveryRecordJson.put("method", "PUT");
+        deliveryRecordJson.put("contentType", "application/json");
+        deliveryRecordJson.put("type", "del");
+        deliveryRecordJson.put("date", "2018-08-29T[0-1][0-9]:10:10.543Z");
+        deliveryRecordJson.put("contentLength", 265);
+
+        return deliveryRecordJson;
+    }
+
+    private String stripBracketFromJson(LOGJSONObject deliveryRecordJson) {
+        String deliveryRecordString = deliveryRecordJson.toString();
+        deliveryRecordString = deliveryRecordString.substring(1, deliveryRecordString.length() - 1);
+        return deliveryRecordString;
+    }
+}
index 098765c..91d72af 100644 (file)
  ******************************************************************************/
 package org.onap.dmaap.datarouter.provisioning.beans;
 
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.junit.*;
+import org.onap.dmaap.datarouter.provisioning.utils.DB;
 
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import java.util.Collection;
 import java.util.Date;
+import java.util.List;
 
-
-@RunWith(PowerMockRunner.class)
-@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.provisioning.beans.Group"})
 public class GroupTest {
-    private Group group;
+  private static EntityManagerFactory emf;
+  private static EntityManager em;
+  private Group group;
+  private DB db;
+
+  @BeforeClass
+  public static void init() {
+    emf = Persistence.createEntityManagerFactory("dr-unit-tests");
+    em = emf.createEntityManager();
+    System.setProperty(
+        "org.onap.dmaap.datarouter.provserver.properties",
+        "src/test/resources/h2Database.properties");
+  }
+
+  @AfterClass
+  public static void tearDownClass() {
+    em.clear();
+    em.close();
+    emf.close();
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    db = new DB();
+    group = new Group("GroupTest", "", "");
+    group.doInsert(db.getConnection());
+  }
+
+  @Test
+  public void Given_Group_Exists_In_Db_GetAllGroups_Returns_Correct_Group() {
+    Collection<Group> groups = Group.getAllgroups();
+    Assert.assertEquals("Group1", ((List<Group>) groups).get(0).getName());
+  }
+
+  @Test
+  public void Given_Group_Inserted_Into_Db_GetGroupMatching_Returns_Created_Group() {
+    Assert.assertEquals(group, Group.getGroupMatching(group));
+  }
+
+  @Test
+  public void Given_Group_Inserted_With_Same_Name_GetGroupMatching_With_Id_Returns_Correct_Group()
+      throws Exception {
+    Group sameGroupName = new Group("GroupTest", "This group has a description", "");
+    sameGroupName.doInsert(db.getConnection());
+    Assert.assertEquals(
+        "This group has a description", Group.getGroupMatching(group, 2).getDescription());
+    sameGroupName.doDelete(db.getConnection());
+  }
 
-    @Test
-    public void Validate_Group_Created_With_Default_Contructor() {
-        group = new Group();
-        Assert.assertEquals(group.getGroupid(), -1);
-        Assert.assertEquals(group.getName(), "");
-    }
+  @Test
+  public void Given_Group_Inserted_GetGroupById_Returns_Correct_Group() {
+    Assert.assertEquals(group, Group.getGroupById(group.getGroupid()));
+  }
 
-    @Test
-    public void Validate_Getters_And_Setters() {
-        group = new Group();
-        group.setGroupid(1);
-        group.setAuthid("Auth");
-        group.setClassification("Class");
-        group.setDescription("Description");
-        Date date = new Date();
-        group.setLast_mod(date);
-        group.setMembers("Members");
-        group.setName("NewName");
-        Assert.assertEquals(1, group.getGroupid());
-        Assert.assertEquals("Auth", group.getAuthid());
-        Assert.assertEquals("Class", group.getClassification());
-        Assert.assertEquals("Description", group.getDescription());
-        Assert.assertEquals(date, group.getLast_mod());
-        Assert.assertEquals("Members", group.getMembers());
-    }
+  @Test
+  public void Given_Group_AuthId_Updated_GetGroupByAuthId_Returns_Correct_Group() throws Exception {
+    group.setAuthid("Basic TmFtZTp6Z04wMFkyS3gybFppbXltNy94ZDhuMkdEYjA9");
+    group.doUpdate(db.getConnection());
+    Assert.assertEquals(group, Group.getGroupByAuthId("Basic TmFtZTp6Z04wMFkyS3gybFppbXltNy94ZDhuMkdEYjA9"));
+  }
 
-    @Test
-    public void Validate_Equals() {
-        group = new Group();
-        group.setGroupid(1);
-        group.setAuthid("Auth");
-        group.setClassification("Class");
-        group.setDescription("Description");
-        Date date = new Date();
-        group.setLast_mod(date);
-        group.setMembers("Members");
-        group.setName("NewName");
-        Group group2 = new Group("NewName", "Description", "Members");
-        group2.setGroupid(1);
-        group2.setAuthid("Auth");
-        group2.setClassification("Class");
-        group2.setLast_mod(date);
-        Assert.assertEquals(group, group2);
-    }
+  @After
+  public void tearDown() throws Exception {
+    group.doDelete(db.getConnection());
+  }
 }
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PubFailRecordTest.java
new file mode 100644 (file)
index 0000000..dd798ab
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * ============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.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.text.ParseException;
+
+@RunWith(PowerMockRunner.class)
+public class PubFailRecordTest {
+
+    private PubFailRecord pubFailRecord;
+
+
+    @Test
+    public void Validate_PubFailRecord_Created_With_Default_Constructor() throws ParseException {
+        String[] args = {"2018-08-29-10-10-10-543.", "PBF", "238465493.fileName",
+                "1", "/publish/1/fileName", "PUT", "application/octet-stream", "285", "200",
+                "172.100.0.3", "user1", "403"};
+        pubFailRecord = new PubFailRecord(args);
+
+        Assert.assertEquals("user1", pubFailRecord.getUser());
+        Assert.assertEquals("172.100.0.3", pubFailRecord.getSourceIP());
+        Assert.assertEquals("403", pubFailRecord.getError());
+        Assert.assertEquals(200, pubFailRecord.getContentLengthReceived());
+    }
+}
diff --git a/datarouter-prov/src/test/resources/META-INF/persistence.xml b/datarouter-prov/src/test/resources/META-INF/persistence.xml
new file mode 100755 (executable)
index 0000000..6b42f8a
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+                                 http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    <persistence-unit name="dr-unit-tests" transaction-type="RESOURCE_LOCAL">
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+        <properties>
+            <!-- Configuring JDBC properties -->
+            <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test;MODE=MySQL;INIT=RUNSCRIPT FROM 'classpath:create.sql';DB_CLOSE_DELAY=-1"/>
+            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
+
+            <!-- Hibernate properties -->
+            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
+            <property name="hibernate.hbm2ddl.auto" value="validate"/>
+            <property name="hibernate.format_sql" value="false"/>
+            <property name="hibernate.show_sql" value="true"/>
+
+        </properties>
+    </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/datarouter-prov/src/test/resources/create.sql b/datarouter-prov/src/test/resources/create.sql
new file mode 100755 (executable)
index 0000000..6e6af1d
--- /dev/null
@@ -0,0 +1,146 @@
+CREATE TABLE FEEDS (
+    FEEDID         INT UNSIGNED NOT NULL PRIMARY KEY,
+    GROUPID        INT(10) UNSIGNED NOT NULL DEFAULT 0,
+    NAME           VARCHAR(255) NOT NULL,
+    VERSION        VARCHAR(20) NOT NULL,
+    DESCRIPTION    VARCHAR(1000),
+    BUSINESS_DESCRIPTION VARCHAR(1000) DEFAULT NULL,
+    AUTH_CLASS     VARCHAR(32) NOT NULL,
+    PUBLISHER      VARCHAR(8) NOT NULL,
+    SELF_LINK      VARCHAR(256),
+    PUBLISH_LINK   VARCHAR(256),
+    SUBSCRIBE_LINK VARCHAR(256),
+    LOG_LINK       VARCHAR(256),
+    DELETED        BOOLEAN DEFAULT FALSE,
+    LAST_MOD       TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    SUSPENDED      BOOLEAN DEFAULT FALSE,
+    CREATED_DATE   TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE TABLE FEED_ENDPOINT_IDS (
+    FEEDID        INT UNSIGNED NOT NULL,
+    USERID        VARCHAR(20) NOT NULL,
+    PASSWORD      VARCHAR(32) NOT NULL
+);
+
+CREATE TABLE FEED_ENDPOINT_ADDRS (
+    FEEDID        INT UNSIGNED NOT NULL,
+    ADDR          VARCHAR(44) NOT NULL
+);
+
+CREATE TABLE SUBSCRIPTIONS (
+    SUBID              INT UNSIGNED NOT NULL PRIMARY KEY,
+    FEEDID             INT UNSIGNED NOT NULL,
+    GROUPID            INT(10) UNSIGNED NOT NULL DEFAULT 0,
+    DELIVERY_URL       VARCHAR(256),
+    DELIVERY_USER      VARCHAR(20),
+    DELIVERY_PASSWORD  VARCHAR(32),
+    DELIVERY_USE100    BOOLEAN DEFAULT FALSE,
+    METADATA_ONLY      BOOLEAN DEFAULT FALSE,
+    SUBSCRIBER         VARCHAR(8) NOT NULL,
+    SELF_LINK          VARCHAR(256),
+    LOG_LINK           VARCHAR(256),
+    LAST_MOD           TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    SUSPENDED          BOOLEAN DEFAULT FALSE,
+    CREATED_DATE       TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+
+);
+
+CREATE TABLE PARAMETERS (
+    KEYNAME        VARCHAR(32) NOT NULL PRIMARY KEY,
+    VALUE          VARCHAR(4096) NOT NULL
+);
+
+CREATE TABLE LOG_RECORDS (
+    TYPE           ENUM('pub', 'del', 'exp', 'pbf', 'dlx') NOT NULL,
+    EVENT_TIME     BIGINT NOT NULL,           /* time of the publish request */
+    PUBLISH_ID     VARCHAR(64) NOT NULL,      /* unique ID assigned to this publish attempt */
+    FEEDID         INT UNSIGNED NOT NULL,     /* pointer to feed in FEEDS */
+    REQURI         VARCHAR(256) NOT NULL,     /* request URI */
+    METHOD         ENUM('DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'POST', 'TRACE') NOT NULL, /* HTTP method */
+    CONTENT_TYPE   VARCHAR(256) NOT NULL,     /* content type of published file */
+    CONTENT_LENGTH BIGINT NOT NULL,  /* content length of published file */
+
+    FEED_FILEID    VARCHAR(256),        /* file ID of published file */
+    REMOTE_ADDR    VARCHAR(40),         /* IP address of publishing endpoint */
+    USER           VARCHAR(50),         /* user name of publishing endpoint */
+    STATUS         SMALLINT,            /* status code returned to delivering agent */
+
+    DELIVERY_SUBID INT UNSIGNED,        /* pointer to subscription in SUBSCRIPTIONS */
+    DELIVERY_FILEID  VARCHAR(256),      /* file ID of file being delivered */
+    RESULT         SMALLINT,            /* result received from subscribing agent */
+
+    ATTEMPTS       INT,             /* deliveries attempted */
+    REASON         ENUM('notRetryable', 'retriesExhausted', 'diskFull', 'other'),
+
+    RECORD_ID      BIGINT UNSIGNED NOT NULL PRIMARY KEY, /* unique ID for this record */
+    CONTENT_LENGTH_2 BIGINT,
+
+    INDEX (FEEDID) USING BTREE,
+    INDEX (DELIVERY_SUBID) USING BTREE,
+    INDEX (RECORD_ID) USING BTREE
+) ENGINE = MyISAM;
+
+CREATE TABLE INGRESS_ROUTES (
+    SEQUENCE  INT UNSIGNED NOT NULL,
+    FEEDID    INT UNSIGNED NOT NULL,
+    USERID    VARCHAR(20),
+    SUBNET    VARCHAR(44),
+    NODESET   INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE EGRESS_ROUTES (
+    SUBID    INT UNSIGNED NOT NULL PRIMARY KEY,
+    NODEID   INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NETWORK_ROUTES (
+    FROMNODE INT UNSIGNED NOT NULL,
+    TONODE   INT UNSIGNED NOT NULL,
+    VIANODE  INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NODESETS (
+    SETID   INT UNSIGNED NOT NULL,
+    NODEID  INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NODES (
+    NODEID  INT UNSIGNED NOT NULL PRIMARY KEY,
+    NAME    VARCHAR(255) NOT NULL,
+    ACTIVE  BOOLEAN DEFAULT TRUE
+);
+
+CREATE TABLE GROUPS (
+    GROUPID        INT UNSIGNED NOT NULL PRIMARY KEY,
+    AUTHID         VARCHAR(100) NOT NULL,
+    NAME           VARCHAR(50) NOT NULL,
+    DESCRIPTION    VARCHAR(255),
+    CLASSIFICATION VARCHAR(20) NOT NULL,
+    MEMBERS        TINYTEXT,
+    LAST_MOD       TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+INSERT INTO PARAMETERS VALUES
+    ('ACTIVE_POD',  'dmaap-dr-prov'),
+    ('PROV_ACTIVE_NAME',  'dmaap-dr-prov'),
+    ('STANDBY_POD', ''),
+    ('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', 'dmaap-dr-prov|dmaap-dr-node'),
+    ('PROV_AUTH_SUBJECTS', ''),
+    ('PROV_MAXFEED_COUNT',  '10000'),
+    ('PROV_MAXSUB_COUNT',   '100000'),
+    ('PROV_REQUIRE_CERT', 'false'),
+    ('PROV_REQUIRE_SECURE', 'false'),
+    ('_INT_VALUES', 'LOGROLL_INTERVAL|PROV_MAXFEED_COUNT|PROV_MAXSUB_COUNT|DELIVERY_INIT_RETRY_INTERVAL|DELIVERY_MAX_RETRY_INTERVAL|DELIVERY_RETRY_RATIO|DELIVERY_MAX_AGE')
+    ;
+
+INSERT INTO GROUPS(GROUPID, AUTHID, NAME, DESCRIPTION, CLASSIFICATION, MEMBERS)
+VALUES (1, 'Basic dXNlcjE6cGFzc3dvcmQx', 'Group1', 'First Group for testing', 'Class1', 'Member1');
diff --git a/datarouter-prov/src/test/resources/h2Database.properties b/datarouter-prov/src/test/resources/h2Database.properties
new file mode 100755 (executable)
index 0000000..5bc20ed
--- /dev/null
@@ -0,0 +1,26 @@
+#-------------------------------------------------------------------------------
+# ============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.
+# *
+#-------------------------------------------------------------------------------
+
+# Database access
+org.onap.dmaap.datarouter.db.driver   = org.h2.Driver
+org.onap.dmaap.datarouter.db.url      = jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
index 36b2ac3..9ac1850 100644 (file)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index e01ce3b..356a67a
@@ -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'),
index f8a4d84..35ed74c 100644 (file)
@@ -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.
@@ -25,10 +25,11 @@ services:
   datarouter-prov:
     image: nexus3.onap.org:10003/onap/dmaap/datarouter-prov
     container_name: datarouter-prov
-    hostname: prov.datarouternew.com
+    hostname: dmaap-dr-prov
     ports:
+     - "443:8443"
      - "8443:8443"
-     - "8080:8080"  
+     - "8080:8080"
     volumes:
      - ./prov_data/provserver.properties:/opt/app/datartr/etc/provserver.properties
      - ./prov_data/addSubscriber.txt:/opt/app/datartr/addSubscriber.txt
@@ -37,12 +38,12 @@ services:
       mariadb_container:
         condition: service_healthy
     healthcheck:
-      test: ["CMD", "curl", "-f", "http://prov.datarouternew.com:8080/internal/prov"]
+      test: ["CMD", "curl", "-f", "http://dmaap-dr-prov:8080/internal/prov"]
       interval: 10s
       timeout: 10s
       retries: 5
     extra_hosts:
-      - "node.datarouternew.com:172.100.0.4"
+      - "dmaap-dr-node:172.100.0.4"
     networks:
       testing_net:
         ipv4_address: 172.100.0.3
@@ -50,7 +51,7 @@ services:
   datarouter-node:
     image: nexus3.onap.org:10003/onap/dmaap/datarouter-node
     container_name: datarouter-node
-    hostname: node.datarouternew.com
+    hostname: dmaap-dr-node
     ports:
      - "9443:8443"
      - "9090:8080"
@@ -60,7 +61,7 @@ services:
       datarouter-prov:
         condition: service_healthy
     extra_hosts:
-      - "prov.datarouternew.com:172.100.0.3"
+      - "dmaap-dr-prov:172.100.0.3"
     networks:
       testing_net:
         ipv4_address: 172.100.0.4
@@ -76,7 +77,7 @@ services:
       networks:
         testing_net:
           ipv4_address: 172.100.0.5
-      
+
   mariadb_container:
     image: mariadb:10.2.14
     container_name: mariadb
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 (executable)
index 0000000..4529ccc
Binary files /dev/null and b/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.jks 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 (executable)
index 0000000..096fbb2
Binary files /dev/null and b/docker-compose/node_data/aaf_certs/org.onap.dmaap-dr.trust.jks differ
index 20c5af1..de38cb6 100644 (file)
@@ -2,7 +2,7 @@
 # ============LICENSE_START==================================================
 # * org.onap.dmaap
 # * ===========================================================================
-# * Copyright  2017 AT&T Intellectual Property. All rights reserved.
+# * 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.
 #
 #    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
+#ProvisioningURL:    ${DRTR_PROV_INTURL}
+ProvisioningURL=https://dmaap-dr-prov: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
+#LogUploadURL:    ${DRTR_LOG_URL}
+LogUploadURL=https://dmaap-dr-prov:8443/internal/logs
 
 #
 #    The port number for http as seen within the server
@@ -74,20 +74,19 @@ SpoolDir=/opt/app/datartr/spool
 #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
+KeyStoreFile:/opt/app/datartr/aaf_certs/org.onap.dmaap-dr.jks
 #
 #    The password for the https keystore
 #
-KeyStorePassword=changeit
+KeyStorePassword=4*&GD+w58RUM]01No.CYY;z6
 #
 #    The password for the private key in the https keystore
 #
-KeyPassword=changeit
+KeyPassword=4*&GD+w58RUM]01No.CYY;z6
 #
 #    The type of truststore for https
 #
@@ -96,11 +95,11 @@ 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
+TrustStoreFile=/opt/app/datartr/aaf_certs/org.onap.dmaap-dr.trust.jks
 #
 #    The password for the https truststore
 #
-TrustStorePassword=changeit
+TrustStorePassword=UDXlT6Iu[F)k,Htk92+B,0Xj
 #
 #    The path to the file used to trigger an orderly shutdown
 #
diff --git a/docker-compose/node_data/self_signed/cacerts.jks b/docker-compose/node_data/self_signed/cacerts.jks
deleted file mode 100644 (file)
index dfd8143..0000000
Binary files a/docker-compose/node_data/self_signed/cacerts.jks and /dev/null differ
diff --git a/docker-compose/node_data/self_signed/keystore.jks b/docker-compose/node_data/self_signed/keystore.jks
deleted file mode 100644 (file)
index e5a4e78..0000000
Binary files a/docker-compose/node_data/self_signed/keystore.jks and /dev/null differ
diff --git a/docker-compose/node_data/self_signed/mykey.cer b/docker-compose/node_data/self_signed/mykey.cer
deleted file mode 100644 (file)
index 2a5c9d7..0000000
Binary files a/docker-compose/node_data/self_signed/mykey.cer and /dev/null differ
diff --git a/docker-compose/node_data/self_signed/nodekey.cer b/docker-compose/node_data/self_signed/nodekey.cer
deleted file mode 100644 (file)
index 4cdfdfe..0000000
Binary files a/docker-compose/node_data/self_signed/nodekey.cer and /dev/null differ
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 (executable)
index 0000000..155991a
Binary files /dev/null and b/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.jks 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 (executable)
index 0000000..c8f9ee6
Binary files /dev/null and b/docker-compose/prov_data/aaf_certs/org.onap.dmaap-dr.trust.jks differ
old mode 100644 (file)
new mode 100755 (executable)
index 7758a64..744bc9c
@@ -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/prov_data/self_signed/cacerts.jks b/docker-compose/prov_data/self_signed/cacerts.jks
deleted file mode 100644 (file)
index 76a480a..0000000
Binary files a/docker-compose/prov_data/self_signed/cacerts.jks and /dev/null differ
diff --git a/docker-compose/prov_data/self_signed/keystore.jks b/docker-compose/prov_data/self_signed/keystore.jks
deleted file mode 100644 (file)
index 2c22b4a..0000000
Binary files a/docker-compose/prov_data/self_signed/keystore.jks and /dev/null differ
diff --git a/docker-compose/prov_data/self_signed/mykey.cer b/docker-compose/prov_data/self_signed/mykey.cer
deleted file mode 100644 (file)
index 2a5c9d7..0000000
Binary files a/docker-compose/prov_data/self_signed/mykey.cer and /dev/null differ