1 package net.jforum.util.legacy.clickstream; 2 3 import java.io.IOException ; 4 5 import javax.servlet.Filter ; 6 import javax.servlet.FilterChain ; 7 import javax.servlet.FilterConfig ; 8 import javax.servlet.ServletException ; 9 import javax.servlet.ServletRequest ; 10 import javax.servlet.ServletResponse ; 11 import javax.servlet.http.HttpServletRequest ; 12 13 import net.jforum.util.preferences.ConfigKeys; 14 15 import org.apache.log4j.Logger; 16 17 24 public class ClickstreamFilter implements Filter 25 { 26 private static final Logger log = Logger.getLogger(ClickstreamFilter.class); 27 28 31 private final static String FILTER_APPLIED = "_clickstream_filter_applied"; 32 33 42 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException , 43 ServletException 44 { 45 if (request.getAttribute(FILTER_APPLIED) == null) { 47 request.setAttribute(FILTER_APPLIED, Boolean.TRUE); 48 49 String bot = BotChecker.isBot((HttpServletRequest )request); 50 51 if (bot != null && log.isInfoEnabled()) { 52 log.info("Found a bot: " + bot); 53 } 54 55 request.setAttribute(ConfigKeys.IS_BOT, new Boolean (bot != null)); 56 } 57 58 chain.doFilter(request, response); 60 } 61 62 68 public void init(FilterConfig filterConfig) throws ServletException {} 69 70 73 public void destroy() {} 74 } | Popular Tags |