Sfoglia il codice sorgente

Add convenience method so subclasses can specify Authentication.setDetails().

Ben Alex 21 anni fa
parent
commit
73349bf8f8

+ 2 - 0
changelog.txt

@@ -1,9 +1,11 @@
 Changes in version 0.7 (2004-xx-xx)
 -----------------------------------
 
+* Major CVS repository restructure to support Maven and eliminate libraries
 * Added AspectJ support (especially useful for instance-level security)
 * Added MethodDefinitionSourceAdvisor for performance and autoproxying
 * Added MethodDefinitionMap querying of interfaces defined by secure objects
+* Added AuthenticationProcessingFilter.setDetails for use by subclasses
 * Refactored MethodDefinitionSource to work with Method, not MethodInvocation
 * Refactored AbstractSecurityInterceptor to better support other AOP libraries
 * Moved MethodSecurityInterceptor to ...intercept.method.aopalliance package

+ 14 - 0
core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilter.java

@@ -83,4 +83,18 @@ public class AuthenticationProcessingFilter extends AbstractProcessingFilter {
     }
 
     public void init(FilterConfig filterConfig) throws ServletException {}
+
+    /**
+     * Provided so that subclasses may configure what is put into the
+     * authentication request's details property. Default implementation
+     * simply sets the IP address of the servlet request.
+     *
+     * @param request that an authentication request is being created for
+     * @param authRequest the authentication request object that should have
+     *        its details set
+     */
+    protected void setDetails(HttpServletRequest request,
+        UsernamePasswordAuthenticationToken authRequest) {
+        authRequest.setDetails(request.getRemoteAddr());
+    }
 }

+ 1 - 0
core/src/test/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilterTests.java

@@ -72,6 +72,7 @@ public class AuthenticationProcessingFilterTests extends TestCase {
 
         Authentication result = filter.attemptAuthentication(request);
         assertTrue(result != null);
+        assertEquals("127.0.0.1", result.getDetails());
     }
 
     public void testNullPasswordHandledGracefully() throws Exception {