Browse Source

SEC-629: authentication-provider doesn't support caching. Refactored MockUserCache class to top level

Luke Taylor 17 years ago
parent
commit
db6fafaf56

+ 0 - 16
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.DataAccessException;
 import org.springframework.dao.DataRetrievalFailureException;
 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) {}
-    }
 }
 }

+ 26 - 0
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);
+    }
+}

+ 1 - 19
core/src/test/java/org/springframework/security/providers/siteminder/SiteminderAuthenticationProviderTests.java

@@ -15,9 +15,6 @@
 
 
 package org.springframework.security.providers.siteminder;
 package org.springframework.security.providers.siteminder;
 
 
-import java.util.HashMap;
-import java.util.Map;
-
 import junit.framework.TestCase;
 import junit.framework.TestCase;
 
 
 import org.springframework.security.AccountExpiredException;
 import org.springframework.security.AccountExpiredException;
@@ -31,7 +28,7 @@ import org.springframework.security.GrantedAuthorityImpl;
 import org.springframework.security.LockedException;
 import org.springframework.security.LockedException;
 import org.springframework.security.providers.TestingAuthenticationToken;
 import org.springframework.security.providers.TestingAuthenticationToken;
 import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
 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.EhCacheBasedUserCache;
 import org.springframework.security.providers.dao.cache.NullUserCache;
 import org.springframework.security.providers.dao.cache.NullUserCache;
 import org.springframework.security.userdetails.User;
 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) {
-        }
-    }
 }
 }