From db6fafaf56178cb2882690f6cdf2104ce0e98c00 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Fri, 28 Mar 2008 14:17:05 +0000 Subject: [PATCH] SEC-629: authentication-provider doesn't support caching. Refactored MockUserCache class to top level --- .../dao/DaoAuthenticationProviderTests.java | 16 ------------ .../security/providers/dao/MockUserCache.java | 26 +++++++++++++++++++ ...SiteminderAuthenticationProviderTests.java | 20 +------------- 3 files changed, 27 insertions(+), 35 deletions(-) create mode 100644 core/src/test/java/org/springframework/security/providers/dao/MockUserCache.java diff --git a/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java index cade3eb7de..5053aa246e 100644 --- a/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java @@ -42,8 +42,6 @@ import org.springframework.security.userdetails.UsernameNotFoundException; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataRetrievalFailureException; -import java.util.HashMap; -import java.util.Map; /** @@ -531,18 +529,4 @@ public class DaoAuthenticationProviderTests extends TestCase { } } } - - private class MockUserCache implements UserCache { - private Map cache = new HashMap(); - - public UserDetails getUserFromCache(String username) { - return (User) cache.get(username); - } - - public void putUserInCache(UserDetails user) { - cache.put(user.getUsername(), user); - } - - public void removeUserFromCache(String username) {} - } } diff --git a/core/src/test/java/org/springframework/security/providers/dao/MockUserCache.java b/core/src/test/java/org/springframework/security/providers/dao/MockUserCache.java new file mode 100644 index 0000000000..37209234a2 --- /dev/null +++ b/core/src/test/java/org/springframework/security/providers/dao/MockUserCache.java @@ -0,0 +1,26 @@ +/** + * + */ +package org.springframework.security.providers.dao; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.security.userdetails.User; +import org.springframework.security.userdetails.UserDetails; + +public class MockUserCache implements UserCache { + private Map cache = new HashMap(); + + public UserDetails getUserFromCache(String username) { + return (User) cache.get(username); + } + + public void putUserInCache(UserDetails user) { + cache.put(user.getUsername(), user); + } + + public void removeUserFromCache(String username) { + cache.remove(username); + } +} \ No newline at end of file diff --git a/core/src/test/java/org/springframework/security/providers/siteminder/SiteminderAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/providers/siteminder/SiteminderAuthenticationProviderTests.java index 652078ff23..de31c3338f 100644 --- a/core/src/test/java/org/springframework/security/providers/siteminder/SiteminderAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/providers/siteminder/SiteminderAuthenticationProviderTests.java @@ -15,9 +15,6 @@ package org.springframework.security.providers.siteminder; -import java.util.HashMap; -import java.util.Map; - import junit.framework.TestCase; import org.springframework.security.AccountExpiredException; @@ -31,7 +28,7 @@ import org.springframework.security.GrantedAuthorityImpl; import org.springframework.security.LockedException; import org.springframework.security.providers.TestingAuthenticationToken; import org.springframework.security.providers.UsernamePasswordAuthenticationToken; -import org.springframework.security.providers.dao.UserCache; +import org.springframework.security.providers.dao.MockUserCache; import org.springframework.security.providers.dao.cache.EhCacheBasedUserCache; import org.springframework.security.providers.dao.cache.NullUserCache; import org.springframework.security.userdetails.User; @@ -404,19 +401,4 @@ public class SiteminderAuthenticationProviderTests extends TestCase { } } } - - private class MockUserCache implements UserCache { - private Map cache = new HashMap(); - - public UserDetails getUserFromCache(String username) { - return (User) cache.get(username); - } - - public void putUserInCache(UserDetails user) { - cache.put(user.getUsername(), user); - } - - public void removeUserFromCache(String username) { - } - } }