diff --git a/changelog.txt b/changelog.txt
index 2498fa9881..efe7721445 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -3,6 +3,7 @@ Changes in version 0.x (2004-xx-xx)
* Added additional DaoAuthenticationProvider event when user not found
* Added Authentication.getDetails() to DaoAuthenticationProvider response
+* Extracted removeUserFromCache(String) to UserCache interface
* Fixed EH-CACHE-based caching implementation behaviour when cache exists
* Fixed Ant "release" target not including project.properties
* Documentation improvements
diff --git a/core/src/main/java/org/acegisecurity/providers/dao/UserCache.java b/core/src/main/java/org/acegisecurity/providers/dao/UserCache.java
index 8f538cf45f..d06b9328ef 100644
--- a/core/src/main/java/org/acegisecurity/providers/dao/UserCache.java
+++ b/core/src/main/java/org/acegisecurity/providers/dao/UserCache.java
@@ -54,4 +54,20 @@ public interface UserCache {
* cache
*/
public void putUserInCache(UserDetails user);
+
+ /**
+ * Removes the specified user from the cache. The username is
+ * the key used to remove the user. If the user is not found, the method
+ * should simply return (not thrown an exception).
+ *
+ *
+ * Some cache implementations may not support eviction from the cache, in + * which case they should provide appropriate behaviour to alter the user + * in either its documentation, via an exception, or through a log + * message. + *
+ * + * @param username to be evicted from the cache + */ + public void removeUserFromCache(String username); } diff --git a/core/src/main/java/org/acegisecurity/providers/dao/cache/NullUserCache.java b/core/src/main/java/org/acegisecurity/providers/dao/cache/NullUserCache.java index bf3a9cdc65..623d3d03d4 100644 --- a/core/src/main/java/org/acegisecurity/providers/dao/cache/NullUserCache.java +++ b/core/src/main/java/org/acegisecurity/providers/dao/cache/NullUserCache.java @@ -33,4 +33,6 @@ public class NullUserCache implements UserCache { } public void putUserInCache(UserDetails user) {} + + public void removeUserFromCache(String username) {} } diff --git a/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java b/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java index acba3cc7b8..186e8cffe9 100644 --- a/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java +++ b/core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationProviderTests.java @@ -354,5 +354,7 @@ public class DaoAuthenticationProviderTests extends TestCase { public void putUserInCache(UserDetails user) { cache.put(user.getUsername(), user); } + + public void removeUserFromCache(String username) {} } } diff --git a/core/src/test/java/org/acegisecurity/providers/dao/cache/NullUserCacheTests.java b/core/src/test/java/org/acegisecurity/providers/dao/cache/NullUserCacheTests.java index 477cace3bd..9c5df76a05 100644 --- a/core/src/test/java/org/acegisecurity/providers/dao/cache/NullUserCacheTests.java +++ b/core/src/test/java/org/acegisecurity/providers/dao/cache/NullUserCacheTests.java @@ -53,6 +53,7 @@ public class NullUserCacheTests extends TestCase { NullUserCache cache = new NullUserCache(); cache.putUserInCache(getUser()); assertNull(cache.getUserFromCache(null)); + cache.removeUserFromCache(null); } private User getUser() {