directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r169302 - in /directory/network/branches/api_integration/src: java/org/apache/mina/common/ java/org/apache/mina/filter/ java/org/apache/mina/filter/codec/ java/org/apache/mina/transport/socket/nio/ test/org/apache/mina/examples/echoserver/
Date Mon, 09 May 2005 12:25:10 GMT
Author: trustin
Date: Mon May  9 05:25:09 2005
New Revision: 169302

URL: http://svn.apache.org/viewcvs?rev=169302&view=rev
Log:
Fixed: messageSent gives empty bytebuffer

Modified:
    directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java
    directory/network/branches/api_integration/src/java/org/apache/mina/filter/SSLFilter.java
    directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
    directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
    directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
    directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketSessionManagerFilterChain.java
    directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
    directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/common/ByteBuffer.java
Mon May  9 05:25:09 2005
@@ -748,7 +748,7 @@
 
         public String toString()
         {
-            return buf.toString();
+            return buf.toString() + " (" + getHexDump() + ')';
         }
 
         public int hashCode()

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/filter/SSLFilter.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/filter/SSLFilter.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/filter/SSLFilter.java
Mon May  9 05:25:09 2005
@@ -29,6 +29,7 @@
 import javax.net.ssl.SSLHandshakeException;
 
 import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.ByteBufferProxy;
 import org.apache.mina.common.IoFilterAdapter;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
@@ -191,7 +192,7 @@
         nextFilter.sessionOpened( session );
     }
 
-    public void sessionClosed( NextFilter nextFilter, IoSession session )
+    public void sessionClosed( NextFilter nextFilter, IoSession session ) throws SSLException
     {
         SSLHandler sslHandler = getSSLSessionHandler( session );
         if( log.isLoggable( Level.FINEST ) )
@@ -211,10 +212,6 @@
                   // there might be data to write out here?
                   writeNetBuffer( session, sslHandler );
                }
-               catch( SSLException ssle )
-               {
-                  nextFilter.exceptionCaught( session, ssle );
-               }
                finally
                {
                   // notify closed session
@@ -229,7 +226,7 @@
     }
    
     public void messageReceived( NextFilter nextFilter, IoSession session,
-                                 Object message )
+                                 Object message ) throws SSLException
     {
         ByteBuffer buf = ( ByteBuffer ) message;
         SSLHandler sslHandler = getSSLSessionHandler( session );
@@ -269,7 +266,7 @@
                         ssle = newSSLE;
                     }
 
-                    nextFilter.exceptionCaught( session, ssle );
+                    throw ssle;
                 }
             }
         }
@@ -282,7 +279,16 @@
     public void messageSent( NextFilter nextFilter, IoSession session,
                              Object message )
     {
-        nextFilter.messageSent( session, message );
+        if( message instanceof EncryptedBuffer )
+        {
+            EncryptedBuffer buf = ( EncryptedBuffer ) message;
+            buf.release();
+            nextFilter.messageSent( session, buf.originalBuffer );
+        }
+        else
+        {
+            // ignore extra buffers used for handshaking
+        }
     }
 
     public void filterWrite( NextFilter nextFilter, IoSession session, Object message ) throws
SSLException
@@ -315,15 +321,17 @@
                 {
                     log.log( Level.FINEST, session + " encrypt: " + buf );
                 }
+                
+                int pos = buf.position();
                 handler.encrypt( buf.buf() );
-                ByteBuffer encryptedBuffer = copy( handler
-                        .getOutNetBuffer() );
+                buf.position( pos );
+                ByteBuffer encryptedBuffer = new EncryptedBuffer(
+                        copy( handler.getOutNetBuffer() ), buf );
 
                 if( log.isLoggable( Level.FINEST ) )
                 {
                     log.log( Level.FINEST, session + " encrypted buf: " + encryptedBuffer);
                 }
-                buf.release();
                 nextFilter.filterWrite( session, encryptedBuffer );
                 return;
             }
@@ -515,6 +523,17 @@
         synchronized( sslSessionHandlerMap )
         {
             sslSessionHandlerMap.remove( session );
+        }
+    }
+
+    private static class EncryptedBuffer extends ByteBufferProxy
+    {
+        private final ByteBuffer originalBuffer;
+        
+        private EncryptedBuffer( ByteBuffer buf, ByteBuffer originalBuffer )
+        {
+            super( buf );
+            this.originalBuffer = originalBuffer;
         }
     }
 }

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
Mon May  9 05:25:09 2005
@@ -148,6 +148,5 @@
             super( buf );
             this.message = message;
         }
-        
     }
 }

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
Mon May  9 05:25:09 2005
@@ -363,6 +363,7 @@
                 continue;
             }
 
+            int pos = buf.position();
             int writtenBytes = ch
                     .send( buf.buf(), session.getRemoteAddress() );
 
@@ -384,7 +385,7 @@
                 }
 
                 session.increaseWrittenBytes( writtenBytes );
-                session.getManagerFilterChain().messageSent( session, buf );
+                session.getManagerFilterChain().messageSent( session, buf.position( pos )
);
             }
         }
     }

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
Mon May  9 05:25:09 2005
@@ -360,6 +360,7 @@
                 continue;
             }
 
+            int pos = buf.position();
             int writtenBytes = ch.write( buf.buf() );
 
             SelectionKey key = session.getSelectionKey();
@@ -380,7 +381,7 @@
                 }
 
                 session.increaseWrittenBytes( writtenBytes );
-                session.getManagerFilterChain().messageSent( session, buf );
+                session.getManagerFilterChain().messageSent( session, buf.position( pos )
);
             }
         }
     }

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
Mon May  9 05:25:09 2005
@@ -451,7 +451,7 @@
                     writeBufferQueue.pop();
                 }
                 
-                session.getManagerFilterChain().messageSent( session, buf );
+                session.getManagerFilterChain().messageSent( session, buf.reset() );
                 continue;
             }
 

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketSessionManagerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketSessionManagerFilterChain.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketSessionManagerFilterChain.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/transport/socket/nio/SocketSessionManagerFilterChain.java
Mon May  9 05:25:09 2005
@@ -1,5 +1,6 @@
 package org.apache.mina.transport.socket.nio;
 
+import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionManager;
@@ -23,6 +24,7 @@
         SocketSession s = ( SocketSession ) session;
         Queue writeBufferQueue = s.getWriteBufferQueue();
         
+        ( ( ByteBuffer ) message ).mark();
         synchronized( writeBufferQueue )
         {
             writeBufferQueue.push( message );

Modified: directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AbstractTest.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
(original)
+++ directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
Mon May  9 05:25:09 2005
@@ -73,7 +73,7 @@
     protected void setUp() throws Exception
     {
         registry = new SimpleServiceRegistry();
-        
+
         // Find an availble test port and bind to it.
         boolean socketBound = false;
         boolean datagramBound = false;

Modified: directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java?rev=169302&r1=169301&r2=169302&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
(original)
+++ directory/network/branches/api_integration/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
Mon May  9 05:25:09 2005
@@ -35,6 +35,7 @@
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.examples.echoserver.ssl.SSLServerSocketFactory;
 import org.apache.mina.examples.echoserver.ssl.SSLSocketFactory;
+import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.SSLFilter;
 
 /**
@@ -62,6 +63,7 @@
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
         acceptor.getFilterChain().addLast( "SSL", sslFilter );
+        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
         
         // Create a commons-net socket factory
         SSLSocketFactory.setSslEnabled(true);



Mime
View raw message