org.efaps.ui.filter
Class AbstractAuthenticationFilter

java.lang.Object
  extended by org.efaps.ui.filter.AbstractFilter
      extended by org.efaps.ui.filter.AbstractAuthenticationFilter
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
BasicAuthenticationFilter, FormBasedAuthenticationFilter

public abstract class AbstractAuthenticationFilter
extends AbstractFilter

Version:
$Id: AbstractAuthenticationFilter.java 3781 2010-03-01 02:19:42Z jan.moxter $
Author:
The eFaps Team

Constructor Summary
AbstractAuthenticationFilter()
           
 
Method Summary
protected  boolean checkLogin(java.lang.String _name, java.lang.String _passwd)
          Checks if the user with given name and password is allowed to login.
 void destroy()
          Destroys the filter.
protected abstract  void doAuthenticate(javax.servlet.http.HttpServletRequest _request, javax.servlet.http.HttpServletResponse _response, javax.servlet.FilterChain _chain)
          Authentication method.
protected  void doFilter(javax.servlet.http.HttpServletRequest _request, javax.servlet.http.HttpServletResponse _response, javax.servlet.FilterChain _chain)
          If the current user is already logged in, nothing is filtered.
 void init(javax.servlet.FilterConfig _filterConfig)
          Called by the web container to indicate to a filter that it is being placed into service.
 
Methods inherited from class org.efaps.ui.filter.AbstractFilter
doFilter, getLoggedInUser, isLoggedIn, setLoggedInUser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAuthenticationFilter

public AbstractAuthenticationFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig _filterConfig)
          throws javax.servlet.ServletException
Called by the web container to indicate to a filter that it is being placed into service. The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work. The web container cannot place the filter into service if the init method either 1.Throws a ServletException 2.Does not return within a time period defined by the web container // sets the login handler

Specified by:
init in interface javax.servlet.Filter
Overrides:
init in class AbstractFilter
Parameters:
_filterConfig - filter configuration instance
Throws:
javax.servlet.ServletException - on error
See Also:
#INIT_PARAM_TITLE, #title, INIT_PARAM_APPLICATION, #loginhandler

destroy

public void destroy()
Destroys the filter. Is an empty method in this implementation which could be overwritten by derived classes.
The method is called by the web container to indicate to a filter that it is being taken out of service. This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed. After the web container calls this method, it will not call the doFilter method again on this instance of the filter.
This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory.

Specified by:
destroy in interface javax.servlet.Filter
Overrides:
destroy in class AbstractFilter

doFilter

protected void doFilter(javax.servlet.http.HttpServletRequest _request,
                        javax.servlet.http.HttpServletResponse _response,
                        javax.servlet.FilterChain _chain)
                 throws java.io.IOException,
                        javax.servlet.ServletException
If the current user is already logged in, nothing is filtered.

Specified by:
doFilter in class AbstractFilter
Parameters:
_request - HttpServletRequest
_response - HttpServletResponse
_chain - FilterChain
Throws:
java.io.IOException - on error
javax.servlet.ServletException - on error
See Also:
doAuthenticate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)

doAuthenticate

protected abstract void doAuthenticate(javax.servlet.http.HttpServletRequest _request,
                                       javax.servlet.http.HttpServletResponse _response,
                                       javax.servlet.FilterChain _chain)
                                throws java.io.IOException,
                                       javax.servlet.ServletException
Authentication method.

Parameters:
_request - HttpServletRequest
_response - HttpServletResponse
_chain - FilterChain
Throws:
java.io.IOException - on error
javax.servlet.ServletException - on error
See Also:
doAuthenticate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)

checkLogin

protected boolean checkLogin(java.lang.String _name,
                             java.lang.String _passwd)
Checks if the user with given name and password is allowed to login.

Parameters:
_name - user name to check
_passwd - password to check
Returns:
true if the user is allowed to login (name and password is correct), otherweise false
See Also:
#loginhandler, doFilter(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)


Copyright © 2003-2010 The eFaps Team. All Rights Reserved.