org.efaps.ui.filter
Class AbstractFilter

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

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

Version:
$Id: AbstractFilter.java 3447 2009-11-29 22:46:39Z tim.moxter $
Author:
tmo

Constructor Summary
AbstractFilter()
           
 
Method Summary
 void destroy()
          Destroys the filter.
protected abstract  void doFilter(javax.servlet.http.HttpServletRequest _request, javax.servlet.http.HttpServletResponse _response, javax.servlet.FilterChain _chain)
           
 void doFilter(javax.servlet.ServletRequest _request, javax.servlet.ServletResponse _response, javax.servlet.FilterChain _chain)
          First the filtes tests, if the http(s) protokoll is used.
protected  java.lang.String getLoggedInUser(javax.servlet.http.HttpServletRequest _request)
           
 void init(javax.servlet.FilterConfig _filterConfig)
          Called by the web container to indicate to a filter that it is being placed into service.
protected  boolean isLoggedIn(javax.servlet.http.HttpServletRequest _request)
          Check, if the session variable sessionParameterLoginName is set.
protected  void setLoggedInUser(javax.servlet.http.HttpServletRequest _request, java.lang.String _userName)
          Stores the logged in user name in a session attribute of the http servlet request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFilter

public AbstractFilter()
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
Parameters:
_filterConfig - filter configuration instance
Throws:
javax.servlet.ServletException
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

doFilter

public void doFilter(javax.servlet.ServletRequest _request,
                     javax.servlet.ServletResponse _response,
                     javax.servlet.FilterChain _chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
First the filtes tests, if the http(s) protokoll is used. If the request is not implementing the HttpServletRequest and the response is not implementing the HttpServletResponse interface, a ServletException is thrown.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException - if the request and response does not use the http(s) protokoll
java.io.IOException
See Also:
HttpServletRequest, HttpServletResponse, #checkLogin

doFilter

protected abstract void doFilter(javax.servlet.http.HttpServletRequest _request,
                                 javax.servlet.http.HttpServletResponse _response,
                                 javax.servlet.FilterChain _chain)
                          throws java.io.IOException,
                                 javax.servlet.ServletException
Throws:
java.io.IOException
javax.servlet.ServletException

isLoggedIn

protected boolean isLoggedIn(javax.servlet.http.HttpServletRequest _request)
Check, if the session variable sessionParameterLoginName is set. If not, user is not logged in. Normally then a redirect to login page is made with method #doRedirect2Login.

Parameters:
_request - http servlet request variable
Returns:
true if user logged in, otherwise false

setLoggedInUser

protected void setLoggedInUser(javax.servlet.http.HttpServletRequest _request,
                               java.lang.String _userName)
Stores the logged in user name in a session attribute of the http servlet request. If the new user name is null, the session attribute is removed.

Parameters:
_request - http servlet request
_userName - name of logged in user to set (or null if not defined)

getLoggedInUser

protected java.lang.String getLoggedInUser(javax.servlet.http.HttpServletRequest _request)


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