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:
parent
76c82db196
commit
82ed7253d4
|
@ -42,15 +42,9 @@ public abstract class AbstractFilterInvocationDefinitionSource
|
||||||
"Object must be a FilterInvocation");
|
"Object must be a FilterInvocation");
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.lookupAttributes((FilterInvocation) object);
|
String url = ((FilterInvocation) object).getRequestUrl();
|
||||||
}
|
|
||||||
|
|
||||||
public boolean supports(Class clazz) {
|
return this.lookupAttributes(url);
|
||||||
if (FilterInvocation.class.isAssignableFrom(clazz)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,9 +57,26 @@ public abstract class AbstractFilterInvocationDefinitionSource
|
||||||
* interface with the <code>FilterInvocationDefinitionSource</code>.
|
* interface with the <code>FilterInvocationDefinitionSource</code>.
|
||||||
* </p>
|
* </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
|
* @return the <code>ConfigAttributeDefinition</code> that applies to the
|
||||||
* specified <code>FilterInvocation</code>
|
* specified <code>FilterInvocation</code>
|
||||||
*/
|
*/
|
||||||
protected abstract ConfigAttributeDefinition lookupAttributes(
|
public abstract ConfigAttributeDefinition lookupAttributes(String url);
|
||||||
FilterInvocation filterInvocation);
|
|
||||||
|
public boolean supports(Class clazz) {
|
||||||
|
if (FilterInvocation.class.isAssignableFrom(clazz)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,18 +99,15 @@ public class PathBasedFilterInvocationDefinitionMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConfigAttributeDefinition lookupAttributes(
|
public ConfigAttributeDefinition lookupAttributes(String url) {
|
||||||
FilterInvocation filterInvocation) {
|
|
||||||
Iterator iter = requestMap.iterator();
|
Iterator iter = requestMap.iterator();
|
||||||
|
|
||||||
String url = filterInvocation.getRequestUrl();
|
|
||||||
|
|
||||||
if (convertUrlToLowercaseBeforeComparison) {
|
if (convertUrlToLowercaseBeforeComparison) {
|
||||||
url = url.toLowerCase();
|
url = url.toLowerCase();
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Converted URL to lowercase, from: '"
|
logger.debug("Converted URL to lowercase, from: '" + url
|
||||||
+ filterInvocation.getRequest() + "'; to: '" + url + "'");
|
+ "'; to: '" + url + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,20 +117,17 @@ public class RegExpBasedFilterInvocationDefinitionMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConfigAttributeDefinition lookupAttributes(
|
public ConfigAttributeDefinition lookupAttributes(String url) {
|
||||||
FilterInvocation filterInvocation) {
|
|
||||||
PatternMatcher matcher = new Perl5Matcher();
|
PatternMatcher matcher = new Perl5Matcher();
|
||||||
|
|
||||||
Iterator iter = requestMap.iterator();
|
Iterator iter = requestMap.iterator();
|
||||||
|
|
||||||
String url = filterInvocation.getRequestUrl();
|
|
||||||
|
|
||||||
if (convertUrlToLowercaseBeforeComparison) {
|
if (convertUrlToLowercaseBeforeComparison) {
|
||||||
url = url.toLowerCase();
|
url = url.toLowerCase();
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Converted URL to lowercase, from: '"
|
logger.debug("Converted URL to lowercase, from: '" + url
|
||||||
+ filterInvocation.getRequest() + "'; to: '" + url + "'");
|
+ "'; to: '" + url + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,7 @@ public class MockFilterInvocationDefinitionSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConfigAttributeDefinition lookupAttributes(
|
public ConfigAttributeDefinition lookupAttributes(String url) {
|
||||||
FilterInvocation filterInvocation) {
|
|
||||||
throw new UnsupportedOperationException("mock method not implemented");
|
throw new UnsupportedOperationException("mock method not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,8 @@ public class PathBasedFilterDefinitionMapTests extends TestCase {
|
||||||
FilterInvocation fi = new FilterInvocation(req,
|
FilterInvocation fi = new FilterInvocation(req,
|
||||||
new MockHttpServletResponse(), new MockFilterChain());
|
new MockHttpServletResponse(), new MockFilterChain());
|
||||||
|
|
||||||
ConfigAttributeDefinition response = map.lookupAttributes(fi);
|
ConfigAttributeDefinition response = map.lookupAttributes(fi
|
||||||
|
.getRequestUrl());
|
||||||
assertEquals(def, response);
|
assertEquals(def, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +99,8 @@ public class PathBasedFilterDefinitionMapTests extends TestCase {
|
||||||
FilterInvocation fi = new FilterInvocation(req,
|
FilterInvocation fi = new FilterInvocation(req,
|
||||||
new MockHttpServletResponse(), new MockFilterChain());
|
new MockHttpServletResponse(), new MockFilterChain());
|
||||||
|
|
||||||
ConfigAttributeDefinition response = map.lookupAttributes(fi);
|
ConfigAttributeDefinition response = map.lookupAttributes(fi
|
||||||
|
.getRequestUrl());
|
||||||
assertEquals(null, response);
|
assertEquals(null, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +119,8 @@ public class PathBasedFilterDefinitionMapTests extends TestCase {
|
||||||
FilterInvocation fi = new FilterInvocation(req,
|
FilterInvocation fi = new FilterInvocation(req,
|
||||||
new MockHttpServletResponse(), new MockFilterChain());
|
new MockHttpServletResponse(), new MockFilterChain());
|
||||||
|
|
||||||
ConfigAttributeDefinition response = map.lookupAttributes(fi);
|
ConfigAttributeDefinition response = map.lookupAttributes(fi
|
||||||
|
.getRequestUrl());
|
||||||
assertEquals(def, response);
|
assertEquals(def, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,8 @@ public class RegExpBasedFilterDefinitionMapTests extends TestCase {
|
||||||
FilterInvocation fi = new FilterInvocation(req,
|
FilterInvocation fi = new FilterInvocation(req,
|
||||||
new MockHttpServletResponse(), new MockFilterChain());
|
new MockHttpServletResponse(), new MockFilterChain());
|
||||||
|
|
||||||
ConfigAttributeDefinition response = map.lookupAttributes(fi);
|
ConfigAttributeDefinition response = map.lookupAttributes(fi
|
||||||
|
.getRequestUrl());
|
||||||
assertEquals(def, response);
|
assertEquals(def, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +99,8 @@ public class RegExpBasedFilterDefinitionMapTests extends TestCase {
|
||||||
FilterInvocation fi = new FilterInvocation(req,
|
FilterInvocation fi = new FilterInvocation(req,
|
||||||
new MockHttpServletResponse(), new MockFilterChain());
|
new MockHttpServletResponse(), new MockFilterChain());
|
||||||
|
|
||||||
ConfigAttributeDefinition response = map.lookupAttributes(fi);
|
ConfigAttributeDefinition response = map.lookupAttributes(fi
|
||||||
|
.getRequestUrl());
|
||||||
assertEquals(null, response);
|
assertEquals(null, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +119,8 @@ public class RegExpBasedFilterDefinitionMapTests extends TestCase {
|
||||||
FilterInvocation fi = new FilterInvocation(req,
|
FilterInvocation fi = new FilterInvocation(req,
|
||||||
new MockHttpServletResponse(), new MockFilterChain());
|
new MockHttpServletResponse(), new MockFilterChain());
|
||||||
|
|
||||||
ConfigAttributeDefinition response = map.lookupAttributes(fi);
|
ConfigAttributeDefinition response = map.lookupAttributes(fi
|
||||||
|
.getRequestUrl());
|
||||||
assertEquals(def, response);
|
assertEquals(def, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
<action dev="benalex" type="add">Added AbstractProcessingFilter property to always use defaultTargetUrl</action>
|
<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">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 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">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">Improved performance of JBoss container adapter (see reference docs)</action>
|
||||||
<action dev="benalex" type="update">Made DaoAuthenticationProvider detect null in Authentication.principal</action>
|
<action dev="benalex" type="update">Made DaoAuthenticationProvider detect null in Authentication.principal</action>
|
||||||
|
|
Loading…
Reference in New Issue