directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r169321 - in /directory/network/trunk/src: java/org/apache/mina/io/ java/org/apache/mina/io/filter/ java/org/apache/mina/protocol/ test/org/apache/mina/examples/echoserver/
Date Mon, 09 May 2005 15:00:26 GMT
Author: trustin
Date: Mon May  9 08:00:25 2005
New Revision: 169321

URL: http://svn.apache.org/viewcvs?rev=169321&view=rev
Log:
Fixed: DIRMINA-31

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/AbstractIoFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
    directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/AbstractIoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/AbstractIoFilterChain.java?rev=169321&r1=169320&r2=169321&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/AbstractIoFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/AbstractIoFilterChain.java Mon May
 9 08:00:25 2005
@@ -426,7 +426,7 @@
         
         try
         {
-            entry.filter.filterWrite( entry.prevFilter, session, buf, marker );
+            entry.filter.filterWrite( entry.nextFilter, session, buf, marker );
         }
         catch( Throwable e )
         {
@@ -473,8 +473,6 @@
 
         private final NextFilter nextFilter;
         
-        private final NextFilter prevFilter;
-
         private Entry( Entry prevEntry, Entry nextEntry,
                        String name, IoFilter filter )
         {
@@ -529,46 +527,6 @@
                 {
                     Entry nextEntry = Entry.this.nextEntry;
                     callNextDataWritten( nextEntry, session, marker );
-                }
-                
-                public void filterWrite( IoSession session, ByteBuffer buf, Object marker
)
-                {
-                    throw new IllegalStateException();
-                }
-            };
-            
-            this.prevFilter = new NextFilter()
-            {
-
-                public void sessionOpened( IoSession session )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void sessionClosed( IoSession session )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void sessionIdle( IoSession session, IdleStatus status )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void exceptionCaught( IoSession session,
-                                            Throwable cause )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void dataRead( IoSession session, ByteBuffer buf )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void dataWritten( IoSession session, Object marker )
-                {
-                    throw new IllegalStateException();
                 }
                 
                 public void filterWrite( IoSession session, ByteBuffer buf, Object marker
)

Modified: directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java?rev=169321&r1=169320&r2=169321&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java Mon May  9 08:00:25
2005
@@ -47,11 +47,12 @@
 public class SSLFilter extends IoFilterAdapter
 {
     private static final Logger log = Logger.getLogger( SSLFilter.class.getName() );
+
     /**
      * A marker which is passed with {@link IoHandler#dataWritten(IoSession, Object)}
      * when <tt>SSLFilter</tt> writes data other then user actually requested.
      */
-    public static final Object SSL_MARKER = new Object()
+    private static final Object SSL_MARKER = new Object()
     {
         public String toString()
         {
@@ -187,7 +188,7 @@
     public void sessionOpened( NextFilter nextFilter, IoSession session ) throws SSLException
     {
         // Create an SSL handler
-        createSSLSessionHandler( session );
+        createSSLSessionHandler( nextFilter, session );
         nextFilter.sessionOpened( session );
     }
 
@@ -209,7 +210,7 @@
                   sslHandler.shutdown();
                   
                   // there might be data to write out here?
-                  writeNetBuffer( session, sslHandler );
+                  writeNetBuffer( nextFilter, session, sslHandler );
                }
                catch( SSLException ssle )
                {
@@ -243,7 +244,7 @@
                 try
                 {
                     // forward read encrypted data to SSL handler
-                    sslHandler.dataRead( buf.buf() );
+                    sslHandler.dataRead( nextFilter, buf.buf() );
 
                     // Handle data to be forwarded to application or written to net
                     handleSSLData( nextFilter, session, sslHandler );
@@ -281,13 +282,16 @@
     public void dataWritten( NextFilter nextFilter, IoSession session,
                             Object marker )
     {
-        nextFilter.dataWritten( session, marker );
+        if( marker != SSL_MARKER )
+        {
+            nextFilter.dataWritten( session, marker );
+        }
     }
 
     public void filterWrite( NextFilter nextFilter, IoSession session, ByteBuffer buf, Object
marker ) throws SSLException
     {
 
-        SSLHandler handler = createSSLSessionHandler( session );
+        SSLHandler handler = createSSLSessionHandler( nextFilter, session );
         if( log.isLoggable( Level.FINEST ) )
         {
             log.log( Level.FINEST, session + " Filtered Write: " + handler );
@@ -358,7 +362,7 @@
         }
 
         // Write encrypted data to be written (if any)
-        writeNetBuffer( session, handler );
+        writeNetBuffer( nextFilter, session, handler );
 
         // handle app. data read (if any)
         handleAppDataRead( nextFilter, session, handler );
@@ -383,7 +387,7 @@
         }
     }
 
-    void writeNetBuffer( IoSession session, SSLHandler sslHandler )
+    void writeNetBuffer( NextFilter nextFilter, IoSession session, SSLHandler sslHandler
)
             throws SSLException
     {
         // Check if any net data needed to be writen
@@ -415,14 +419,14 @@
                 log.log( Level.FINEST, session + " session write: " + writeBuffer );
             }
             //debug("outNetBuffer (after copy): {0}", sslHandler.getOutNetBuffer());
-            session.write( writeBuffer, SSL_MARKER );
+            filterWrite( nextFilter, session, writeBuffer, SSL_MARKER );
 
             // loop while more writes required to complete handshake
             while( sslHandler.needToCompleteInitialHandshake() )
             {
                 try
                 {
-                    sslHandler.continueHandshake();
+                    sslHandler.continueHandshake( nextFilter );
                 }
                 catch( SSLException ssle )
                 {
@@ -440,7 +444,7 @@
                     }
                     ByteBuffer writeBuffer2 = copy( sslHandler
                             .getOutNetBuffer() );
-                    session.write( writeBuffer2, SSL_MARKER );
+                    filterWrite( nextFilter, session, writeBuffer2, SSL_MARKER );
                 }
             }
         }
@@ -470,7 +474,7 @@
 
     // Utilities to mainpulate SSLHandler based on IoSession
 
-    private SSLHandler createSSLSessionHandler( IoSession session ) throws SSLException
+    private SSLHandler createSSLSessionHandler( NextFilter nextFilter, IoSession session
) throws SSLException
     {
         SSLHandler handler = ( SSLHandler ) sslSessionHandlerMap.get( session );
         if( handler == null )
@@ -486,7 +490,7 @@
                         handler =
                             new SSLHandler( this, sslContext, session );
                         sslSessionHandlerMap.put( session, handler );
-                        handler.doHandshake();
+                        handler.doHandshake( nextFilter );
                         done = true;
                     }
                     finally 

Modified: directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java?rev=169321&r1=169320&r2=169321&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java Mon May  9
08:00:25 2005
@@ -213,7 +213,7 @@
      * @param buf buffer to decrypt
      * @throws SSLException on errors
      */
-    public void dataRead( ByteBuffer buf ) throws SSLException
+    public void dataRead( NextFilter nextFilter, ByteBuffer buf ) throws SSLException
     {
         if ( buf.limit() > inNetBuffer.remaining() ) {
             // We have to expand inNetBuffer
@@ -236,7 +236,7 @@
         inNetBuffer.put( buf );
         if( !initialHandshakeComplete )
         {
-            doHandshake();
+            doHandshake( nextFilter );
         }
         else
         {
@@ -249,13 +249,13 @@
      *
      * @throws SSLException on errors
      */
-    public void continueHandshake() throws SSLException
+    public void continueHandshake( NextFilter nextFilter ) throws SSLException
     {
         if( log.isLoggable( Level.FINEST ) )
         {
             log.log( Level.FINEST, session + " continueHandshake()" );
         }
-        doHandshake();
+        doHandshake( nextFilter );
     }
 
     /**
@@ -403,7 +403,7 @@
     /**
      * Perform any handshaking processing.
      */
-    synchronized void doHandshake() throws SSLException
+    synchronized void doHandshake( NextFilter nextFilter ) throws SSLException
     {
 
         if( log.isLoggable( Level.FINEST ) )
@@ -474,7 +474,7 @@
 
                 outNetBuffer.flip();
                 initialHandshakeStatus = result.getHandshakeStatus();
-                parent.writeNetBuffer( session, this );
+                parent.writeNetBuffer( nextFilter, session, this );
                 // return to allow data on out buffer being sent
                 // TODO: We might want to send more data immidiatley?
             }

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java?rev=169321&r1=169320&r2=169321&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
Mon May  9 08:00:25 2005
@@ -425,7 +425,7 @@
         
         try
         {
-            entry.filter.filterWrite( entry.prevFilter, session, message );
+            entry.filter.filterWrite( entry.nextFilter, session, message );
         }
         catch( Throwable e )
         {
@@ -472,8 +472,6 @@
 
         private final NextFilter nextFilter;
         
-        private final NextFilter prevFilter;
-
         private Entry( Entry prevEntry, Entry nextEntry,
                        String name, ProtocolFilter filter )
         {
@@ -528,46 +526,6 @@
                 {
                     Entry nextEntry = Entry.this.nextEntry;
                     callNextMessageSent( nextEntry, session, message );
-                }
-                
-                public void filterWrite( ProtocolSession session, Object message )
-                {
-                    throw new IllegalStateException();
-                }
-            };
-            
-            this.prevFilter = new NextFilter()
-            {
-
-                public void sessionOpened( ProtocolSession session )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void sessionClosed( ProtocolSession session )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void sessionIdle( ProtocolSession session, IdleStatus status )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void exceptionCaught( ProtocolSession session,
-                                            Throwable cause )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void messageReceived( ProtocolSession session, Object message )
-                {
-                    throw new IllegalStateException();
-                }
-
-                public void messageSent( ProtocolSession session, Object message )
-                {
-                    throw new IllegalStateException();
                 }
                 
                 public void filterWrite( ProtocolSession session, Object message )

Modified: directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java?rev=169321&r1=169320&r2=169321&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
Mon May  9 08:00:25 2005
@@ -212,19 +212,16 @@
         
         public void dataWritten( IoSession session, Object marker )
         {
-            if( marker != SSLFilter.SSL_MARKER )
+            if( ( counter & 1 ) == 0 )
             {
-                if( ( counter & 1 ) == 0 )
-                {
-                    Assert.assertEquals( new Integer( counter ), marker );
-                }
-                else
-                {
-                    Assert.assertNull( marker );
-                }
-                
-                counter ++;
+                Assert.assertEquals( new Integer( counter ), marker );
             }
+            else
+            {
+                Assert.assertNull( marker );
+            }
+            
+            counter ++;
         }
 
         public void exceptionCaught( IoSession session, Throwable cause )



Mime
View raw message