From 73349bf8f8c04b23748ef61c663e4fa814da1c04 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Sat, 30 Oct 2004 01:19:22 +0000 Subject: [PATCH] Add convenience method so subclasses can specify Authentication.setDetails(). --- changelog.txt | 2 ++ .../ui/webapp/AuthenticationProcessingFilter.java | 14 ++++++++++++++ .../AuthenticationProcessingFilterTests.java | 1 + 3 files changed, 17 insertions(+) diff --git a/changelog.txt b/changelog.txt index e589e82262..2552b0b975 100644 --- a/changelog.txt +++ b/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 diff --git a/core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilter.java b/core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilter.java index 4fc2d85677..46cfc0b3a7 100644 --- a/core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilter.java +++ b/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()); + } } diff --git a/core/src/test/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilterTests.java b/core/src/test/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilterTests.java index 22d6f4abb9..97408fdbdb 100644 --- a/core/src/test/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilterTests.java +++ b/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 {