openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1767568 - /openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Date Tue, 01 Nov 2016 20:42:20 GMT
Author: rmannibucau
Date: Tue Nov  1 20:42:20 2016
New Revision: 1767568

URL: http://svn.apache.org/viewvc?rev=1767568&view=rev
Log:
better http2 handling with SslHostConfig instantiation - test to do asap

Modified:
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java?rev=1767568&r1=1767567&r2=1767568&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Tue Nov  1 20:42:20 2016
@@ -55,6 +55,7 @@ import org.apache.tomcat.JarScanFilter;
 import org.apache.tomcat.util.descriptor.web.LoginConfig;
 import org.apache.tomcat.util.descriptor.web.SecurityCollection;
 import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
+import org.apache.tomcat.util.net.SSLHostConfig;
 import org.apache.xbean.finder.ResourceFinder;
 import org.apache.xbean.recipe.ObjectRecipe;
 import org.xml.sax.Attributes;
@@ -434,9 +435,6 @@ public class Microwave implements AutoCl
             if (connector.getAttribute("connectionTimeout") == null) {
                 connector.setAttribute("connectionTimeout", "3000");
             }
-            if (configuration.http2) { // would likely need SSLHostConfig programmatically
-                connector.addUpgradeProtocol(new Http2Protocol());
-            }
 
             tomcat.getService().addConnector(connector);
             tomcat.setConnector(connector);
@@ -460,14 +458,11 @@ public class Microwave implements AutoCl
             if (configuration.clientAuth != null) {
                 httpsConnector.setAttribute("clientAuth", configuration.clientAuth);
             }
+
             if (configuration.keyAlias != null) {
                 httpsConnector.setAttribute("keyAlias", configuration.keyAlias);
             }
 
-            if (configuration.http2) { // would likely need SSLHostConfig programmatically
-                httpsConnector.addUpgradeProtocol(new Http2Protocol());
-            }
-
             tomcat.getService().addConnector(httpsConnector);
 
             if (configuration.skipHttp) {
@@ -475,6 +470,15 @@ public class Microwave implements AutoCl
             }
         }
 
+        if (configuration.http2) {
+            final Connector c = configuration.ssl ?
+                    tomcat.getService().findConnectors()[tomcat.getService().findConnectors().length
- 1] :
+                    ofNullable(tomcat.getRawConnector()).orElse(tomcat.getService().findConnectors()[0]);
+
+            c.addUpgradeProtocol(new Http2Protocol());
+            c.addSslHostConfig(buildSslHostConfig());
+        }
+
         for (final Connector c : configuration.connectors) {
             tomcat.getService().addConnector(c);
         }
@@ -515,6 +519,18 @@ public class Microwave implements AutoCl
         return this;
     }
 
+    private SSLHostConfig buildSslHostConfig() {
+        final ObjectRecipe recipe = new ObjectRecipe(SSLHostConfig.class);
+        for (final String key : configuration.properties.stringPropertyNames()) {
+            if (!key.startsWith("connector.sslhostconfig.")) {
+                continue;
+            }
+            final String substring = key.substring("connector.sslhostconfig.".length());
+            recipe.setProperty(substring, configuration.properties.getProperty(key));
+        }
+        return SSLHostConfig.class.cast(recipe.create());
+    }
+
     protected void beforeStart() {
         // no-op
     }
@@ -576,7 +592,12 @@ public class Microwave implements AutoCl
                 if (!key.startsWith("connector.")) {
                     continue;
                 }
+
                 final String substring = key.substring("connector.".length());
+                if (substring.startsWith("sslhostconfig.")) {
+                    continue;
+                }
+
                 if (!substring.startsWith("attributes.")) {
                     recipe.setProperty(substring, properties.getProperty(key));
                 } else {



Mime
View raw message