BrightSide Workbench Full Report + Source Code
org.turro.elephant.servlet.context.ElephantFilter Class Reference
Inheritance diagram for org.turro.elephant.servlet.context.ElephantFilter:
Collaboration diagram for org.turro.elephant.servlet.context.ElephantFilter:

Public Member Functions

void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
 
void init (FilterConfig filterConfig) throws ServletException
 
void destroy ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 49 of file ElephantFilter.java.

Member Function Documentation

◆ destroy()

void org.turro.elephant.servlet.context.ElephantFilter.destroy ( )

Definition at line 98 of file ElephantFilter.java.

98  {
99  }

◆ doFilter()

void org.turro.elephant.servlet.context.ElephantFilter.doFilter ( ServletRequest  request,
ServletResponse  response,
FilterChain  chain 
) throws IOException, ServletException

Definition at line 55 of file ElephantFilter.java.

57  {
58  if(request instanceof HttpServletRequest httpRequest) {
59  // Performance blocks
60  if(ipActivity.isBlocked(request.getRemoteAddr(), httpRequest.getServletPath(), httpRequest.getHeader("User-Agent"))) {
61  if(response instanceof HttpServletResponse httpResponse) {
62  Document crawlers = Document.from(ElephantContext.getRealPath(CrawlerOptions.CRAWLERS_RESPONSE));
63  httpResponse.setContentType("text/html");
64  httpResponse.setCharacterEncoding(ElephantContext.getEncoding());
65  httpResponse.setStatus(HttpServletResponse.SC_FORBIDDEN);
66  httpResponse.getWriter().write(crawlers.content());
67  }
68  return; // blocked
69  // Performance internal calls
70  } else if(!pass(httpRequest.getServletPath())) {
71  if(resource(httpRequest.getServletPath())) {
72  RequestDispatcher rd = getServletContext().getNamedDispatcher("default");
73  if(rd!= null) rd.forward(request, response);
74  return; // resource
75  }
76  if(!checkSchemas(httpRequest, (HttpServletResponse) response)) {
77  return; // redirected
78  }
79  ElephantContext.initServerSchemas(httpRequest);
80  if(!DirectContents.isDirectContent(httpRequest) && checkMobile(httpRequest)) {
81  forwardMobile(httpRequest, response);
82  return; // mobile context
83  }
84  ipActivity.check(request.getRemoteAddr(), httpRequest.getServletPath(), httpRequest.getHeader("User-Agent"));
85  }
86  }
87 
88  chain.doFilter(request, response);
89  }
Here is the call graph for this function:

◆ init()

void org.turro.elephant.servlet.context.ElephantFilter.init ( FilterConfig  filterConfig) throws ServletException

Definition at line 92 of file ElephantFilter.java.

92  {
93  this.filterConfig = filterConfig;
94  this.ipActivity = IPActivity.instance(Cached.<IActivityOptions>instance(() -> CrawlerOptions.instance()));
95  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: