Refactor AbstractFilterInvocationDefinitionSource to use a standard URL String in its lookup method, rather than a full FilterInvocation. This will make it easier for views (taglibs etc) to access URI security details without needing to construct a MockFilterInvocation.

This commit is contained in:
Ben Alex 2004-12-05 05:04:52 +00:00
parent 76c82db196
commit 82ed7253d4
7 changed files with 41 additions and 30 deletions

View File

@ -42,15 +42,9 @@ public abstract class AbstractFilterInvocationDefinitionSource
"Object must be a FilterInvocation");
}
return this.lookupAttributes((FilterInvocation) object);
}
String url = ((FilterInvocation) object).getRequestUrl();
public boolean supports(Class clazz) {
if (FilterInvocation.class.isAssignableFrom(clazz)) {
return true;
} else {
return false;
}
return this.lookupAttributes(url);
}
/**
@ -62,10 +56,27 @@ public abstract class AbstractFilterInvocationDefinitionSource
* Provided so subclasses need only to provide one basic method to properly
* interface with the <code>FilterInvocationDefinitionSource</code>.
* </p>
*
* <P>
* Public visiblity so that tablibs or other view helper classes can access
* the <code>ConfigAttributeDefinition</code> applying to a given URI
* pattern without needing to construct a mock
* <code>FilterInvocation</code> and retrieving the attibutes via the
* {@link #getAttributes(Object)} method.
* </p>
*
* @param url the URI to retrieve configuration attributes for
*
* @return the <code>ConfigAttributeDefinition</code> that applies to the
* specified <code>FilterInvocation</code>
*/
protected abstract ConfigAttributeDefinition lookupAttributes(
FilterInvocation filterInvocation);
public abstract ConfigAttributeDefinition lookupAttributes(String url);
public boolean supports(Class clazz) {
if (FilterInvocation.class.isAssignableFrom(clazz)) {
return true;
} else {
return false;
}
}
}

View File

@ -99,18 +99,15 @@ public class PathBasedFilterInvocationDefinitionMap
}
}
protected ConfigAttributeDefinition lookupAttributes(
FilterInvocation filterInvocation) {
public ConfigAttributeDefinition lookupAttributes(String url) {
Iterator iter = requestMap.iterator();
String url = filterInvocation.getRequestUrl();
if (convertUrlToLowercaseBeforeComparison) {
url = url.toLowerCase();
if (logger.isDebugEnabled()) {
logger.debug("Converted URL to lowercase, from: '"
+ filterInvocation.getRequest() + "'; to: '" + url + "'");
logger.debug("Converted URL to lowercase, from: '" + url
+ "'; to: '" + url + "'");
}
}

View File

@ -117,20 +117,17 @@ public class RegExpBasedFilterInvocationDefinitionMap
}
}
protected ConfigAttributeDefinition lookupAttributes(
FilterInvocation filterInvocation) {
public ConfigAttributeDefinition lookupAttributes(String url) {
PatternMatcher matcher = new Perl5Matcher();
Iterator iter = requestMap.iterator();
String url = filterInvocation.getRequestUrl();
if (convertUrlToLowercaseBeforeComparison) {
url = url.toLowerCase();
if (logger.isDebugEnabled()) {
logger.debug("Converted URL to lowercase, from: '"
+ filterInvocation.getRequest() + "'; to: '" + url + "'");
logger.debug("Converted URL to lowercase, from: '" + url
+ "'; to: '" + url + "'");
}
}

View File

@ -81,8 +81,7 @@ public class MockFilterInvocationDefinitionSource
}
}
protected ConfigAttributeDefinition lookupAttributes(
FilterInvocation filterInvocation) {
public ConfigAttributeDefinition lookupAttributes(String url) {
throw new UnsupportedOperationException("mock method not implemented");
}
}

View File

@ -79,7 +79,8 @@ public class PathBasedFilterDefinitionMapTests extends TestCase {
FilterInvocation fi = new FilterInvocation(req,
new MockHttpServletResponse(), new MockFilterChain());
ConfigAttributeDefinition response = map.lookupAttributes(fi);
ConfigAttributeDefinition response = map.lookupAttributes(fi
.getRequestUrl());
assertEquals(def, response);
}
@ -98,7 +99,8 @@ public class PathBasedFilterDefinitionMapTests extends TestCase {
FilterInvocation fi = new FilterInvocation(req,
new MockHttpServletResponse(), new MockFilterChain());
ConfigAttributeDefinition response = map.lookupAttributes(fi);
ConfigAttributeDefinition response = map.lookupAttributes(fi
.getRequestUrl());
assertEquals(null, response);
}
@ -117,7 +119,8 @@ public class PathBasedFilterDefinitionMapTests extends TestCase {
FilterInvocation fi = new FilterInvocation(req,
new MockHttpServletResponse(), new MockFilterChain());
ConfigAttributeDefinition response = map.lookupAttributes(fi);
ConfigAttributeDefinition response = map.lookupAttributes(fi
.getRequestUrl());
assertEquals(def, response);
}
}

View File

@ -79,7 +79,8 @@ public class RegExpBasedFilterDefinitionMapTests extends TestCase {
FilterInvocation fi = new FilterInvocation(req,
new MockHttpServletResponse(), new MockFilterChain());
ConfigAttributeDefinition response = map.lookupAttributes(fi);
ConfigAttributeDefinition response = map.lookupAttributes(fi
.getRequestUrl());
assertEquals(def, response);
}
@ -98,7 +99,8 @@ public class RegExpBasedFilterDefinitionMapTests extends TestCase {
FilterInvocation fi = new FilterInvocation(req,
new MockHttpServletResponse(), new MockFilterChain());
ConfigAttributeDefinition response = map.lookupAttributes(fi);
ConfigAttributeDefinition response = map.lookupAttributes(fi
.getRequestUrl());
assertEquals(null, response);
}
@ -117,7 +119,8 @@ public class RegExpBasedFilterDefinitionMapTests extends TestCase {
FilterInvocation fi = new FilterInvocation(req,
new MockHttpServletResponse(), new MockFilterChain());
ConfigAttributeDefinition response = map.lookupAttributes(fi);
ConfigAttributeDefinition response = map.lookupAttributes(fi
.getRequestUrl());
assertEquals(def, response);
}
}

View File

@ -45,6 +45,7 @@
<action dev="benalex" type="add">Added AbstractProcessingFilter property to always use defaultTargetUrl</action>
<action dev="benalex" type="update">Improved BasicAclProvider to only respond to specified ACL object requests</action>
<action dev="benalex" type="update">Refactored MethodDefinitionSource to work with Method, not MethodInvocation</action>
<action dev="benalex" type="update">Refactored AbstractFilterInvocationDefinitionSource to work with URL Strings alone</action>
<action dev="benalex" type="update">Refactored AbstractSecurityInterceptor to better support other AOP libraries</action>
<action dev="benalex" type="update">Improved performance of JBoss container adapter (see reference docs)</action>
<action dev="benalex" type="update">Made DaoAuthenticationProvider detect null in Authentication.principal</action>