directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r156511 - incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
Date Tue, 08 Mar 2005 08:38:43 GMT
Author: trustin
Date: Tue Mar  8 00:38:41 2005
New Revision: 156511

URL: http://svn.apache.org/viewcvs?view=rev&rev=156511
Log:
Fixed: compilation errors.
Fixed: Inifinite loop in handshaking phase when there are no cipher suites in common.

Modified:
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java?view=diff&r1=156510&r2=156511
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
Tue Mar  8 00:38:41 2005
@@ -266,17 +266,15 @@
 
         outNetBuffer.flip();
 
-        switch( result.getStatus() )
+        if ( result.getStatus() == SSLEngineResult.Status.OK )
         {
-
-        case OK:
             if( result.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_TASK
)
             {
                 doTasks();
             }
-            break;
-
-        default:
+        }
+        else
+        {
             throw new SSLException( "SSLEngine error during data write: "
                     + result.getStatus() );
         }
@@ -294,23 +292,25 @@
         }
         while( true )
         {
-            switch( initialHandshakeStatus )
+            if ( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.FINISHED )
             {
-            case FINISHED:
                 if( parent.debug != null )
                 {
                     parent.debug.print( " initialHandshakeStatus=FINISHED" );
                 }
                 initialHandshakeComplete = true;
                 return;
-            case NEED_TASK:
+            }
+            else if ( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_TASK
)
+            {
                 if( parent.debug != null )
                 {
                     parent.debug.print( " initialHandshakeStatus=NEED_TASK" );
                 }
                 initialHandshakeStatus = doTasks();
-                break;
-            case NEED_UNWRAP:
+            }
+            else if ( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_UNWRAP
)
+            {
                 // we need more data read
                 if( parent.debug != null )
                 {
@@ -318,13 +318,14 @@
                             .print( " initialHandshakeStatus=NEED_UNWRAP" );
                 }
                 SSLEngineResult.Status status = unwrap();
-                if( status == SSLEngineResult.Status.BUFFER_UNDERFLOW )
+                if( status == SSLEngineResult.Status.BUFFER_UNDERFLOW || closed )
                 {
-                    // We need more data
+                    // We need more data or the session is closed
                     return;
                 }
-                break;
-            case NEED_WRAP:
+            }
+            else if ( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_WRAP
)
+            {
                 if( parent.debug != null )
                 {
                     parent.debug.print( " initialHandshakeStatus=NEED_WRAP" );
@@ -345,9 +346,9 @@
                 initialHandshakeStatus = result.getHandshakeStatus();
                 // return to allow data on out buffer being sent
                 // TODO: We might want to send more data immidiatley?
-                break;
-            //return;
-            default: // NOT_HANDSHAKING
+            }
+            else
+            {
                 throw new IllegalStateException( "Invalid Handshaking State"
                         + initialHandshakeStatus );
             }
@@ -388,27 +389,28 @@
              * transitions to do a complete handshake, so ignore that
              * possibility.
              */
-            switch( res.getStatus() )
+            SSLEngineResult.Status status = res.getStatus();
+            if( status == SSLEngineResult.Status.BUFFER_UNDERFLOW ||
+                status == SSLEngineResult.Status.OK )
             {
-
-            case BUFFER_UNDERFLOW:
-            case OK:
                 if( res.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_TASK
)
                 {
                     doTasks();
                 }
-                break;
-            case CLOSED:
+            }
+            else if( status == SSLEngineResult.Status.CLOSED )
+            {
                 if( parent.debug != null )
                 {
                     parent.debug.print( "Closed while unwrapping" );
                 }
                 break;
-            default:
+            }
+            else
+            {
                 throw new SSLException( "SSLEngine error during data read: "
                         + res.getStatus() );
             }
-
         }
         while( ( inNetBuffer.position() != 0 )
                 && res.getStatus() != SSLEngineResult.Status.BUFFER_UNDERFLOW );



Mime
View raw message