From dd39d747d53b57f54e499c709eeb9b9fe083658e Mon Sep 17 00:00:00 2001
From: Ben Alex
Date: Mon, 29 Mar 2004 13:39:30 +0000
Subject: [PATCH] Improved documentation and added methods to facilitate unit
testing.
---
.../adapters/AutoIntegrationFilter.java | 34 +++++++++++++++++--
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/core/src/main/java/org/acegisecurity/adapters/AutoIntegrationFilter.java b/core/src/main/java/org/acegisecurity/adapters/AutoIntegrationFilter.java
index 7c4e81f02f..787a05a258 100644
--- a/core/src/main/java/org/acegisecurity/adapters/AutoIntegrationFilter.java
+++ b/core/src/main/java/org/acegisecurity/adapters/AutoIntegrationFilter.java
@@ -31,6 +31,15 @@ import javax.servlet.http.HttpServletRequest;
* web.xml
will not need to refer to a specific container
* integration filter.
*
+ *
+ *
+ * The filter automatically delegates to
+ * HttpRequestIntegrationFilter
if any
+ * Authentication
object is detected in the
+ * ServletRequest
. Failing this, it will delegate to
+ * JbossIntegrationFilter
if the ServletRequest
+ * contains an instance of JBoss' SimplePrincipal
.
+ *
*
* @author Ben Alex
* @version $Id$
@@ -45,7 +54,7 @@ public class AutoIntegrationFilter extends AbstractIntegrationFilter {
HttpServletRequest httpRequest = (HttpServletRequest) request;
if (httpRequest.getUserPrincipal() instanceof Authentication) {
- return new HttpRequestIntegrationFilter().extractFromContainer(request);
+ return getHttpServletRequest().extractFromContainer(request);
}
try {
@@ -55,8 +64,7 @@ public class AutoIntegrationFilter extends AbstractIntegrationFilter {
if (null != httpRequest.getUserPrincipal()) {
if (simplePrincipalClass.isAssignableFrom(
httpRequest.getUserPrincipal().getClass())) {
- return new JbossIntegrationFilter()
- .extractFromContainer(request);
+ return getJbossIntegrationFilter().extractFromContainer(request);
}
}
} catch (ClassNotFoundException e) {
@@ -67,4 +75,24 @@ public class AutoIntegrationFilter extends AbstractIntegrationFilter {
return null;
}
+
+ /**
+ * Allows test case to override the source of
+ * HttpRequestIntegrationFilter
.
+ *
+ * @return the HttpRequestIntegrationFilter
to use
+ */
+ protected HttpRequestIntegrationFilter getHttpServletRequest() {
+ return new HttpRequestIntegrationFilter();
+ }
+
+ /**
+ * Allows test case to override the source of
+ * JbossIntegrationFilter
.
+ *
+ * @return the JbossIntegrationFilter
to use
+ */
+ protected JbossIntegrationFilter getJbossIntegrationFilter() {
+ return new JbossIntegrationFilter();
+ }
}