From 3cce0b71d9e4cd41945769415716b2fb782c63a7 Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 07 Mar 2016 10:33:14 +0000
Subject: [PATCH] OPENDJ-2659 lazily recompute virtual attributes before updating privileges

---
 opendj-server-legacy/src/main/java/org/opends/server/core/AuthenticatedUsers.java |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/AuthenticatedUsers.java b/opendj-server-legacy/src/main/java/org/opends/server/core/AuthenticatedUsers.java
index 6ad420e..f891326 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/AuthenticatedUsers.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/AuthenticatedUsers.java
@@ -221,22 +221,28 @@
   {
     final Entry oldEntry = op.getCurrentEntry();
 
-    if (op.getResultCode() != ResultCode.SUCCESS || oldEntry == null) {
+    if (op.getResultCode() != ResultCode.SUCCESS || oldEntry == null)
+    {
       return PostResponse.continueOperationProcessing();
     }
 
-    final Entry newEntry = op.getModifiedEntry();
     // Identify any client connections that may be authenticated
     // or authorized as the user whose entry has been modified
-    // and update them with the latest version of the entry.
+    // and update them with the latest version of the entry
+    // including any virtual attributes.
     lock.writeLock().lock();
     try
     {
       CopyOnWriteArraySet<ClientConnection> connectionSet = userMap.get(oldEntry.getName());
       if (connectionSet != null)
       {
+        Entry newEntry = null;
         for (ClientConnection conn : connectionSet)
         {
+          if (newEntry == null)
+          {
+            newEntry = op.getModifiedEntry().duplicate(true);
+          }
           conn.updateAuthenticationInfo(oldEntry, newEntry);
         }
       }

--
Gitblit v1.10.0