com.eaio.j2ee.filter
Class HotlinkingFilter

java.lang.Object
  |
  +--com.eaio.j2ee.filter.HotlinkingFilter
All Implemented Interfaces:
Filter

public class HotlinkingFilter
extends Object
implements Filter

The HotlinkingFilter checks the referer header (if present) for matches of a number of "good" referer strings. If no matches are found, the request is redirected to another URL. If the referer header is not present, the request is always accepted.

The init parameters are:

Don't forget to add your local IP address to the list of "good" referers when testing locally.

Author:
Johann Burkard

Field Summary
static String PARAMETER_REDIRECT
          The "redirect" parameter name.
static String PARAMETER_REFERER
          The "referer" parameter name.
 
Constructor Summary
HotlinkingFilter()
          Constructor for HotlinkingFilter.
 
Method Summary
 void destroy()
           
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
           
 FilterConfig getFilterConfig()
           
 void init(FilterConfig config)
           
 void setFilterConfig(FilterConfig config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_REFERER

public static final String PARAMETER_REFERER
The "referer" parameter name.

See Also:
Constant Field Values

PARAMETER_REDIRECT

public static final String PARAMETER_REDIRECT
The "redirect" parameter name.

See Also:
Constant Field Values
Constructor Detail

HotlinkingFilter

public HotlinkingFilter()
Constructor for HotlinkingFilter.

Method Detail

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
              throws IOException,
                     ServletException
Specified by:
doFilter in interface Filter
IOException
ServletException
See Also:
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)

getFilterConfig

public FilterConfig getFilterConfig()
See Also:
javax.servlet.Filter#getFilterConfig()

setFilterConfig

public void setFilterConfig(FilterConfig config)
See Also:
javax.servlet.Filter#setFilterConfig(javax.servlet.FilterConfig)

init

public void init(FilterConfig config)
          throws ServletException
Specified by:
init in interface Filter
ServletException
See Also:
Filter.init(javax.servlet.FilterConfig)

destroy

public void destroy()
Specified by:
destroy in interface Filter
See Also:
Filter.destroy()