Fix datarouter-prov server issue 19/60719/3
authoreconwar <conor.ward@ericsson.com>
Wed, 15 Aug 2018 12:12:42 +0000 (12:12 +0000)
committerRonan Keogh <ronan.keogh@ericsson.com>
Thu, 16 Aug 2018 13:43:05 +0000 (14:43 +0100)
Change-Id: Id9637c56d39156da60c167dfb8f375f4cb498f55
Signed-off-by: Conor Ward <conor.ward@ericsson.com>
Issue-ID: DMAAP-596

datarouter-node/pom.xml
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
datarouter-prov/pom.xml
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java

index fb28724..bb0b7ff 100755 (executable)
             <artifactId>eelf-core</artifactId>
             <version>0.0.1</version>
         </dependency>
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.5</version>
-        </dependency>
         <dependency>
             <groupId>com.thoughtworks.xstream</groupId>
             <artifactId>xstream</artifactId>
index b9cdb54..f9d82a7 100644 (file)
@@ -92,12 +92,13 @@ public class NodeMain {
         Server server = new Server();
 
         // HTTP configuration
-        HttpConfiguration http_config = new HttpConfiguration();
-        http_config.setIdleTimeout(2000);
-        http_config.setRequestHeaderSize(2048);
+        HttpConfiguration httpConfiguration = new HttpConfiguration();
+        httpConfiguration.setIdleTimeout(2000);
+        httpConfiguration.setRequestHeaderSize(2048);
 
-        ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
-        http.setPort(ncm.getHttpPort());
+        // HTTP connector
+        ServerConnector httpServerConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
+        httpServerConnector.setPort(ncm.getHttpPort());
 
         // HTTPS configuration
         SslContextFactory sslContextFactory = new SslContextFactory();
@@ -105,23 +106,28 @@ public class NodeMain {
         sslContextFactory.setKeyStorePath(ncm.getKSFile());
         sslContextFactory.setKeyStorePassword(ncm.getKSPass());
         sslContextFactory.setKeyManagerPassword(ncm.getKPass());
-
-        HttpConfiguration https_config = new HttpConfiguration(http_config);
-        https_config.setRequestHeaderSize(8192);
-
-        ServerConnector https = new ServerConnector(server,
-                new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
-                new HttpConnectionFactory(https_config));
-        https.setPort(ncm.getHttpsPort());
-        https.setIdleTimeout(500000);
-        https.setAcceptQueueSize(2);
-
         /* Skip SSLv3 Fixes */
         sslContextFactory.addExcludeProtocols("SSLv3");
         logger.info("Excluded protocols node-" + sslContextFactory.getExcludeProtocols());
         /* End of SSLv3 Fixes */
 
-        server.setConnectors(new Connector[]{http, https});
+        HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration);
+        httpsConfiguration.setRequestHeaderSize(8192);
+
+        SecureRequestCustomizer secureRequestCustomizer = new SecureRequestCustomizer();
+        secureRequestCustomizer.setStsMaxAge(2000);
+        secureRequestCustomizer.setStsIncludeSubDomains(true);
+        httpsConfiguration.addCustomizer(secureRequestCustomizer);
+
+        // HTTPS connector
+        ServerConnector httpsServerConnector = new ServerConnector(server,
+                new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
+                new HttpConnectionFactory(httpsConfiguration));
+        httpsServerConnector.setPort(ncm.getHttpsPort());
+        httpsServerConnector.setIdleTimeout(500000);
+        httpsServerConnector.setAcceptQueueSize(2);
+
+        server.setConnectors(new Connector[]{httpServerConnector, httpsServerConnector});
         ServletContextHandler ctxt = new ServletContextHandler(0);
         ctxt.setContextPath("/");
         server.setHandler(ctxt);
index a0650a0..a0624d2 100755 (executable)
             <artifactId>eelf-core</artifactId>\r
             <version>0.0.1</version>\r
         </dependency>\r
-        <dependency>\r
-            <groupId>javax.servlet</groupId>\r
-            <artifactId>servlet-api</artifactId>\r
-            <version>2.5</version>\r
-        </dependency>\r
         <dependency>\r
             <groupId>org.eclipse.jetty</groupId>\r
             <artifactId>jetty-server</artifactId>\r
index 60496e5..3e3f45f 100644 (file)
@@ -116,50 +116,60 @@ public class Main {
 
         // Get properties
         Properties p = (new DB()).getProperties();
-        int http_port = Integer.parseInt(p.getProperty("org.onap.dmaap.datarouter.provserver.http.port", "8080"));
-        int https_port = Integer.parseInt(p.getProperty("org.onap.dmaap.datarouter.provserver.https.port", "8443"));
+        int httpPort = Integer.parseInt(p.getProperty("org.onap.dmaap.datarouter.provserver.http.port", "8080"));
+        int httpsPort = Integer.parseInt(p.getProperty("org.onap.dmaap.datarouter.provserver.https.port", "8443"));
+
+        // HTTP configuration
+        HttpConfiguration httpConfiguration = new HttpConfiguration();
+        httpConfiguration.setSecureScheme("https");
+        httpConfiguration.setSecurePort(httpsPort);
+        httpConfiguration.setOutputBufferSize(32768);
+        httpConfiguration.setRequestHeaderSize(2048);
+        httpConfiguration.setIdleTimeout(300000);
+        httpConfiguration.setSendServerVersion(true);
+        httpConfiguration.setSendDateHeader(false);
+
+        // Server's thread pool
+        QueuedThreadPool queuedThreadPool = new QueuedThreadPool();
+        queuedThreadPool.setMinThreads(10);
+        queuedThreadPool.setMaxThreads(200);
+        queuedThreadPool.setDetailedDump(false);
+
+        // The server itself
+        server = new Server(queuedThreadPool);
 
         // HTTP connector
-        HttpConfiguration http_config = new HttpConfiguration();
-        http_config.setSecureScheme("https");
-        http_config.setSecurePort(https_port);
-        http_config.setOutputBufferSize(32768);
-        http_config.setRequestHeaderSize(2048);
-        http_config.setIdleTimeout(300000);
-        http_config.setSendServerVersion(true);
-        http_config.setSendDateHeader(false);
-
-        ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
-        http.setPort(http_port);
-        http.setAcceptQueueSize(2);
-
-        // HTTPS config
-        HttpConfiguration https_config = new HttpConfiguration(http_config);
-        https_config.setRequestHeaderSize(8192);
+        ServerConnector httpServerConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
+        httpServerConnector.setPort(httpPort);
+        httpServerConnector.setAcceptQueueSize(2);
+
+        // HTTPS configuration
+        HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration);
+        httpsConfiguration.setRequestHeaderSize(8192);
 
         // HTTPS connector
         SslContextFactory sslContextFactory = new SslContextFactory();
         sslContextFactory.setKeyStorePath(p.getProperty(KEYSTORE_PATH_PROPERTY));
         sslContextFactory.setKeyStorePassword(p.getProperty(KEYSTORE_PASSWORD_PROPERTY));
         sslContextFactory.setKeyManagerPassword(p.getProperty("org.onap.dmaap.datarouter.provserver.keymanager.password"));
-
-        ServerConnector https = new ServerConnector(server,
-                new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
-                new HttpConnectionFactory(https_config));
-        https.setPort(https_port);
-        https.setIdleTimeout(30000);
-        https.setAcceptQueueSize(2);
-
         // SSL stuff
         /* Skip SSLv3 Fixes */
         sslContextFactory.addExcludeProtocols("SSLv3");
         logger.info("Excluded protocols prov-" + sslContextFactory.getExcludeProtocols());
         /* End of SSLv3 Fixes */
 
+        ServerConnector httpsServerConnector = new ServerConnector(server,
+                new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
+                new HttpConnectionFactory(httpsConfiguration));
+        httpsServerConnector.setPort(httpsPort);
+        httpsServerConnector.setIdleTimeout(30000);
+        httpsServerConnector.setAcceptQueueSize(2);
+
         sslContextFactory.setKeyStoreType(p.getProperty(KEYSTORE_TYPE_PROPERTY, "jks"));
         sslContextFactory.setKeyStorePath(p.getProperty(KEYSTORE_PATH_PROPERTY));
         sslContextFactory.setKeyStorePassword(p.getProperty(KEYSTORE_PASSWORD_PROPERTY));
         sslContextFactory.setKeyManagerPassword(p.getProperty("org.onap.dmaap.datarouter.provserver.keymanager.password"));
+
         String ts = p.getProperty(TRUSTSTORE_PATH_PROPERTY);
         if (ts != null && ts.length() > 0) {
             System.out.println("@@ TS -> " + ts);
@@ -210,12 +220,6 @@ public class Main {
         hc.setHandlers(new Handler[]{contexts, new DefaultHandler()});
         hc.addHandler(reqlog);
 
-        // Server's thread pool
-        QueuedThreadPool queuedThreadPool = new QueuedThreadPool();
-        queuedThreadPool.setMinThreads(10);
-        queuedThreadPool.setMaxThreads(200);
-        queuedThreadPool.setDetailedDump(false);
-
         // Daemon to clean up the log directory on a daily basis
         Timer rolex = new Timer();
         rolex.scheduleAtFixedRate(new PurgeLogDirTask(), 0, 86400000L);    // run once per day
@@ -223,16 +227,13 @@ public class Main {
         // Start LogfileLoader
         LogfileLoader.getLoader();
 
-        // The server itself
-        server = new Server(queuedThreadPool);
-
         ServerConnector serverConnector = new ServerConnector(server,
                 new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
-                new HttpConnectionFactory(https_config));
-        serverConnector.setPort(https_port);
+                new HttpConnectionFactory(httpsConfiguration));
+        serverConnector.setPort(httpsPort);
         serverConnector.setIdleTimeout(500000);
 
-        server.setConnectors(new Connector[]{http, https});
+        server.setConnectors(new Connector[]{httpServerConnector, httpsServerConnector});
         server.setHandler(hc);
         server.setStopAtShutdown(true);
         server.setStopTimeout(5000);