List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:org.ameba.http.RequestIDFilter.java
/** * {@inheritDoc}/*from w w w . j ava 2 s . c o m*/ */ @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (request.getHeader(Constants.HEADER_VALUE_X_REQUESTID) == null) { RequestIDHolder.setRequestID(generator.generate()); } else { RequestIDHolder.setRequestID(request.getHeader(Constants.HEADER_VALUE_X_REQUESTID)); } try { filterChain.doFilter(request, response); } finally { RequestIDHolder.destroy(); } }
From source file:edu.cornell.mannlib.vitro.webapp.filters.CachingResponseFilter.java
private void produceBasicResponse(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException { chain.doFilter(req, resp); }
From source file:org.cloudfoundry.tools.timeout.TimeoutProtectionFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Assert.state(this.strategy != null, "Please set the TimeoutProtectionStrategy"); TimeoutProtectionHttpRequest timeoutProtectionRequest = TimeoutProtectionHttpRequest.get(request); if (timeoutProtectionRequest == null) { chain.doFilter(request, response); return;//from ww w. j av a 2 s .co m } if (timeoutProtectionRequest.getType() == TimeoutProtectionHttpRequest.Type.POLL) { this.strategy.handlePoll(timeoutProtectionRequest, (HttpServletResponse) response); return; } doFilter(timeoutProtectionRequest, (HttpServletResponse) response, chain); }
From source file:com.ms.app.web.commons.pagecache.PageCacheManager.java
public void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, ServletException { // ??//w ww .j a v a 2s . c o m if (!enable) { // ??filter chain.doFilter(request, response); return; } // ?? PageCache pageCache = getPageCache(request); if (pageCache == null) { // ??filter chain.doFilter(request, response); return; } PageInfo pageInfo = buildPageInfo(pageCache, request, response, chain); writeResponse(request, response, pageInfo); }
From source file:io.konverge.library.servlet.KonvergeServletFilter.java
/** * @param request/*from ww w . ja v a 2 s . com*/ * @param response * @param chain * @throws IOException * @throws ServletException */ public void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, ServletException { s_request.set(request); s_response.set(response); try { chain.doFilter(request, response); } catch (final Exception e) { Konverge.uncaught(e); } finally { s_request.remove(); s_response.remove(); } }
From source file:org.cloudfoundry.tools.timeout.TimeoutProtectionFilter.java
private void doFilter(TimeoutProtectionHttpRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponseMonitorFactory monitor = this.strategy.handleRequest(request); try {/* w w w. ja v a 2 s . co m*/ MonitoredHttpServletResponseWrapper monitoredHttpResponse = new MonitoredHttpServletResponseWrapper( response, monitor); chain.doFilter(request.getServletRequest(), monitoredHttpResponse); } finally { this.strategy.afterRequest(request, monitor); } }
From source file:com.thoughtworks.go.server.security.BasicAuthenticationFilter.java
@Override public void doFilterHttp(HttpServletRequest httpRequest, HttpServletResponse httpResponse, FilterChain chain) throws IOException, ServletException { // if bitbucket webhook, don't basic auth, the rails controller will handle this. if (StringUtils.defaultIfBlank(httpRequest.getHeader("User-Agent"), "").startsWith("Bitbucket-Webhooks/")) { chain.doFilter(httpRequest, httpResponse); return;//from ww w . j a va2 s . com } try { isProcessingBasicAuth.set(true); super.doFilterHttp(httpRequest, httpResponse, chain); } catch (Exception e) { LOG.error(e.toString()); // NPE and others do not have messages, their types are important too LOG.debug(e.getMessage(), e); handleException(httpRequest, httpResponse, e); } finally { isProcessingBasicAuth.set(false); } }
From source file:com.anite.meercat.PersistenceTidyUpFilter.java
/** * Run all the normal stuf, assoicate hibernate session to thread then on * finally close the request./*from ww w.j av a2 s.c o m*/ * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, * javax.servlet.ServletResponse, javax.servlet.FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (log.isInfoEnabled()) { log.info("doFilter"); } if (request instanceof HttpServletRequest) { HttpServletRequest httpRequest = (HttpServletRequest) request; try { filterChain.doFilter(request, response); } catch (Exception e) { log.error("FilterChain generated an error", e); } // close hibernate session, just in case there is one! PersistenceLocator.getInstance().closeRequest(); } else { log.info("Unusual request"); filterChain.doFilter(request, response); } }
From source file:com.ge.predix.web.cors.CORSFilter.java
@Override protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { if (!isCrossOriginRequest(request)) { filterChain.doFilter(request, response); return;//from w w w. ja va 2 s . c om } if (isXhrRequest(request)) { String method = request.getMethod(); if (!isCorsXhrAllowedMethod(method)) { response.setStatus(HttpStatus.METHOD_NOT_ALLOWED.value()); return; } String origin = request.getHeader(HttpHeaders.ORIGIN); // Validate the origin so we don't reflect back any potentially dangerous content. URI originURI; try { originURI = new URI(origin); } catch (URISyntaxException e) { response.setStatus(HttpStatus.FORBIDDEN.value()); return; } String requestUri = request.getRequestURI(); if (!isCorsXhrAllowedRequestUri(requestUri) || !isCorsXhrAllowedOrigin(origin)) { response.setStatus(HttpStatus.FORBIDDEN.value()); return; } response.addHeader("Access-Control-Allow-Origin", originURI.toString()); if ("OPTIONS".equals(request.getMethod())) { buildCorsXhrPreFlightResponse(request, response); } else { filterChain.doFilter(request, response); } return; } response.addHeader("Access-Control-Allow-Origin", "*"); if (request.getHeader("Access-Control-Request-Method") != null && "OPTIONS".equals(request.getMethod())) { // CORS "pre-flight" request response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); response.addHeader("Access-Control-Allow-Headers", "Authorization"); response.addHeader("Access-Control-Max-Age", "1728000"); } else { filterChain.doFilter(request, response); } }
From source file:com.ctc.storefront.filters.CustomerLocationRestorationFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { if (getCustomerLocationFacade().getUserLocationData() == null) { final Cookie[] cookies = request.getCookies(); if (cookies != null) { setUserLocationDataFromCookies(cookies); }//from w w w. j a v a 2 s. com } filterChain.doFilter(request, response); }