From 725e20b114d39b8406abe70363c737570bcd5b32 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 28 Oct 2010 19:23:14 +0000
Subject: [PATCH] Fixed GSSAPI bug when detecting the end of the multi-stage bind process.

---
 sdk/src/org/opends/sdk/requests/GSSAPISASLBindRequestImpl.java |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/sdk/src/org/opends/sdk/requests/GSSAPISASLBindRequestImpl.java b/sdk/src/org/opends/sdk/requests/GSSAPISASLBindRequestImpl.java
index 1462117..86f3bd1 100644
--- a/sdk/src/org/opends/sdk/requests/GSSAPISASLBindRequestImpl.java
+++ b/sdk/src/org/opends/sdk/requests/GSSAPISASLBindRequestImpl.java
@@ -138,27 +138,23 @@
       @Override
       public Boolean run() throws ErrorResultException
       {
-        if (lastResult.getResultCode() == ResultCode.SASL_BIND_IN_PROGRESS
-            && lastResult.getServerSASLCredentials() != null)
+        try
         {
-          try
-          {
-            setNextSASLCredentials(saslClient.evaluateChallenge(lastResult
-                .getServerSASLCredentials().toByteArray()));
-            return false;
-          }
-          catch (final SaslException e)
-          {
-            // FIXME: I18N need to have a better error message.
-            // FIXME: Is this the best result code?
-            throw ErrorResultException.wrap(Responses
-                .newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR)
-                .setDiagnosticMessage(
-                    "An error occurred during multi-stage authentication")
-                .setCause(e));
-          }
+          setNextSASLCredentials(saslClient.evaluateChallenge(lastResult
+              .getServerSASLCredentials() == null ? new byte[0] : lastResult
+              .getServerSASLCredentials().toByteArray()));
+          return saslClient.isComplete();
         }
-        return true;
+        catch (final SaslException e)
+        {
+          // FIXME: I18N need to have a better error message.
+          // FIXME: Is this the best result code?
+          throw ErrorResultException.wrap(Responses
+              .newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR)
+              .setDiagnosticMessage(
+                  "An error occurred during multi-stage authentication")
+              .setCause(e));
+        }
       }
     };
 

--
Gitblit v1.10.0