List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:fr.putnami.pwt.plugin.ajaxbot.filter.DeleteCacheFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; if (HttpMethod.GET.toString().equals(request.getMethod()) && null != request.getParameter(QUERY_PARAM_RESET_FILTER)) { this.resetCache(); }/*from w w w.j av a 2 s. c om*/ chain.doFilter(req, resp); }
From source file:com.sun.socialsite.web.filters.CustomizedPageCachingFilter.java
@Override protected PageInfo buildPage(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws AlreadyGzippedException, Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); GenericResponseWrapper wrappedResponse = new GenericResponseWrapper(response, out); chain.doFilter(request, wrappedResponse); wrappedResponse.flush();/*from w ww . ja va2s . c o m*/ return new ExtendedPageInfo(wrappedResponse, out.toByteArray(), true); }
From source file:gov.nih.nci.cabig.ccts.security.UserFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; prepareUser(httpRequest);//from w w w . ja v a2 s . c o m loadLinks(httpRequest); chain.doFilter(httpRequest, httpResponse); }
From source file:com.du.order.dist.log.LoggingFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { long requestId = id.incrementAndGet(); request = new RequestWrapper(requestId, request); response = new ResponseWrapper(requestId, response); try {//from w w w .j a va 2 s . co m filterChain.doFilter(request, response); // response.flushBuffer(); } finally { logRequest(request); logResponse((ResponseWrapper) response); } }
From source file:com.mothsoft.alexis.web.security.StoreUsernameInSessionFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { final HttpSession session = request.getSession(false); if (session != null && SecurityContextHolder.getContext().getAuthentication() != null) { session.setAttribute(USERNAME, SecurityContextHolder.getContext().getAuthentication().getName()); }/* w ww .j a v a2s. c om*/ chain.doFilter(request, response); }
From source file:edu.sdsc.scigraph.services.jersey.dynamic.SwaggerFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { boolean gzip = isGzip(request); // Capture the output of the filter chain ByteArrayResponseWrapper wrappedResp = new ByteArrayResponseWrapper((HttpServletResponse) response); chain.doFilter(request, wrappedResp); if (gzip) {//ww w . j ava 2 s .c om try (InputStream is = new ByteArrayInputStream(wrappedResp.getBytes()); GZIPInputStream gis = new GZIPInputStream(is); ByteArrayOutputStream bs = new ByteArrayOutputStream(); GZIPOutputStream gzos = new GZIPOutputStream(bs)) { byte[] newApi = writeDynamicResource(gis); gzos.write(newApi); gzos.close(); byte[] output = bs.toByteArray(); response.setContentLength(output.length); response.getOutputStream().write(output); } } else { try (InputStream is = new ByteArrayInputStream(wrappedResp.getBytes()); ByteArrayOutputStream bs = new ByteArrayOutputStream()) { byte[] newApi = writeDynamicResource(is); response.setContentLength(newApi.length); response.getOutputStream().write(newApi); } } }
From source file:gateway.controller.util.CorsFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { response.setHeader("Access-Control-Allow-Headers", "authorization, content-type"); response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "*"); response.setHeader("Access-Control-Max-Age", "36000"); filterChain.doFilter(request, response); }
From source file:net.solarnetwork.node.setup.web.NodeAssociationFilter.java
private void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final String path = request.getPathInfo(); if (!path.startsWith(NODE_ASSOCIATE_PATH) && identityService.getNodeId() == null) { response.sendRedirect(request.getContextPath() + NODE_ASSOCIATE_PATH); } else {/*from w w w . j a v a 2 s.c om*/ chain.doFilter(request, response); } }
From source file:com.adobe.acs.commons.forms.impl.FormsPostRedirectGetFilterImpl.java
@Override public final void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { if (!(servletRequest instanceof SlingHttpServletRequest) || !(servletResponse instanceof SlingHttpServletResponse)) { filterChain.doFilter(servletRequest, servletResponse); return;/*from w w w . j a v a 2 s .co m*/ } final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) servletRequest; final SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) servletResponse; /** * Fail fast and early! * * Must be: * - HTTP GET Request * - Have Forms Sling Suffix * - At this point, 99% of includes will be passed over * - Must contain Form Selector Query Parameter * - Include is not a product of a previous forward by this Filter */ if (!StringUtils.equals("GET", slingRequest.getMethod()) || !formsRouter.hasValidSuffix(slingRequest)) { filterChain.doFilter(servletRequest, servletResponse); return; } /* Ensure there is a valid form selector as part of Query Params */ final String formSelector = formsRouter.getFormSelector(slingRequest); if (formSelector == null) { filterChain.doFilter(servletRequest, servletResponse); return; } /* Ensure this is not a product of a previous forward; This is to be absolutely sure we are not hitting an * infinite loop condition */ if (slingRequest.getAttribute(REQUEST_ATTR_PREVIOUSLY_PROCESSED) != null) { filterChain.doFilter(servletRequest, servletResponse); return; } final RequestDispatcherOptions options = new RequestDispatcherOptions(); options.setReplaceSelectors(formSelector); options.setReplaceSuffix(slingRequest.getRequestPathInfo().getSuffix()); if (log.isDebugEnabled()) { log.debug("POST-Redirect-GET Form Filter; Internal forward to resource: {} ", slingRequest.getResource()); log.debug("POST-Redirect-GET Form Filter; Internal forward to path: {} ", slingRequest.getResource().getPath()); log.debug("POST-Redirect-GET Filter; Internal forward w/ replace selectors: {} ", options.getReplaceSelectors()); log.debug("POST-Redirect-GET Filter; Internal forward w/ suffix: {} ", options.getReplaceSuffix()); } // Avoid accidental infinite loops with API consumers doing their own Fws and Includes slingRequest.setAttribute(REQUEST_ATTR_PREVIOUSLY_PROCESSED, Boolean.TRUE); slingRequest.getRequestDispatcher(slingRequest.getResource(), options).forward(slingRequest, slingResponse); }
From source file:com.mec.Security.JWTAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { //System.out.println("JWTAuthenticationFilter doFilter"); HttpServletRequest res = (HttpServletRequest) request; Authentication authentication = tokenService.getAuthentication(res); SecurityContextHolder.getContext().setAuthentication(authentication); filterChain.doFilter(request, response); }