浏览代码

DigestProcessingFilter now provides userCache getter and setter.

Ben Alex 20 年之前
父节点
当前提交
c936801842

+ 8 - 0
core/src/main/java/org/acegisecurity/ui/digestauth/DigestProcessingFilter.java

@@ -435,6 +435,14 @@ public class DigestProcessingFilter implements Filter, InitializingBean {
         return digestMd5;
     }
 
+    public void setUserCache(UserCache userCache) {
+        this.userCache = userCache;
+    }
+
+    public UserCache getUserCache() {
+        return userCache;
+    }
+
     public void init(FilterConfig arg0) throws ServletException {}
 
     private void fail(ServletRequest request, ServletResponse response,

+ 16 - 0
core/src/test/java/org/acegisecurity/ui/digestauth/DigestProcessingFilterTests.java

@@ -27,6 +27,7 @@ import net.sf.acegisecurity.context.ContextHolder;
 import net.sf.acegisecurity.context.security.SecureContextImpl;
 import net.sf.acegisecurity.context.security.SecureContextUtils;
 import net.sf.acegisecurity.providers.dao.AuthenticationDao;
+import net.sf.acegisecurity.providers.dao.UserCache;
 import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
 import net.sf.acegisecurity.util.StringSplitUtils;
 
@@ -193,6 +194,11 @@ public class DigestProcessingFilterTests extends TestCase {
 
         filter.setAuthenticationEntryPoint(new DigestProcessingFilterEntryPoint());
         assertTrue(filter.getAuthenticationEntryPoint() != null);
+
+        filter.setUserCache(null);
+        assertNull(filter.getUserCache());
+        filter.setUserCache(new MockUserCache());
+        assertNotNull(filter.getUserCache());
     }
 
     public void testInvalidDigestAuthorizationTokenGeneratesError()
@@ -885,4 +891,14 @@ public class DigestProcessingFilterTests extends TestCase {
             }
         }
     }
+
+    private class MockUserCache implements UserCache {
+        public UserDetails getUserFromCache(String username) {
+            return null;
+        }
+
+        public void putUserInCache(UserDetails user) {}
+
+        public void removeUserFromCache(String username) {}
+    }
 }

+ 1 - 0
doc/xdocs/changes.xml

@@ -37,6 +37,7 @@
       <action dev="benalex" type="fix">TokenBasedRememberMeServices now respects expired users, expired credentials and disabled users</action>
       <action dev="benalex" type="fix">HttpSessionContextIntegrationFilter now handles HttpSession invalidation without redirection</action>
       <action dev="benalex" type="fix">StringSplitUtils.split() ignored delimiter argument</action>
+      <action dev="benalex" type="fix">DigestProcessingFilter now provides userCache getter and setter</action>
     </release>
     <release version="0.8.0" date="2005-03-03">
       <action dev="benalex" type="add">Added Digest Authentication support (RFC 2617 and RFC 2069)</action>