List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:nl.ctrlaltdev.harbinger.filter.HttpEvidenceFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { Evidence evidence = new Evidence(request); if (isValid(request, evidence)) { try {// w ww.j a v a 2s.c om chain.doFilter(request, response); } catch (IOException | ServletException | RuntimeException ex) { evidence = new Evidence(evidence, ex); throw ex; } finally { Evidence ev = ctx.getEvidenceCollector().store(new Evidence(evidence, response)); ctx.getResponseDecider().decide(ev).perform(ctx); } } else { response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); } }
From source file:edu.cornell.mannlib.vitro.webapp.filters.StartupStatusDisplayFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { if (ss.allClear() || (!isFatal() && statusAlreadyDisplayed)) { chain.doFilter(req, resp); return;//ww w .j av a 2 s. c o m } displayStartupStatus(req, resp); statusAlreadyDisplayed = true; }
From source file:de.zib.gndms.gndms.security.LocalRequestSkippingChannelProcessingFilter.java
@Override public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) throws IOException, ServletException { final String remoteAddr = req.getRemoteAddr(); logger.info("request from: " + remoteAddr); if (remoteAddr.equals(req.getLocalAddr())) chain.doFilter(req, res); else//w ww .ja v a 2 s.c o m super.doFilter(req, res, chain); // overriden method implementation }
From source file:it.scoppelletti.programmerpower.web.spring.FilterBean.java
/** * Filtro di una richiesta./* w w w. j a va 2 s. co m*/ * * @param req Richiesta. * @param resp Risposta. * @param chain Catena dei filtri. */ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { if (myFilter == null) { chain.doFilter(req, resp); return; } synchronized (myFilter) { if (!myInitialized) { myFilter.init(new FilterConfigImpl(myName, myServletCtx, myProps)); myInitialized = true; } myFilter.doFilter(req, resp, chain); } }
From source file:com.thoughtworks.go.server.newsecurity.filters.ArtifactSizeEnforcementFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { String headerValue = request.getHeader(HttpService.GO_ARTIFACT_PAYLOAD_SIZE); if (isBlank(headerValue)) { filterChain.doFilter(request, response); return;//ww w . j av a 2 s. com } if (lastOperationTime.pastWaitingPeriod()) { synchronized (this) { if (lastOperationTime.pastWaitingPeriod()) { totalAvailableSpace = artifactsDirHolder.getArtifactsDir().getUsableSpace() - systemEnvironment.getArtifactReposiotryFullLimit() * GoConstants.MEGA_BYTE; lastOperationTime.refresh(); } } } if (Long.valueOf(headerValue) * 2 > totalAvailableSpace) { Long artifactSize = Long.valueOf(headerValue); LOG.error( "[Artifact Upload] Artifact upload (Required Size {} * 2 = {}) was denied by the server because it has run out of disk space (Available Space {}).", artifactSize, artifactSize * 2, totalAvailableSpace); response.setStatus(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE); } else { filterChain.doFilter(request, response); } }
From source file:SecurityWrappingFilter.java
/** {@inheritDoc} */ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest wrappedRequest = new SecurityWrapperHttpServletRequest( (HttpServletRequest) servletRequest); filterChain.doFilter(wrappedRequest, servletResponse); }
From source file:cn.com.esrichina.gcloud.commons.LicenseFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String url = request.getRequestURI(); Boolean result = matchExcludePatterns(url); if (result) { filterChain.doFilter(request, response); return;/* w w w . j av a2 s .co m*/ } if (licenceContext.getIsAuthorized()) { doFilter(request, response, filterChain); } else { response.setContentType("text/json;charset=UTF-8"); // TODO ajax Json???HTTP? PrintWriter writer = response.getWriter(); RestResponse res = new RestResponse(false, licenceContext.getReason()); ObjectMapper mapper = new ObjectMapper(); String json = ""; try { json = mapper.writeValueAsString(res); } catch (JsonProcessingException e) { e.printStackTrace(); } writer.print(json); writer.close(); } }
From source file:be.fedict.eid.applet.service.HSTSFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { TransportService transportService = this.transportServiceLocator.locateService(); if (null == transportService) { chain.doFilter(request, response); return;//from w w w .j av a2s. com } StrictTransportSecurityConfig hstsConfig = transportService.getStrictTransportSecurityConfig(); if (null == hstsConfig) { chain.doFilter(request, response); return; } LOG.debug("adding HSTS header"); HttpServletResponse httpServletResponse = (HttpServletResponse) response; String headerValue = "max-age=" + hstsConfig.getMaxAge(); if (hstsConfig.isIncludeSubdomains()) { headerValue += "; includeSubdomains"; } httpServletResponse.addHeader("Strict-Transport-Security", headerValue); chain.doFilter(request, response); }
From source file:eu.trentorise.smartcampus.permissionprovider.oauth.ClientCredentialsFilter.java
@Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { super.successfulAuthentication(request, response, chain, authResult); chain.doFilter(request, response); }
From source file:org.fishwife.jrugged.spring.PerformanceMonitorFilter.java
public void doFilter(final ServletRequest req, final ServletResponse resp, final FilterChain chain) throws IOException, ServletException { try {/*from w w w. j a v a2 s. co m*/ invoke(new Runnable() { public void run() { try { chain.doFilter(req, resp); } catch (IOException e) { throw new WrappedException(e); } catch (ServletException e) { throw new WrappedException(e); } } }); } catch (WrappedException e) { Throwable wrapped = e.getCause(); if (wrapped instanceof IOException) { throw (IOException) wrapped; } else if (wrapped instanceof ServletException) { throw (ServletException) wrapped; } else { throw new IllegalStateException("unknown wrapped exception", wrapped); } } catch (Exception e) { throw new IllegalStateException("unknown checked exception", e); } }