tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1810352 - in /tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat: Jre9Compat.java JreCompat.java LocalStrings.properties
Date Mon, 02 Oct 2017 13:29:05 GMT
Author: markt
Date: Mon Oct  2 13:29:05 2017
New Revision: 1810352

URL: http://svn.apache.org/viewvc?rev=1810352&view=rev
Log:
Add support for SSLParameters.setApplicationProtocols() to JreCompat

Modified:
    tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java
    tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/JreCompat.java
    tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties

Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java?rev=1810352&r1=1810351&r2=1810352&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java Mon Oct  2 13:29:05
2017
@@ -16,21 +16,30 @@
  */
 package org.apache.tomcat.util.compat;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.net.ssl.SSLParameters;
+
 class Jre9Compat extends Jre8Compat {
 
     private static final Class<?> inaccessibleObjectExceptionClazz;
-
+    private static final Method setApplicationProtocolsMethod;
 
     static {
         Class<?> c1 = null;
+        Method m2 = null;
+
         try {
             c1 = Class.forName("java.lang.reflect.InaccessibleObjectException");
-        } catch (SecurityException e) {
+            SSLParameters.class.getMethod("setApplicationProtocolsMethod", String[].class);
+        } catch (SecurityException | NoSuchMethodException e) {
             // Should never happen
         } catch (ClassNotFoundException e) {
             // Must be Java 8
         }
         inaccessibleObjectExceptionClazz = c1;
+        setApplicationProtocolsMethod = m2;
     }
 
 
@@ -47,4 +56,14 @@ class Jre9Compat extends Jre8Compat {
 
         return inaccessibleObjectExceptionClazz.isAssignableFrom(t.getClass());
     }
+
+
+    @Override
+    public void setApplicationProtocols(SSLParameters sslParameters, String[] protocols)
{
+        try {
+            setApplicationProtocolsMethod.invoke(sslParameters, (Object) protocols);
+        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
e) {
+            throw new UnsupportedOperationException(e);
+        }
+    }
 }

Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/JreCompat.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/JreCompat.java?rev=1810352&r1=1810351&r2=1810352&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/JreCompat.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/JreCompat.java Mon Oct  2 13:29:05
2017
@@ -17,6 +17,7 @@
 package org.apache.tomcat.util.compat;
 
 import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLParameters;
 
 import org.apache.tomcat.util.res.StringManager;
 
@@ -93,4 +94,16 @@ public class JreCompat {
         // Exception does not exist prior to Java 9
         return false;
     }
+
+
+    /**
+     * Set the application protocols the server will accept for ALPN
+     *
+     * @param sslParameters    The SSL parameters for a connection
+     * @param protocols        The application protocols to be allowed for that
+     *                         connection
+     */
+    public void setApplicationProtocols(SSLParameters sslParameters, String[] protocols)
{
+        throw new UnsupportedOperationException(sm.getString("jreCompat.noApplicationProtocols"));
+    }
 }

Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties?rev=1810352&r1=1810351&r2=1810352&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties Mon Oct
 2 13:29:05 2017
@@ -13,4 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-jreCompat.noServerCipherSuiteOrder=Java Runtime does not support "useServerCipherSuitesOrder".
You must use Java 8 or later to use this feature.
\ No newline at end of file
+jreCompat.noApplicationProtocols=Java Runtime does not support SSLParameters.setApplicationProtocols().
You must use Java 9 to use this feature.
+jreCompat.noServerCipherSuiteOrder=Java Runtime does not support "useServerCipherSuitesOrder".
You must use Java 8 or later to use this feature.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message