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 Object
implements javax.servlet.Filter

Version:
$Id: AbstractFilter.java 5506 2010-09-08 18:47:57Z jan.moxter $
Author:
The eFaps Team

Field Summary
static String INITPARAM_APP_KEY
          Name of the InitParameter variable for the application key.
static String INITPARAM_LOGIN_ROLES
          Name of the InitParameter variable for the login roles.
 
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  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, 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
 

Field Detail

INITPARAM_LOGIN_ROLES

public static final String INITPARAM_LOGIN_ROLES
Name of the InitParameter variable for the login roles.

See Also:
Constant Field Values

INITPARAM_APP_KEY

public static final String INITPARAM_APP_KEY
Name of the InitParameter variable for the application key.

See Also:
Constant Field Values
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 - 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

doFilter

public void doFilter(javax.servlet.ServletRequest _request,
                     javax.servlet.ServletResponse _response,
                     javax.servlet.FilterChain _chain)
              throws 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
Parameters:
_request - ServletRequest
_response - ServletResponse
_chain - FilterChain
Throws:
javax.servlet.ServletException - if the request and response does not use the http(s) protokoll
IOException - on error
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 IOException,
                                 javax.servlet.ServletException
Parameters:
_request - ServletRequest
_response - ServletResponse
_chain - FilterChain
Throws:
IOException - on error
javax.servlet.ServletException - on error

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,
                               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 String getLoggedInUser(javax.servlet.http.HttpServletRequest _request)
Parameters:
_request - HttpServletRequest
Returns:
nmae of the logged in user


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