From 2d838c933b9a3ce360855f11c14a5fb08712868d Mon Sep 17 00:00:00 2001
From: david_page <david_page@localhost>
Date: Mon, 12 Mar 2007 13:38:34 +0000
Subject: [PATCH] The following update to core.PasswordPolicyState.java, along with some small changes to consumers of its API are the result of a review in preparation for password policy state management extended operation (issue 579).

---
 opends/src/server/org/opends/server/core/BindOperation.java |   30 +++++++++---------------------
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/BindOperation.java b/opends/src/server/org/opends/server/core/BindOperation.java
index 51909be..2c75910 100644
--- a/opends/src/server/org/opends/server/core/BindOperation.java
+++ b/opends/src/server/org/opends/server/core/BindOperation.java
@@ -1542,7 +1542,7 @@
 
 
               pwPolicyState.handleDeprecatedStorageSchemes(simplePassword);
-              pwPolicyState.clearAuthFailureTimes();
+              pwPolicyState.clearFailureLockout();
 
               if (isFirstWarning)
               {
@@ -1574,21 +1574,15 @@
               setResultCode(ResultCode.INVALID_CREDENTIALS);
               setAuthFailureReason(msgID, message);
 
-              int maxAllowedFailures
-                   = pwPolicyState.getPolicy().getLockoutFailureCount();
-              if (maxAllowedFailures > 0)
+              if (pwPolicyState.getPolicy().getLockoutFailureCount() > 0)
               {
                 pwPolicyState.updateAuthFailureTimes();
-                if (pwPolicyState.getAuthFailureTimes().size() >=
-                    maxAllowedFailures)
+                if (pwPolicyState.lockedDueToFailures())
                 {
-                  pwPolicyState.lockDueToFailures();
-
                   AccountStatusNotificationType notificationType;
 
-                  int lockoutDuration
-                       = pwPolicyState.getPolicy().getLockoutDuration();
-                  if (lockoutDuration > 0)
+                  int lockoutDuration = pwPolicyState.getSecondsUntilUnlock();
+                  if (lockoutDuration > -1)
                   {
                     notificationType = AccountStatusNotificationType.
                                             ACCOUNT_TEMPORARILY_LOCKED;
@@ -2073,23 +2067,17 @@
               if (saslHandler.isPasswordBased(saslMechanism))
               {
 
-                int maxAllowedFailures
-                     = pwPolicyState.getPolicy().getLockoutFailureCount();
-                if (maxAllowedFailures > 0)
+                if (pwPolicyState.getPolicy().getLockoutFailureCount() > 0)
                 {
                   pwPolicyState.updateAuthFailureTimes();
-                  if (pwPolicyState.getAuthFailureTimes().size() >=
-                      maxAllowedFailures)
+                  if (pwPolicyState.lockedDueToFailures())
                   {
-                    pwPolicyState.lockDueToFailures();
-
                     AccountStatusNotificationType notificationType;
                     int msgID;
                     String message;
 
-                    int lockoutDuration
-                         = pwPolicyState.getPolicy().getLockoutDuration();
-                    if (lockoutDuration > 0)
+                    int lockoutDuration = pwPolicyState.getSecondsUntilUnlock();
+                    if (lockoutDuration > -1)
                     {
                       notificationType = AccountStatusNotificationType.
                                               ACCOUNT_TEMPORARILY_LOCKED;

--
Gitblit v1.10.0