Commit 88caa4d1 authored by Roman S's avatar Roman S

OF-754: Lock out user option works incorrectly in some cases

parent 1575642d
......@@ -145,22 +145,8 @@ public class LockOutManager {
if (username == null) {
throw new UnsupportedOperationException("Null username not allowed!");
}
if (provider.shouldNotBeCached()) {
return provider.getDisabledStatus(username);
}
LockOutFlag flag = lockOutCache.get(username);
// If ID wan't found in cache, load it up and put it there.
if (flag == null) {
synchronized (username.intern()) {
flag = lockOutCache.get(username);
// If group wan't found in cache, load it up and put it there.
if (flag == null) {
flag = provider.getDisabledStatus(username);
lockOutCache.put(username, flag);
}
}
}
return flag;
LockOutFlag lockOutFlag = getUserLockOut(username);
return getUnExpiredLockout(lockOutFlag);
}
/**
......@@ -239,5 +225,50 @@ public class LockOutManager {
// Fire event.
LockOutEventDispatcher.lockedAccountDenied(username);
}
/**
* Gets the user lock out.
*
* @param username
* the username
* @return the user lock out
*/
private LockOutFlag getUserLockOut(String username) {
if (provider.shouldNotBeCached()) {
return provider.getDisabledStatus(username);
}
LockOutFlag flag = lockOutCache.get(username);
// If ID wan't found in cache, load it up and put it there.
if (flag == null) {
synchronized (username.intern()) {
flag = lockOutCache.get(username);
// If group wan't found in cache, load it up and put it there.
if (flag == null) {
flag = provider.getDisabledStatus(username);
lockOutCache.put(username, flag);
}
}
}
return flag;
}
/**
* Check if lockout flag is expired.
*
* @param flag
* the flag
*/
private LockOutFlag getUnExpiredLockout(LockOutFlag flag) {
if (flag != null) {
Date curDate = new Date();
if (flag.getEndTime() != null && curDate.after(flag.getEndTime())) {
// Remove expired lockout entry
lockOutCache.remove(flag.getUsername());
provider.unsetDisabledStatus(flag.getUsername());
return null;
}
}
return flag;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment