From ce85e5cee200e6ee4ecffd4b0960aa5001c0ecf3 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Thu, 12 Feb 2009 21:37:55 +0000
Subject: [PATCH] Add check for null SASL Context and fix error message in EXTERNAL Digest Handler.

---
 opendj-sdk/opends/src/server/org/opends/server/extensions/SASLContext.java                  |    7 ++++++-
 opendj-sdk/opends/src/messages/messages/extension.properties                                |    8 +++++---
 opendj-sdk/opends/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java |    3 +--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/opendj-sdk/opends/src/messages/messages/extension.properties b/opendj-sdk/opends/src/messages/messages/extension.properties
index 2c81485e..db8bafb 100644
--- a/opendj-sdk/opends/src/messages/messages/extension.properties
+++ b/opendj-sdk/opends/src/messages/messages/extension.properties
@@ -363,9 +363,9 @@
 MILD_ERR_SASLEXTERNAL_NO_CLIENT_CONNECTION_123=The SASL EXTERNAL bind request \
  could not be processed because the associated bind request does not have a \
  reference to the client connection
-MILD_ERR_SASLEXTERNAL_NO_SECURITY_PROVIDER_124=The SASL EXTERNAL bind request \
- could not be processed because the associated client connection does not have \
- a security provider
+MILD_ERR_SASLEXTERNAL_NOT_LDAP_CLIENT_INSTANCE_124=The SASL EXTERNAL bind \
+request could not be processed because the associated client connection \
+instance is not an instance of LDAPClientConnection
 MILD_ERR_SASLEXTERNAL_CLIENT_NOT_USING_TLS_PROVIDER_125=The SASL EXTERNAL \
  bind request could not be processed because the client connection is not \
  using the TLS security provider (client security provider is %s).  The TLS \
@@ -1415,3 +1415,5 @@
 SEVERE_ERR_SASLDIGESTMD5_PROTOCOL_ERROR_570=SASL DIGEST MD5 protocol error: %s
 INFO_LOG_EXTENSION_INFORMATION_571=Loaded extension from file '%s' (build %s, \
  revision %s)
+ SEVERE_ERR_SASL_CREATE_SASL_SERVER_FAILED_572=Failed to create a SASL server \
+ for SASL mechanism %s using a server FQDN of %s
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java
index b0c60f4..478127f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java
@@ -176,9 +176,8 @@
     }
 
     if(!(clientConnection instanceof LDAPClientConnection)) {
-        //TODO SASLPhase2 need better message
         bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS);
-        Message message = ERR_SASLEXTERNAL_NO_SECURITY_PROVIDER.get();
+        Message message = ERR_SASLEXTERNAL_NOT_LDAP_CLIENT_INSTANCE.get();
         bindOperation.setAuthFailureReason(message);
         return;
     }
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/SASLContext.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/SASLContext.java
index 2c22972..606fc54 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/SASLContext.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/SASLContext.java
@@ -160,8 +160,13 @@
      * constructor.
      */
     private void initSASLServer() throws SaslException {
-       this.saslServer = Sasl.createSaslServer(mechanism, SASL_DEFAULT_PROTOCOL,
+       saslServer = Sasl.createSaslServer(mechanism, SASL_DEFAULT_PROTOCOL,
                                                serverFQDN, saslProps, this);
+       if(saslServer == null) {
+         Message msg =
+                 ERR_SASL_CREATE_SASL_SERVER_FAILED.get(mechanism, serverFQDN);
+         throw new SaslException(Message.toString(msg));
+       }
     }
 
 

--
Gitblit v1.10.0