After reading many posts on this forum and seeing the "anonymous" user approach, I gave it a whirl. I got it to work, but I had to write quite a bit of code to do something that should be simple. So I scrapped it and hacked Acegi a bit to allow excluded URLs. Below is a patch that allows you to exclude URLs in your context file with the following syntax:
Code:
<property name="objectDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
!/signup.html=Foo
!/passwordhint.html*=Foo
/*.html*=Administrators
</value>
</property>
I found that the "=Foo" is necessary, even though it's never used. Here's the patch/hack for the Ant pattern matching:
Code:
Index: core/src/main/java/net/sf/acegisecurity/intercept/web/PathBasedFilterInvocationDefinitionMap.java
===================================================================
RCS file:
/cvsroot/acegisecurity/acegisecurity/core/src/main/java/net/sf/acegisecurity/intercept/web/PathBasedFilterInvocationD
efinitionMap.java,v
retrieving revision 1.2
diff -u -r1.2 PathBasedFilterInvocationDefinitionMap.java
--- core/src/main/java/net/sf/acegisecurity/intercept/web/PathBasedFilterInvocationDefinitionMap.java 5 Dec 2004
05:04:52 -0000 1.2
+++ core/src/main/java/net/sf/acegisecurity/intercept/web/PathBasedFilterInvocationDefinitionMap.java 16 Dec 2004
00:46:51 -0000
@@ -113,6 +113,19 @@
while (iter.hasNext()) {
EntryHolder entryHolder = (EntryHolder) iter.next();
+
+ // If path starts with !, and it matches, return
+ if (entryHolder.getAntPath().startsWith("!")) {
+ String pathToCompare =
+ entryHolder.getAntPath().substring(1, entryHolder.getAntPath().length());
+ boolean matched = PathMatcher.match(pathToCompare, url);
+ if (matched) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Matched excluded URL, returning null");
+ }
+ return null;
+ }
+ }
boolean matched = PathMatcher.match(entryHolder.getAntPath(), url);