org.securityfilter.filter
Class SecurityFilter

java.lang.Object
  extended byorg.securityfilter.filter.SecurityFilter
All Implemented Interfaces:
javax.servlet.Filter

public class SecurityFilter
extends Object
implements javax.servlet.Filter

SecurityFilter provides authentication and authorization services.

Version:
$Revision: 1.13 $ $Date: 2004/10/09 19:50:20 $
Author:
Max Cooper (max@maxcooper.com), Daya Sharma (iamdaya@yahoo.com, billydaya@sbcglobal.net), Torgeir Veimo (torgeir@pobox.com)

Field Summary
static String ALREADY_PROCESSED
           
protected  Authenticator authenticator
           
protected  javax.servlet.FilterConfig config
           
static String CONFIG_FILE_KEY
           
static String DEFAULT_CONFIG_FILE
           
protected  URLPatternFactory patternFactory
           
protected  List patternList
           
protected  SecurityRealmInterface realm
           
static String SAVED_FILTER
           
static String SAVED_REQUEST
           
static String SAVED_REQUEST_URL
           
static String TRUE
           
static String VALIDATE_KEY
           
 
Constructor Summary
SecurityFilter()
           
 
Method Summary
static void authenticate(javax.servlet.http.HttpServletRequest request, String userId, String password)
           
 void destroy()
          Destroy the filter, releasing resources.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          Perform filtering operation, and optionally pass the request down the chain.
static String getContinueToURL(javax.servlet.http.HttpServletRequest request)
          Get the URL to continue to after successful login.
static SecurityFilter getFilter()
           
 javax.servlet.FilterConfig getFilterConfig()
          Get the filter config object, included for WebLogic 6 compatibility.
 void init(javax.servlet.FilterConfig config)
          Initialize the SecurityFilter.
protected  URLPattern matchPattern(String pattern, String httpMethod, URLPatternMatcher matcher)
          Find a match for the requested pattern & method, if any.
static void saveRequestInformation(javax.servlet.http.HttpServletRequest request)
          Save request information to re-use when the user is successfully authenticated.
 void setFilterConfig(javax.servlet.FilterConfig config)
          Set the filter configuration, included for WebLogic 6 compatibility.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_FILE_KEY

public static final String CONFIG_FILE_KEY
See Also:
Constant Field Values

DEFAULT_CONFIG_FILE

public static final String DEFAULT_CONFIG_FILE
See Also:
Constant Field Values

VALIDATE_KEY

public static final String VALIDATE_KEY
See Also:
Constant Field Values

TRUE

public static final String TRUE
See Also:
Constant Field Values

ALREADY_PROCESSED

public static final String ALREADY_PROCESSED

SAVED_FILTER

public static final String SAVED_FILTER

SAVED_REQUEST_URL

public static final String SAVED_REQUEST_URL

SAVED_REQUEST

public static final String SAVED_REQUEST

config

protected javax.servlet.FilterConfig config

realm

protected SecurityRealmInterface realm

patternList

protected List patternList

patternFactory

protected URLPatternFactory patternFactory

authenticator

protected Authenticator authenticator
Constructor Detail

SecurityFilter

public SecurityFilter()
Method Detail

authenticate

public static void authenticate(javax.servlet.http.HttpServletRequest request,
                                String userId,
                                String password)

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws IOException,
                     javax.servlet.ServletException
Perform filtering operation, and optionally pass the request down the chain.

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
request - the current request
response - the current response
chain - request handler chain
Throws:
IOException
javax.servlet.ServletException

getFilter

public static SecurityFilter getFilter()

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Initialize the SecurityFilter.

Specified by:
init in interface javax.servlet.Filter
Parameters:
config - filter configuration object
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Destroy the filter, releasing resources.

Specified by:
destroy in interface javax.servlet.Filter

matchPattern

protected URLPattern matchPattern(String pattern,
                                  String httpMethod,
                                  URLPatternMatcher matcher)
                           throws Exception
Find a match for the requested pattern & method, if any.

Parameters:
pattern - the pattern to match
httpMethod - the HTTP Method to match
matcher - the thread-local URLPatternMatcher object
Returns:
the matching URLPattern object, or null if there is no match.
Throws:
Exception

getContinueToURL

public static String getContinueToURL(javax.servlet.http.HttpServletRequest request)
Get the URL to continue to after successful login. This may be the SAVED_REQUEST_URL if the authorization sequence was initiated by the filter, or the default URL (as specified in the config file) if a login request was spontaneously submitted.

Parameters:
request - the current request

saveRequestInformation

public static void saveRequestInformation(javax.servlet.http.HttpServletRequest request)
Save request information to re-use when the user is successfully authenticated.

Parameters:
request - the current request

setFilterConfig

public void setFilterConfig(javax.servlet.FilterConfig config)
                     throws javax.servlet.ServletException
Set the filter configuration, included for WebLogic 6 compatibility.

Parameters:
config - filter configuration object
Throws:
javax.servlet.ServletException

getFilterConfig

public javax.servlet.FilterConfig getFilterConfig()
Get the filter config object, included for WebLogic 6 compatibility.