net.spy.jwebkit.auth
Class FormAuthFilter

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.jwebkit.JWFilter
          extended by net.spy.jwebkit.auth.AuthFilter
              extended by net.spy.jwebkit.auth.FormAuthFilter
All Implemented Interfaces:
javax.servlet.Filter

public class FormAuthFilter
extends AuthFilter

Handler for form-based authenticators.


Field Summary
static java.lang.String LOGIN_ACTION
          The name of the action that logs in the user.
static java.lang.String LOGIN_URI
          The name of the next URI to visit (if applicable).
static java.lang.String PASSWORD_PARAM
          The name of the form field containing the password.
static java.lang.String USERNAME_PARAM
          The name of the form field containing the username.
 
Fields inherited from class net.spy.jwebkit.auth.AuthFilter
AUTH_REQ_HEADER, AUTH_RES_HEADER
 
Constructor Summary
FormAuthFilter()
           
 
Method Summary
protected  java.security.Principal checkPassword(java.lang.String user, java.lang.String pass)
          Check the username and password of the current user.
protected  void doCheckedFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
          Run whatever authentication filters need to be attempted here.
protected  void doNoAuthChain(javax.servlet.http.HttpServletRequest hreq, javax.servlet.http.HttpServletResponse hres, javax.servlet.FilterChain chain, java.lang.String form, boolean recordLocation)
          Executed when the user is not authenticated.
protected  java.lang.String getAuthForm()
          Get the path to the auth form.
protected  java.lang.String getAuthType()
          Get the authentication type used by this filter.
protected  java.lang.String getFailedAuthForm()
          Get the path to the auth form.
protected  java.lang.String getLoginAction()
          Get the action path that will be authenticating this user.
protected  java.lang.String getLoginURI()
          Get the name of the request parameter that will tell us where to forward the user after authentication.
protected  java.lang.String getPasswordParam()
          Get the name of the parameter containing the password.
protected  java.lang.String getUsernameParam()
          Get the name of the parameter containing the username.
 void init(javax.servlet.FilterConfig c)
           
 
Methods inherited from class net.spy.jwebkit.auth.AuthFilter
doAuthedChain, doFilter, getAuthAdaptor, getRequestWithPrincipal, getRequestWithPrincipal
 
Methods inherited from class net.spy.jwebkit.JWFilter
destroy, getConfig
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USERNAME_PARAM

public static final java.lang.String USERNAME_PARAM
The name of the form field containing the username.

See Also:
Constant Field Values

PASSWORD_PARAM

public static final java.lang.String PASSWORD_PARAM
The name of the form field containing the password.

See Also:
Constant Field Values

LOGIN_ACTION

public static final java.lang.String LOGIN_ACTION
The name of the action that logs in the user.

See Also:
Constant Field Values

LOGIN_URI

public static final java.lang.String LOGIN_URI
The name of the next URI to visit (if applicable).

See Also:
Constant Field Values
Constructor Detail

FormAuthFilter

public FormAuthFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig c)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Overrides:
init in class AuthFilter
Throws:
javax.servlet.ServletException

getAuthForm

protected java.lang.String getAuthForm()
Get the path to the auth form.


getFailedAuthForm

protected java.lang.String getFailedAuthForm()
Get the path to the auth form.


doNoAuthChain

protected void doNoAuthChain(javax.servlet.http.HttpServletRequest hreq,
                             javax.servlet.http.HttpServletResponse hres,
                             javax.servlet.FilterChain chain,
                             java.lang.String form,
                             boolean recordLocation)
                      throws java.io.IOException,
                             javax.servlet.ServletException
Executed when the user is not authenticated.

recordLocation is true when the client is not authenticated and we are not attempting to authenticate the user. It is false when the client has failed to authenticate. This allows the filter to send the client back to the original page it was requesting after authentication completes.

Parameters:
hreq - the request
hres - the response
chain - the chain
recordLocation - if true, record the current location
Throws:
java.io.IOException
javax.servlet.ServletException

getUsernameParam

protected java.lang.String getUsernameParam()
Get the name of the parameter containing the username.


getPasswordParam

protected java.lang.String getPasswordParam()
Get the name of the parameter containing the password.


getLoginAction

protected java.lang.String getLoginAction()
Get the action path that will be authenticating this user.


getLoginURI

protected java.lang.String getLoginURI()
Get the name of the request parameter that will tell us where to forward the user after authentication.


getAuthType

protected java.lang.String getAuthType()
Description copied from class: AuthFilter
Get the authentication type used by this filter.

Specified by:
getAuthType in class AuthFilter
Returns:
one of the HttpServletRequest auth types.
See Also:
HttpServletRequest

doCheckedFilter

protected void doCheckedFilter(javax.servlet.ServletRequest req,
                               javax.servlet.ServletResponse res,
                               javax.servlet.FilterChain chain)
                        throws java.io.IOException,
                               javax.servlet.ServletException
Description copied from class: AuthFilter
Run whatever authentication filters need to be attempted here. This will only be evaluated when there is no exception list.

Specified by:
doCheckedFilter in class AuthFilter
Parameters:
req - the request
res - the response
chain - the chain
Throws:
java.io.IOException - if there are errors reading or writing
javax.servlet.ServletException - if there's a general error

checkPassword

protected java.security.Principal checkPassword(java.lang.String user,
                                                java.lang.String pass)
                                         throws javax.servlet.ServletException
Check the username and password of the current user.

Parameters:
user - the username
pass - the password
Returns:
a Principal if the authentication succeeds, else null
Throws:
javax.servlet.ServletException - if something goes horribly, horribly wrong


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.