net.spy.jwebkit.auth
Class BasicAuthFilter

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.BasicAuthFilter
All Implemented Interfaces:
javax.servlet.Filter

public class BasicAuthFilter
extends AuthFilter

Filter for providing basic authentication support.


Field Summary
 
Fields inherited from class net.spy.jwebkit.auth.AuthFilter
AUTH_REQ_HEADER, AUTH_RES_HEADER
 
Constructor Summary
BasicAuthFilter()
           
 
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.
 void doNoAuthChain(javax.servlet.http.HttpServletRequest hreq, javax.servlet.http.HttpServletResponse hres, javax.servlet.FilterChain chain)
          Invoked when the authentication credentials do not match, or the credentials are rejected.
protected  java.lang.String getAuthType()
          Get the authentication type used by this filter.
 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
 

Constructor Detail

BasicAuthFilter

public BasicAuthFilter()
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

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

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

doNoAuthChain

public void doNoAuthChain(javax.servlet.http.HttpServletRequest hreq,
                          javax.servlet.http.HttpServletResponse hres,
                          javax.servlet.FilterChain chain)
                   throws java.io.IOException,
                          javax.servlet.ServletException
Invoked when the authentication credentials do not match, or the credentials are rejected. The default implementation sets the status to SC_UNAUTHORIZED and sets the WWW-Authenticate header appropriately.

Parameters:
hreq - servlet request
hres - servlet response
chain - the current filter chain
Throws:
java.io.IOException
javax.servlet.ServletException

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.