List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:jp.aegif.nemaki.rest.AuthenticationFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest hreq = (HttpServletRequest) req; HttpServletResponse hres = (HttpServletResponse) res; boolean auth = login(hreq, hres); if (auth) {/*from w ww. ja v a2 s. c o m*/ chain.doFilter(req, res); } else { log.error("REST API Unauthorized!"); hres.sendError(HttpServletResponse.SC_UNAUTHORIZED); } }
From source file:edu.wisc.web.filter.ShallowEtagHeaderFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { ShallowEtagResponseWrapper responseWrapper = new ShallowEtagResponseWrapper(response); filterChain.doFilter(request, responseWrapper); byte[] body = responseWrapper.toByteArray(); int statusCode = responseWrapper.getStatusCode(); if (isEligibleForEtag(request, responseWrapper, statusCode, body)) { String responseETag = generateETagHeaderValue(body); response.setHeader(HEADER_ETAG, responseETag); String requestETag = request.getHeader(HEADER_IF_NONE_MATCH); if (responseETag.equals(requestETag)) { if (logger.isTraceEnabled()) { logger.trace("ETag [" + responseETag + "] equal to If-None-Match, sending 304"); }/*from w w w.j av a 2 s . c om*/ response.setContentLength(0); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); } else { if (logger.isTraceEnabled()) { logger.trace("ETag [" + responseETag + "] not equal to If-None-Match [" + requestETag + "], sending normal response"); } copyBodyToResponse(body, response); } } else { if (logger.isTraceEnabled()) { logger.trace("Response with status code [" + statusCode + "] not eligible for ETag"); } copyBodyToResponse(body, response); } }
From source file:br.on.daed.services.filters.AllowCrossDomainAjax.java
@Override public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { String path = request.getServletPath(); if (path.matches("^/astro/.*$")) { response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); }/* w w w . j a va 2s . c om*/ chain.doFilter(request, response); }
From source file:nu.yona.server.rest.ErrorLoggingFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; try (LoggingContext loggingContext = LoggingContext.createInstance(request)) { chain.doFilter(request, response); Series responseStatus = HttpStatus.Series.valueOf(response.getStatus()); if (responseStatus == Series.SUCCESSFUL) { return; }/*w ww. j av a 2 s. c om*/ logResponseStatus(request, response, responseStatus); } }
From source file:info.magnolia.cms.filters.VirtualUriFilter.java
@Override public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final AggregationState aggregationState = MgnlContext.getAggregationState(); String targetUri = getURIMapping(aggregationState.getCurrentURI(), aggregationState.getQueryString()); if (StringUtils.isEmpty(targetUri)) { chain.doFilter(request, response); return;/* w w w. j a v a 2 s. c om*/ } if (response.isCommitted()) { log.warn("Response is already committed, cannot apply virtual URI {} (original URI was {})", targetUri, request.getRequestURI()); chain.doFilter(request, response); return; } if (RequestDispatchUtil.dispatch(targetUri, request, response)) { return; } aggregationState.setCurrentURI(targetUri); chain.doFilter(request, response); }
From source file:org.craftercms.security.servlet.filters.RequestSecurityFilter.java
/** * Returns the last processor of the chain, which should actually call the {@link FilterChain}. *//*from www. j av a 2s .c o m*/ protected RequestSecurityProcessor getLastProcessorInChain(final FilterChain chain) { return new RequestSecurityProcessor() { public void processRequest(RequestContext context, RequestSecurityProcessorChain processorChain) throws Exception { chain.doFilter(context.getRequest(), context.getResponse()); } }; }
From source file:com.google.gerrit.httpd.ProjectBasicAuthFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; Response rsp = new Response((HttpServletResponse) response); if (verify(req, rsp)) { chain.doFilter(req, rsp); }//from www . jav a2 s .co m }
From source file:de.qucosa.spring.RoleParameterAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String role = request.getParameter("role"); if (role != null) { SecurityContext sctx = SecurityContextHolder.getContext(); if (sctx.getAuthentication() == null) { sctx.setAuthentication(new UsernamePasswordAuthenticationToken(role, role)); }/*from ww w . j a va 2 s . co m*/ } chain.doFilter(request, response); }
From source file:org.cloudfoundry.practical.demo.core.webdav.WebDavFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if ((request instanceof HttpServletRequest) && ((HttpServletRequest) request).getPathInfo().startsWith(MAPPING_PATH)) { handleWebDav((HttpServletRequest) request, (HttpServletResponse) response); } else {/*from ww w . ja va 2 s . com*/ chain.doFilter(request, response); } }
From source file:org.jasig.cas.web.LicenceFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { if (this.expiretime == 0l) { response.getOutputStream().println("License failed to load"); } else if (this.expiretime <= new Date().getTime()) { response.getOutputStream().println("License has expired"); return;// w ww. j a v a2 s . c o m } chain.doFilter(request, response); }