From 77f20a44a73bc404678940faf43bbf30a671c4c2 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 05 Dec 2006 02:33:00 +0000
Subject: [PATCH] Update the password policy state management code to properly return a value of -1 when attempting to get the last login time for a user when it isn't possible to do so for some reason.  Even though the documentation said it would return -1 in this case, it was actually returning the creation timestamp for the entry.

---
 opends/src/server/org/opends/server/core/PasswordPolicyState.java |   50 ++++++++++++++++++++++++++++++--------------------
 1 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/PasswordPolicyState.java b/opends/src/server/org/opends/server/core/PasswordPolicyState.java
index 6c2008f..0f2e90a 100644
--- a/opends/src/server/org/opends/server/core/PasswordPolicyState.java
+++ b/opends/src/server/org/opends/server/core/PasswordPolicyState.java
@@ -1917,12 +1917,11 @@
         {
           debugMessage(DebugLogCategory.PASSWORD_POLICY, DebugLogSeverity.INFO,
                        CLASS_NAME, "getLastLoginTime",
-                       "Returning creation time of " + createTime +
-                       " for user " + userDNString + " because no last login " +
-                       "time will be maintained.");
+                       "Returning -1 for user " + userDNString +
+                       " because no last login time will be maintained.");
         }
 
-        lastLoginTime = createTime;
+        lastLoginTime = -1;
         return lastLoginTime;
       }
 
@@ -1933,12 +1932,11 @@
         {
           debugMessage(DebugLogCategory.PASSWORD_POLICY, DebugLogSeverity.INFO,
                        CLASS_NAME, "getLastLoginTime",
-                       "Returning creation time of " + createTime +
-                       " for user " + userDNString + " because no last login " +
-                       "time value exists.");
+                       "Returning -1 for user " + userDNString +
+                       " because no last login time value exists.");
         }
 
-        lastLoginTime = createTime;
+        lastLoginTime = -1;
         return lastLoginTime;
       }
 
@@ -2003,17 +2001,28 @@
               debugMessage(DebugLogCategory.PASSWORD_POLICY,
                            DebugLogSeverity.WARNING,
                            CLASS_NAME, "getLastLoginTime",
-                           "Returning creation time of " + createTime +
-                           " for user " + userDNString + " because the last " +
-                           "login time value " + valueString +
+                           "Returning -1 for user " + userDNString +
+                           " because the last login time value " + valueString +
                            "could not be parsed using any known format.");
             }
 
-            lastLoginTime = createTime;
+            lastLoginTime = -1;
             return lastLoginTime;
           }
         }
       }
+
+
+      // We shouldn't get here.
+      if (debug)
+      {
+        debugMessage(DebugLogCategory.PASSWORD_POLICY, DebugLogSeverity.WARNING,
+                     CLASS_NAME, "getLastLoginTime",
+                     "Returning -1 for user " + userDNString +
+                     " because even though there appears to be a last " +
+                     "login time value we couldn't decipher it.");
+      }
+      return -1;
     }
 
     if (debug)
@@ -2143,14 +2152,15 @@
       {
         if (lastLoginTime > lockTime)
         {
-        if (debug)
-        {
-          debugMessage(DebugLogCategory.PASSWORD_POLICY, DebugLogSeverity.INFO,
-                       CLASS_NAME, "lockedDueToIdleInterval",
-                       "Returning false for user " + userDNString +
-                       " because the last login time is in an acceptable " +
-                         "window.");
-        }
+          if (debug)
+          {
+            debugMessage(DebugLogCategory.PASSWORD_POLICY,
+                         DebugLogSeverity.INFO, CLASS_NAME,
+                         "lockedDueToIdleInterval",
+                         "Returning false for user " + userDNString +
+                         " because the last login time is in an acceptable " +
+                           "window.");
+          }
 
           isIdleLocked = ConditionResult.FALSE;
           return false;

--
Gitblit v1.10.0