Author: robbie
Date: Mon May 27 15:39:13 2013
New Revision: 1486643

URL: http://svn.apache.org/r1486643
Log:
PROTON-318: update the state field based on the outcome

Modified:
    
qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java

Modified: 
qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java?rev=1486643&r1=1486642&r2=1486643&view=diff
==============================================================================
--- 
qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
 (original)
+++ 
qpid/proton/trunk/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
 Mon May 27 15:39:13 2013
@@ -168,11 +168,20 @@ public class SaslImpl implements Sasl, S
             {
                 processInit(buffer);
                 _state = SaslState.PN_SASL_STEP;
+
+                //HACK: if we received an outcome before
+                //we sent our init, change the state now
+                if(_outcome != SaslOutcome.PN_SASL_NONE)
+                {
+                    _state = classifyStateFromOutcome(_outcome);
+                }
             }
+
             if(getState() == SaslState.PN_SASL_STEP && getChallengeResponse() 
!= null)
             {
                 processResponse(buffer);
             }
+
         }
     }
 
@@ -367,7 +376,7 @@ public class SaslImpl implements Sasl, S
         checkRole(Role.SERVER);
         _outcome = outcome;
         _done = true;
-        _state = outcome == SaslOutcome.PN_SASL_OK ? SaslState.PN_SASL_PASS : 
SaslState.PN_SASL_FAIL;
+        _state = classifyStateFromOutcome(outcome);
         _logger.fine("SASL negotiation done: " + this);
     }
 
@@ -408,6 +417,10 @@ public class SaslImpl implements Sasl, S
             if(outcome.getCode() == saslOutcome.getCode().ordinal())
             {
                 _outcome = outcome;
+                if (_state != SaslState.PN_SASL_IDLE)
+                {
+                    _state = classifyStateFromOutcome(outcome);
+                }
                 break;
             }
         }
@@ -419,6 +432,11 @@ public class SaslImpl implements Sasl, S
         }
     }
 
+    private SaslState classifyStateFromOutcome(SaslOutcome outcome)
+    {
+        return outcome == SaslOutcome.PN_SASL_OK ? SaslState.PN_SASL_PASS : 
SaslState.PN_SASL_FAIL;
+    }
+
     private void processResponse(WritableBuffer buffer)
     {
         SaslResponse response = new SaslResponse();



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to