mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nik...@apache.org
Subject svn commit: r522453 - in /mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter: SSLFilter.java support/SSLHandler.java
Date Mon, 26 Mar 2007 08:32:33 GMT
Author: niklas
Date: Mon Mar 26 01:32:32 2007
New Revision: 522453

URL: http://svn.apache.org/viewvc?view=rev&rev=522453
Log:
Resolved DIRMINA-326: If the SSLFilter.PEER_ADDRESS session attribute is set SSLHandler will
use SSLContext.createSSLEngine(hostname, port) which allows reuse of cached SSLSessions.

Modified:
    mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/SSLFilter.java
    mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/support/SSLHandler.java

Modified: mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/SSLFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/SSLFilter.java?view=diff&rev=522453&r1=522452&r2=522453
==============================================================================
--- mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/SSLFilter.java (original)
+++ mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/SSLFilter.java Mon Mar 26 01:32:32
2007
@@ -19,6 +19,8 @@
  */
 package org.apache.mina.filter;
 
+import java.net.InetSocketAddress;
+
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLException;
@@ -101,6 +103,21 @@
      * doesn't emit any events related with SSL session flow control.
      */
     public static final String USE_NOTIFICATION = SSLFilter.class.getName() + ".UseNotification";
+    
+    /**
+     * A session attribute key that should be set to an {@link InetSocketAddress}. 
+     * Setting this attribute causes  
+     * {@link SSLContext#createSSLEngine(String, int)} to be called passing the 
+     * hostname and port of the {@link InetSocketAddress} to get an 
+     * {@link SSLEngine} instance. If not set {@link SSLContext#createSSLEngine()}
+     * will be called.
+     * .
+     * Using this feature {@link SSLSession} objects may be cached and reused 
+     * when in client mode. 
+     * 
+     * @see SSLContext#createSSLEngine(String, int)
+     */
+    public static final String PEER_ADDRESS = SSLFilter.class.getName() + ".PeerAddress";
     
     /**
      * A special message object which is emitted with a {@link IoHandler#messageReceived(IoSession,
Object)}

Modified: mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/support/SSLHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/support/SSLHandler.java?view=diff&rev=522453&r1=522452&r2=522453
==============================================================================
--- mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/support/SSLHandler.java (original)
+++ mina/trunk/filter-ssl/src/main/java/org/apache/mina/filter/support/SSLHandler.java Mon
Mar 26 01:32:32 2007
@@ -19,6 +19,7 @@
  */
 package org.apache.mina.filter.support;
 
+import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.util.LinkedList;
 import java.util.Queue;
@@ -111,7 +112,12 @@
             return;
         }
 
-        sslEngine = ctx.createSSLEngine();
+        InetSocketAddress peer = (InetSocketAddress) session.getAttribute(SSLFilter.PEER_ADDRESS);
+        if (peer == null) {
+            sslEngine = ctx.createSSLEngine();
+        } else {
+            sslEngine = ctx.createSSLEngine(peer.getHostName(), peer.getPort());
+        } 
         sslEngine.setUseClientMode( parent.isUseClientMode() );
 
         if ( parent.isWantClientAuth() )



Mime
View raw message