Author: markt
Date: Tue Mar  1 11:12:22 2011
New Revision: 1075776

URL: http://svn.apache.org/viewvc?rev=1075776&view=rev
Log:
Remove the init from references to handshake since the same fields/methods will 
be used for renegotiation

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java
    tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java?rev=1075776&r1=1075775&r2=1075776&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioChannel.java Tue Mar  1 
11:12:22 2011
@@ -173,9 +173,8 @@ public class NioChannel implements ByteC
      * isInitHandshakeComplete
      *
      * @return boolean
-     * TODO Implement this org.apache.tomcat.util.net.SecureNioChannel method
      */
-    public boolean isInitHandshakeComplete() {
+    public boolean isHandshakeComplete() {
         return true;
     }
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java?rev=1075776&r1=1075775&r2=1075776&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNioChannel.java Tue Mar  
1 11:12:22 2011
@@ -43,8 +43,8 @@ public class SecureNioChannel extends Ni
     
     protected SSLEngine sslEngine;
     
-    protected boolean initHandshakeComplete = false;
-    protected HandshakeStatus initHandshakeStatus; //gets set by begin 
handshake
+    protected boolean handshakeComplete = false;
+    protected HandshakeStatus handshakeStatus; //gets set by handshake
     
     protected boolean closed = false;
     protected boolean closing = false;
@@ -82,12 +82,12 @@ public class SecureNioChannel extends Ni
         netOutBuffer.limit(0);
         netInBuffer.position(0);
         netInBuffer.limit(0);
-        initHandshakeComplete = false;
+        handshakeComplete = false;
         closed = false;
         closing = false;
         //initiate handshake
         sslEngine.beginHandshake();
-        initHandshakeStatus = sslEngine.getHandshakeStatus();
+        handshakeStatus = sslEngine.getHandshakeStatus();
     }
     
     @Override
@@ -146,35 +146,35 @@ public class SecureNioChannel extends Ni
      */
     @Override
     public int handshake(boolean read, boolean write) throws IOException {
-        if ( initHandshakeComplete ) return 0; //we have done our initial 
handshake
+        if ( handshakeComplete ) return 0; //we have done our initial handshake
         
         if (!flush(netOutBuffer)) return SelectionKey.OP_WRITE; //we still 
have data to write
         
         SSLEngineResult handshake = null;
         
-        while (!initHandshakeComplete) {
-            switch ( initHandshakeStatus ) {
+        while (!handshakeComplete) {
+            switch ( handshakeStatus ) {
                 case NOT_HANDSHAKING: {
                     //should never happen
                     throw new IOException("NOT_HANDSHAKING during handshake");
                 }
                 case FINISHED: {
                     //we are complete if we have delivered the last package
-                    initHandshakeComplete = !netOutBuffer.hasRemaining();
+                    handshakeComplete = !netOutBuffer.hasRemaining();
                     //return 0 if we are complete, otherwise we still have 
data to write
-                    return initHandshakeComplete?0:SelectionKey.OP_WRITE; 
+                    return handshakeComplete?0:SelectionKey.OP_WRITE; 
                 }
                 case NEED_WRAP: {
                     //perform the wrap function
                     handshake = handshakeWrap(write);
                     if ( handshake.getStatus() == Status.OK ){
-                        if (initHandshakeStatus == HandshakeStatus.NEED_TASK) 
-                            initHandshakeStatus = tasks();
+                        if (handshakeStatus == HandshakeStatus.NEED_TASK) 
+                            handshakeStatus = tasks();
                     } else {
                         //wrap should always work with our buffers
                         throw new IOException("Unexpected status:" + 
handshake.getStatus() + " during handshake WRAP.");
                     }
-                    if ( initHandshakeStatus != HandshakeStatus.NEED_UNWRAP || 
(!flush(netOutBuffer)) ) {
+                    if ( handshakeStatus != HandshakeStatus.NEED_UNWRAP || 
(!flush(netOutBuffer)) ) {
                         //should actually return OP_READ if we have NEED_UNWRAP
                         return SelectionKey.OP_WRITE;
                     }
@@ -186,26 +186,26 @@ public class SecureNioChannel extends Ni
                     //perform the unwrap function
                     handshake = handshakeUnwrap(read);
                     if ( handshake.getStatus() == Status.OK ) {
-                        if (initHandshakeStatus == HandshakeStatus.NEED_TASK) 
-                            initHandshakeStatus = tasks();
+                        if (handshakeStatus == HandshakeStatus.NEED_TASK) 
+                            handshakeStatus = tasks();
                     } else if ( handshake.getStatus() == 
Status.BUFFER_UNDERFLOW ){
                         //read more data, reregister for OP_READ
                         return SelectionKey.OP_READ;
                     } else {
-                        throw new IOException("Invalid handshake 
status:"+initHandshakeStatus+" during handshake UNWRAP.");
+                        throw new IOException("Invalid handshake 
status:"+handshakeStatus+" during handshake UNWRAP.");
                     }//switch
                     break;
                 }
                 case NEED_TASK: {
-                    initHandshakeStatus = tasks();
+                    handshakeStatus = tasks();
                     break;
                 }
-                default: throw new IllegalStateException("Invalid handshake 
status:"+initHandshakeStatus);
+                default: throw new IllegalStateException("Invalid handshake 
status:"+handshakeStatus);
             }//switch
         }//while      
         //return 0 if we are complete, otherwise reregister for any activity 
that 
         //would cause this method to be called again.
-        return 
initHandshakeComplete?0:(SelectionKey.OP_WRITE|SelectionKey.OP_READ);
+        return 
handshakeComplete?0:(SelectionKey.OP_WRITE|SelectionKey.OP_READ);
     }
     
     /**
@@ -235,7 +235,7 @@ public class SecureNioChannel extends Ni
         //prepare the results to be written
         netOutBuffer.flip();
         //set the status
-        initHandshakeStatus = result.getHandshakeStatus();
+        handshakeStatus = result.getHandshakeStatus();
         //optimization, if we do have a writable channel, write it now
         if ( doWrite ) flush(netOutBuffer);
         return result;
@@ -269,15 +269,15 @@ public class SecureNioChannel extends Ni
             //compact the buffer, this is an optional method, wonder what 
would happen if we didn't
             netInBuffer.compact();
             //read in the status
-            initHandshakeStatus = result.getHandshakeStatus();
+            handshakeStatus = result.getHandshakeStatus();
             if ( result.getStatus() == SSLEngineResult.Status.OK &&
                  result.getHandshakeStatus() == HandshakeStatus.NEED_TASK ) {
                 //execute tasks if we need to
-                initHandshakeStatus = tasks();
+                handshakeStatus = tasks();
             }
             //perform another unwrap?
             cont = result.getStatus() == SSLEngineResult.Status.OK &&
-                   initHandshakeStatus == HandshakeStatus.NEED_UNWRAP;
+                   handshakeStatus == HandshakeStatus.NEED_UNWRAP;
         }while ( cont );
         return result;
     }
@@ -354,7 +354,7 @@ public class SecureNioChannel extends Ni
         //are we in the middle of closing or closed?
         if ( closing || closed) return -1;
         //did we finish our handshake?
-        if (!initHandshakeComplete) throw new IllegalStateException("Handshake 
incomplete, you must complete handshake before reading data.");
+        if (!handshakeComplete) throw new IllegalStateException("Handshake 
incomplete, you must complete handshake before reading data.");
 
         //read from the network
         int netread = sc.read(netInBuffer);
@@ -475,8 +475,8 @@ public class SecureNioChannel extends Ni
     }
 
     @Override
-    public boolean isInitHandshakeComplete() {
-        return initHandshakeComplete;
+    public boolean isHandshakeComplete() {
+        return handshakeComplete;
     }
 
     @Override



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

Reply via email to