org.ibisph.filter
Class AbstractPathPatternFilter

java.lang.Object
  extended by org.ibisph.filter.AbstractPathPatternFilter
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
Filter, Filter, Filter, SVGToJPEGFilter

public abstract class AbstractPathPatternFilter
extends java.lang.Object
implements javax.servlet.Filter

Base Filter that allows additional path pattern matching. This additional filter was needed since the pattern matching provided by the servlet 2.3 spec doesn't allow for servlet and extension matching together - you can do one or the other but not both. E.g., mapping can't be both directory and file extension based like (/dir/*.ext) has to be either a directory path -OR- a filename but not mixed e.g. "*.ext" is legal and so is "/dir/*" but NOT "/dir/*.ext". That's why the filter mapping and the filter's init params values are needed - to implement this type of behavior.

PARAMETER NAMEINIT-PARAM DESCRIPTION
PathPattern.MatchList List of path patterns to search the URI/Path Info for. If no values then the match call will always return true - matches - use.
PathPattern.MatchListSeperator The list separator character (typically ",", " ", [tab]. The default is ","
PathPattern.MatchType Optional parameter that controls how to search for the "SearchText". A value of "P" indicates that the text is a "P"refix and only checks if the string starts with the specified value. Otherwise the string is simply checked for any part (index of != -1). Default is the "P"refix value "p".
PathPattern.PathType Optional parameter that controls the type of the path to use for the pattern matching. A value of "URI" causes the request's URI to be used (which includes the application context and servlet path). A value of "PathInfo" (the default) will use the request's Path Info as the value to be checked.

Future: can simply do a struct that has the pattern, and if * /something/ * then do as a contains else if /something/ * then treat as a prefix. Loop would then match accordingly. The pattern type would then not be needed. A better solution is to piggy-back/use the more robust, more Spring consistent ACEGI Security filter mechanism (rumored to become part of the Spring MVC framework at some point).

Author:
Garth Braithwaite, STG

Nested Class Summary
protected  class AbstractPathPatternFilter.PathPattern
          Inner class that allows for several patterns to be used for the filter.
 
Field Summary
static java.lang.String LIST_SEPERATOR_PARAM_NAME
           
static java.lang.String MATCH_LIST_PARAM_NAME
           
static java.lang.String MATCH_TYPE_PARAM_NAME
           
protected  AbstractPathPatternFilter.PathPattern pathPattern
           
static java.lang.String REQUEST_PATH_TYPE_PARAM_NAME
           
 
Constructor Summary
AbstractPathPatternFilter()
           
 
Method Summary
 void destroy()
          Default, required method for all filter type objects.
protected  java.lang.String getInitParameterValue(javax.servlet.FilterConfig filterConfig, java.lang.String initParameterName, java.lang.String defaultValue)
          Helper method that gets an init parameter value from the servlet context.
 void init(javax.servlet.FilterConfig filterConfig)
          Sets the filter's control properties via the init-parameters (located in the application's deployment web.xml file)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.Filter
doFilter
 

Field Detail

MATCH_LIST_PARAM_NAME

public static java.lang.String MATCH_LIST_PARAM_NAME

LIST_SEPERATOR_PARAM_NAME

public static java.lang.String LIST_SEPERATOR_PARAM_NAME

MATCH_TYPE_PARAM_NAME

public static java.lang.String MATCH_TYPE_PARAM_NAME

REQUEST_PATH_TYPE_PARAM_NAME

public static java.lang.String REQUEST_PATH_TYPE_PARAM_NAME

pathPattern

protected AbstractPathPatternFilter.PathPattern pathPattern
Constructor Detail

AbstractPathPatternFilter

public AbstractPathPatternFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
Sets the filter's control properties via the init-parameters (located in the application's deployment web.xml file)

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - Standard FilterConfig object passed to this filter from the container. The main info passed are the filtering pattern on which this class is based. The FilterConfig allows access to the filter/init-param elements (properties).

getInitParameterValue

protected java.lang.String getInitParameterValue(javax.servlet.FilterConfig filterConfig,
                                                 java.lang.String initParameterName,
                                                 java.lang.String defaultValue)
Helper method that gets an init parameter value from the servlet context. If the parameter is NOT found (null) then the supplied default value is returned.

Parameters:
filterConfig - Standard FilterConfig object passed to this filter from the container.
initParameterName - Name of the init parameter to get.
defaultValue - Value to be returned if the init parameter is null.
Returns:
defaultValue if the init parameter name is not found or is not set, otherwise returns the init parameter's value.

destroy

public void destroy()
Default, required method for all filter type objects.

Specified by:
destroy in interface javax.servlet.Filter