tomcat-dev mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1810353&view=rev
Log:
Add SSLEngine.getApplicationProtocol() 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=1810353&r1=1810352&r2=1810353&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:34:10
2017
@@ -19,20 +19,24 @@ package org.apache.tomcat.util.compat;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
+import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLParameters;
 
 class Jre9Compat extends Jre8Compat {
 
     private static final Class<?> inaccessibleObjectExceptionClazz;
     private static final Method setApplicationProtocolsMethod;
+    private static final Method getApplicationProtocolMethod;
 
     static {
         Class<?> c1 = null;
         Method m2 = null;
+        Method m3 = null;
 
         try {
             c1 = Class.forName("java.lang.reflect.InaccessibleObjectException");
-            SSLParameters.class.getMethod("setApplicationProtocolsMethod", String[].class);
+            m2 = SSLParameters.class.getMethod("setApplicationProtocolsMethod", String[].class);
+            m3 = SSLEngine.class.getMethod("getApplicationProtocol");
         } catch (SecurityException | NoSuchMethodException e) {
             // Should never happen
         } catch (ClassNotFoundException e) {
@@ -40,6 +44,7 @@ class Jre9Compat extends Jre8Compat {
         }
         inaccessibleObjectExceptionClazz = c1;
         setApplicationProtocolsMethod = m2;
+        getApplicationProtocolMethod = m3;
     }
 
 
@@ -65,5 +70,15 @@ class Jre9Compat extends Jre8Compat {
         } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
e) {
             throw new UnsupportedOperationException(e);
         }
+    }
+
+
+    @Override
+    public String getApplicationProtocol(SSLEngine sslEngine) {
+        try {
+            return (String) getApplicationProtocolMethod.invoke(sslEngine);
+        } 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=1810353&r1=1810352&r2=1810353&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:34:10
2017
@@ -106,4 +106,18 @@ public class JreCompat {
     public void setApplicationProtocols(SSLParameters sslParameters, String[] protocols)
{
         throw new UnsupportedOperationException(sm.getString("jreCompat.noApplicationProtocols"));
     }
+
+
+    /**
+     * Get the application protocol that has been negotiated for connection
+     * associated with the given SSLEngine.
+     *
+     * @param sslEngine The SSLEngine for which to obtain the negotiated
+     *                  protocol
+     *
+     * @return The name of the negotiated protocol
+     */
+    public String getApplicationProtocol(SSLEngine sslEngine) {
+        throw new UnsupportedOperationException(sm.getString("jreCompat.noApplicationProtocol"));
+    }
 }

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=1810353&r1=1810352&r2=1810353&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:34:10 2017
@@ -13,5 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+jreCompat.noApplicationProtocol=Java Runtime does not support SSLEngine.getApplicationProtocol().
You must use Java 9 to use this feature.
 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