Commit 10081d25 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Ported changes from 3.5.0 branch.


git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9979 b35dd754-fafc-0310-a699-88a17e54d16e
parent 787a8403
......@@ -101,6 +101,14 @@ public class ClearspaceLockOutProvider implements LockOutProvider {
return false;
}
/**
* Clearspace needs to always be queried for disabled status.
* @see org.jivesoftware.openfire.lockout.LockOutProvider#shouldNotBeCached()
*/
public boolean shouldNotBeCached() {
return true;
}
/**
* Looks up and modifies a user's CS properties to indicate whether they are enabled or disabled.
* It is important for this to incorporate the existing user data and only tweak the field
......@@ -176,6 +184,9 @@ public class ClearspaceLockOutProvider implements LockOutProvider {
return new LockOutFlag(username, null, null);
}
}
catch (NotLockedOutException e) {
throw e;
}
catch (Exception e) {
// Hrm. This is not good. We have to opt on the side of positive.
Log.error("Error while looking up user's disabled status from Clearspace: ", e);
......
......@@ -166,4 +166,12 @@ public class DefaultLockOutProvider implements LockOutProvider {
return true;
}
/**
* Default provider should be cached.
* @see org.jivesoftware.openfire.lockout.LockOutProvider#shouldNotBeCached()
*/
public boolean shouldNotBeCached() {
return false;
}
}
......@@ -129,6 +129,9 @@ 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) {
......@@ -187,8 +190,10 @@ public class LockOutManager {
}
LockOutFlag flag = new LockOutFlag(username, startTime, endTime);
provider.setDisabledStatus(flag);
// Add lockout data to cache.
lockOutCache.put(username, flag);
if (!provider.shouldNotBeCached()) {
// Add lockout data to cache.
lockOutCache.put(username, flag);
}
// Fire event.
LockOutEventDispatcher.accountLocked(flag);
}
......@@ -206,8 +211,10 @@ public class LockOutManager {
throw new UnsupportedOperationException();
}
provider.unsetDisabledStatus(username);
// Remove lockout data from cache.
lockOutCache.remove(username);
if (!provider.shouldNotBeCached()) {
// Remove lockout data from cache.
lockOutCache.remove(username);
}
// Fire event.
LockOutEventDispatcher.accountUnlocked(username);
}
......
......@@ -70,4 +70,13 @@ public interface LockOutProvider {
*/
public boolean isTimeoutSupported();
/**
* Returns true if the lock out flags should not be cached, meaning every status lookup will
* go straight to the source. This is typically set if the status can change on the provider
* target without Openfire knowing about it.
*
* @return true if disabled status should not be cached.
*/
public boolean shouldNotBeCached();
}
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