Commit b65dbe6c authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Added flag for not caching lock out provider data for situations where it should not be cached.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches@9978 b35dd754-fafc-0310-a699-88a17e54d16e
parent c797b1ad
...@@ -101,6 +101,14 @@ public class ClearspaceLockOutProvider implements LockOutProvider { ...@@ -101,6 +101,14 @@ public class ClearspaceLockOutProvider implements LockOutProvider {
return false; 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. * 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 * It is important for this to incorporate the existing user data and only tweak the field
......
...@@ -166,4 +166,12 @@ public class DefaultLockOutProvider implements LockOutProvider { ...@@ -166,4 +166,12 @@ public class DefaultLockOutProvider implements LockOutProvider {
return true; 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 { ...@@ -129,6 +129,9 @@ public class LockOutManager {
if (username == null) { if (username == null) {
throw new UnsupportedOperationException("Null username not allowed!"); throw new UnsupportedOperationException("Null username not allowed!");
} }
if (!provider.shouldNotBeCached()) {
return provider.getDisabledStatus(username);
}
LockOutFlag flag = lockOutCache.get(username); LockOutFlag flag = lockOutCache.get(username);
// If ID wan't found in cache, load it up and put it there. // If ID wan't found in cache, load it up and put it there.
if (flag == null) { if (flag == null) {
...@@ -187,8 +190,10 @@ public class LockOutManager { ...@@ -187,8 +190,10 @@ public class LockOutManager {
} }
LockOutFlag flag = new LockOutFlag(username, startTime, endTime); LockOutFlag flag = new LockOutFlag(username, startTime, endTime);
provider.setDisabledStatus(flag); provider.setDisabledStatus(flag);
if (!provider.shouldNotBeCached()) {
// Add lockout data to cache. // Add lockout data to cache.
lockOutCache.put(username, flag); lockOutCache.put(username, flag);
}
// Fire event. // Fire event.
LockOutEventDispatcher.accountLocked(flag); LockOutEventDispatcher.accountLocked(flag);
} }
...@@ -206,8 +211,10 @@ public class LockOutManager { ...@@ -206,8 +211,10 @@ public class LockOutManager {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
provider.unsetDisabledStatus(username); provider.unsetDisabledStatus(username);
if (!provider.shouldNotBeCached()) {
// Remove lockout data from cache. // Remove lockout data from cache.
lockOutCache.remove(username); lockOutCache.remove(username);
}
// Fire event. // Fire event.
LockOutEventDispatcher.accountUnlocked(username); LockOutEventDispatcher.accountUnlocked(username);
} }
......
...@@ -70,4 +70,13 @@ public interface LockOutProvider { ...@@ -70,4 +70,13 @@ public interface LockOutProvider {
*/ */
public boolean isTimeoutSupported(); 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