tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1779542 - in /tomcat/trunk/java/org/apache/tomcat/util/compat: Jre9Compat.java JreCompat.java LocalStrings.properties
Date Thu, 19 Jan 2017 23:55:49 GMT
Author: markt
Date: Thu Jan 19 23:55:48 2017
New Revision: 1779542

URL: http://svn.apache.org/viewvc?rev=1779542&view=rev
Log:
Add SSLEngine.getApplicationProtocol() to JreCompat

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

Modified: tomcat/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java?rev=1779542&r1=1779541&r2=1779542&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/compat/Jre9Compat.java Thu Jan 19 23:55:48 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 JreCompat {
 
     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 JreCompat {
         }
         inaccessibleObjectExceptionClazz = c1;
         setApplicationProtocolsMethod = m2;
+        getApplicationProtocolMethod = m3;
     }
 
 
@@ -65,5 +70,15 @@ class Jre9Compat extends JreCompat {
         } 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/trunk/java/org/apache/tomcat/util/compat/JreCompat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/compat/JreCompat.java?rev=1779542&r1=1779541&r2=1779542&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/compat/JreCompat.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/compat/JreCompat.java Thu Jan 19 23:55:48 2017
@@ -16,6 +16,7 @@
  */
 package org.apache.tomcat.util.compat;
 
+import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLParameters;
 
 import org.apache.tomcat.util.res.StringManager;
@@ -85,4 +86,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/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties?rev=1779542&r1=1779541&r2=1779542&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/compat/LocalStrings.properties Thu Jan 19 23:55:48
2017
@@ -13,4 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-jreCompat.noApplicationProtocols=Java Runtime does not support SSLParameters.setApplicationProtocols().
You must use Java 9 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.noApplicationProtocol=Java Runtime does not support SSLEngine.getApplicationProtocol().
You must use Java 9 to use this feature.
\ No newline at end of file



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


Mime
View raw message