From 4a4a8540f0b64feff6934c3215c6f896c9561c7d Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 08 Feb 2007 22:27:58 +0000
Subject: [PATCH] Update the AuthenticationInfo object to store the entries for the authentication and authorization identities rather than just their DNs.  This includes a mechanism to keep those entries up to date as changes occur in the server, and also includes a hook for ClientConnection subclasses to perform processing whenever a connection is terminated.

---
 opends/src/server/org/opends/server/core/BindOperation.java |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/BindOperation.java b/opends/src/server/org/opends/server/core/BindOperation.java
index fa694e4..0489f66 100644
--- a/opends/src/server/org/opends/server/core/BindOperation.java
+++ b/opends/src/server/org/opends/server/core/BindOperation.java
@@ -147,6 +147,10 @@
   // The DN of the user entry that is attempting to authenticate.
   private DN userEntryDN;
 
+  // The entry of the user that successfully authenticated during processing of
+  // this bind operation.
+  private Entry authenticatedUserEntry;
+
   // The DN of the user as whom a SASL authentication was attempted (regardless
   // of whether the authentication was successful) for the purpose of updating
   // password policy state information.
@@ -244,6 +248,7 @@
     responseControls         = new ArrayList<Control>(0);
     authFailureID            = 0;
     authFailureReason        = null;
+    authenticatedUserEntry   = null;
     saslAuthUserEntry        = null;
     isFirstWarning           = false;
     isGraceLogin             = false;
@@ -304,12 +309,13 @@
       this.rawBindDN = rawBindDN;
     }
 
-    bindDN            = null;
-    userEntryDN       = null;
-    responseControls  = new ArrayList<Control>(0);
-    authFailureID     = 0;
-    authFailureReason = null;
-    saslAuthUserEntry = null;
+    bindDN                 = null;
+    userEntryDN            = null;
+    responseControls       = new ArrayList<Control>(0);
+    authFailureID          = 0;
+    authFailureReason      = null;
+    authenticatedUserEntry = null;
+    saslAuthUserEntry      = null;
   }
 
 
@@ -369,6 +375,7 @@
     responseControls         = new ArrayList<Control>(0);
     authFailureID            = 0;
     authFailureReason        = null;
+    authenticatedUserEntry   = null;
     saslAuthUserEntry        = null;
     isFirstWarning           = false;
     isGraceLogin             = false;
@@ -429,11 +436,12 @@
       rawBindDN = new ASN1OctetString(bindDN.toString());
     }
 
-    responseControls  = new ArrayList<Control>(0);
-    authFailureID     = 0;
-    authFailureReason = null;
-    saslAuthUserEntry = null;
-    userEntryDN       = null;
+    responseControls       = new ArrayList<Control>(0);
+    authFailureID          = 0;
+    authFailureReason      = null;
+    authenticatedUserEntry = null;
+    saslAuthUserEntry      = null;
+    userEntryDN            = null;
   }
 
 
@@ -1481,8 +1489,8 @@
               setResultCode(ResultCode.SUCCESS);
 
               boolean isRoot = DirectoryServer.isRootDN(userEntry.getDN());
-              authInfo = new AuthenticationInfo(userEntry.getDN(),
-                                                simplePassword, isRoot);
+              authInfo = new AuthenticationInfo(userEntry, simplePassword,
+                                                isRoot);
 
 
               // See if the user's entry contains a custom size limit.
@@ -2220,6 +2228,7 @@
     // Update the authentication information for the user.
     if ((getResultCode() == ResultCode.SUCCESS) && (authInfo != null))
     {
+      authenticatedUserEntry = authInfo.getAuthenticationEntry();
       clientConnection.setAuthenticationInfo(authInfo);
       clientConnection.setSizeLimit(sizeLimit);
       clientConnection.setTimeLimit(timeLimit);

--
Gitblit v1.10.0