Regex use
Robert Ellis Parrott <[email protected]> Tue, 31 Dec 2002 17:38:11 -0500 (EST)
| Newsgroups | gmane.comp.java.securityfilter.user |
|---|---|
| Message-ID | <[email protected]> |
I looked into SecurityFilter originally because I needed to protect
almost all resources within a webapp except for a few that represent a
front door view, and login page components, and I thought that regex
functionality could do this for me. I had hoped that I could specify a
regex in the config file, since they are so powerful.
However, the way that SecurityFilter works is that it assumes a
significantly simpler URL Pattern in the config file, so that my regex
expressions are mauled up.
What I had wanted to do was match almost every URL expect those under a
/public directory, and one index.jsp page, so that instead of manually
securing a resource, the default is that it's secure and you have to
manually unsecure it.
I propose that true and untampered regex functionality be included in the
matching code; this is a small modification, but allows for much more
powerful matching ability. I've made a modification to URLPattern to
accomplish this; basically, prefixing a URLPattern value by "RE:" tells
URLPattern to interpret it as a true regular expression, and compiler it
as is. I don't think that the string "RE:" will clash with any URL
pattern.
And as for the suggestions that regex capability be removed, I agree that
it might be removed for some pattern types, but should still be available,
at least for this functionality.
rob
patch: ---------------------------------------------------------------------
Index: URLPattern.java
===================================================================
RCS file:
/cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/filter/URLPattern.java,v
retrieving revision 1.1
diff -r1.1 URLPattern.java
85a86,90
> /**
> * Pattern type for patterns that are regular expressions themselves;
> * they are preceeded by "RE:".
> */
> public static final int RE_TYPE = 4;
189c194,197
< if (pattern.startsWith("*.")) {
---
>
> if (pattern.startsWith("RE:") ) {
> patternType = URLPattern.RE_TYPE;
> } else if (pattern.startsWith("*.")) {
251a260,263
>
> // however, if RE_TYPE, assume that input was valid RE, and just remove "RE:" prefix
> if (patternType == RE_TYPE) { convertedPattern = pattern.substring(3);}
>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf