From 4bf7d7c4a02bf5d16acf88579f2c0f376f3e4080 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 19 Sep 2011 13:23:39 +0000
Subject: [PATCH] Fix OPENDJ-288: Use INVALID_CREDENTIALS result code when disconnecting users because their entry has been deleted

---
 opends/src/messages/messages/core.properties                                 |    2 ++
 opends/src/server/org/opends/server/core/AuthenticatedUsers.java             |    3 ++-
 opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java |    3 +++
 opends/src/server/org/opends/server/types/DisconnectReason.java              |   10 ++++++++++
 4 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/opends/src/messages/messages/core.properties b/opends/src/messages/messages/core.properties
index a44fccf..b375926 100644
--- a/opends/src/messages/messages/core.properties
+++ b/opends/src/messages/messages/core.properties
@@ -21,6 +21,7 @@
 # CDDL HEADER END
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
+#      Portions copyright 2011 ForgeRock AS
 
 
 
@@ -1851,3 +1852,4 @@
 SEVERE_WARN_OP_REJECTED_BY_QUEUE_INTERRUPT_740=The request to process this \
  operation has been rejected because request handler thread was interrupted \
  while attempting to put the operation on the work queue
+INFO_DISCONNECT_DUE_TO_INVALID_CREDENTIALS_741=Invalid Credentials
diff --git a/opends/src/server/org/opends/server/core/AuthenticatedUsers.java b/opends/src/server/org/opends/server/core/AuthenticatedUsers.java
index 43226c2..41f484b 100644
--- a/opends/src/server/org/opends/server/core/AuthenticatedUsers.java
+++ b/opends/src/server/org/opends/server/core/AuthenticatedUsers.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
+ *      Portions copyright 2011 ForgeRock AS
  */
 package org.opends.server.core;
 import java.util.HashSet;
@@ -234,7 +235,7 @@
         Message message = WARN_CLIENTCONNECTION_DISCONNECT_DUE_TO_DELETE.get(
                 String.valueOf(entry.getDN()));
 
-        conn.disconnect(DisconnectReason.OTHER, true, message);
+        conn.disconnect(DisconnectReason.INVALID_CREDENTIALS, true, message);
       }
     }
   }
diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
index 413144d..c31f5cd 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -1091,6 +1091,9 @@
         case CONNECTION_REJECTED:
           resultCode = LDAPResultCode.CONSTRAINT_VIOLATION;
           break;
+        case INVALID_CREDENTIALS:
+          resultCode = LDAPResultCode.INVALID_CREDENTIALS;
+          break;
         default:
           resultCode = LDAPResultCode.OTHER;
           break;
diff --git a/opends/src/server/org/opends/server/types/DisconnectReason.java b/opends/src/server/org/opends/server/types/DisconnectReason.java
index a834b221..6b1a7f8 100644
--- a/opends/src/server/org/opends/server/types/DisconnectReason.java
+++ b/opends/src/server/org/opends/server/types/DisconnectReason.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Portions copyright 2011 ForgeRock AS
  */
 package org.opends.server.types;
 import org.opends.messages.Message;
@@ -117,6 +118,15 @@
 
 
   /**
+   * The disconnect reason that indicates that the client connection was closed
+   * because the bound user's entry is no longer accessible.
+   */
+  INVALID_CREDENTIALS(
+          INFO_DISCONNECT_DUE_TO_INVALID_CREDENTIALS.get()),
+
+
+
+  /**
    * The disconnect reason that indicates that the client connection
    * was closed because the maximum allowed request size was exceeded.
    */

--
Gitblit v1.10.0