List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:shiver.me.timbers.security.spring.StatelessAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { try {//from w ww .ja v a 2s . co m contextHolder.getContext().setAuthentication(httpServletBinder.retrieve((HttpServletRequest) request)); } catch (Throwable e) { exceptionMapper.throwMapped(e); } filterChain.doFilter(request, response); }
From source file:com.adobe.acs.commons.http.injectors.AbstractHtmlRequestInjector.java
@Override public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { if (!this.accepts(servletRequest, servletResponse)) { filterChain.doFilter(servletRequest, servletResponse); return;/*from ww w. j ava 2s . co m*/ } // We know these are HTTP Servlet Requests since accepts passed final HttpServletRequest request = (HttpServletRequest) servletRequest; final HttpServletResponse response = (HttpServletResponse) servletResponse; // Prepare to capture the original response final BufferingResponse originalResponse = new BufferingResponse(response); // Process and capture the original response filterChain.doFilter(request, originalResponse); // Get contents final String originalContents = originalResponse.getContents(); if (originalContents != null && StringUtils.contains(response.getContentType(), "html")) { final int injectionIndex = getInjectIndex(originalContents); if (injectionIndex != -1) { final PrintWriter printWriter = response.getWriter(); // Write all content up to the injection index printWriter.write(originalContents.substring(0, injectionIndex)); // Inject the contents; Pass the request/response - consumer can use as needed inject(request, response, printWriter); // Write all content after the injection index printWriter.write(originalContents.substring(injectionIndex)); return; } } if (originalContents != null) { response.getWriter().write(originalContents); } }
From source file:com.envision.envservice.filter.LoginFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; if (loginCheck(request, response)) { chain.doFilter(request, response); }/*from w ww . j a v a2 s . c o m*/ }
From source file:com.mindmutex.draugiem.DraugiemHttpFilter.java
@Override public void doInternalFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { try {/*from ww w .j av a2 s . co m*/ innerChain.reset(); innerChain.doFilter(request, response); filterChain.doFilter(request, response); } catch (Exception ex) { throw new ServletException(ex); } }
From source file:net.solarnetwork.node.setup.web.NodeAssociationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { doFilter((HttpServletRequest) request, (HttpServletResponse) response, chain); } else {/* w w w . ja va 2 s . c om*/ chain.doFilter(request, response); } }
From source file:org.chtijbug.drools.platform.web.filter.DynamicBaseFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { logger.debug(">> doFilterInternal()"); try {/* w w w. j av a 2 s . c o m*/ PrintWriter out = response.getWriter(); CharResponseWrapper wrapper = new CharResponseWrapper(response); filterChain.doFilter(request, wrapper); String baseHref = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/"; logger.debug("About to replace the base href element with {}", baseHref); String modifiedHtml = baseElementPattern.matcher(wrapper.toString()) .replaceAll("<base href=\"" + baseHref + "\""); logger.debug("Modified HTML content : {}", modifiedHtml); // Write our modified text to the real response response.setContentLength(modifiedHtml.getBytes().length); out.write(modifiedHtml); out.close(); } catch (Throwable t) { logger.error(t.getMessage()); } finally { logger.debug("<< doFilterInternal()"); } }
From source file:org.jamwiki.authentication.JAMWikiExceptionMessageFilter.java
/** * *//*from w w w . java 2 s.com*/ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(request instanceof HttpServletRequest)) { throw new ServletException("HttpServletRequest required"); } try { chain.doFilter(request, response); } catch (AcegiSecurityException ex) { handleException(request, ex); throw ex; } catch (ServletException ex) { if (ex.getRootCause() instanceof AcegiSecurityException) { handleException(request, (AcegiSecurityException) ex.getRootCause()); } throw ex; } }
From source file:com.pe.nisira.movil.view.listener.SessionTimeoutFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("filter called"); final HttpServletRequest req = (HttpServletRequest) request; final HttpSession session = req.getSession(false); if (session != null && !session.isNew()) { chain.doFilter(request, response); } else {/*from ww w. j a va2s.c o m*/ System.out.println("Has timed out"); req.getRequestDispatcher("/index.xthml").forward(request, response); } }
From source file:de.knightsoftnet.validationexample.server.spring.WebSecurityConfig.java
private Filter csrfHeaderFilter() { return new OncePerRequestFilter() { @Override/*from w w w .j a va2s . c o m*/ protected void doFilterInternal(final HttpServletRequest prequest, final HttpServletResponse presponse, final FilterChain pfilterChain) throws ServletException, IOException { WebSecurityConfig.this.csrfCookieHandler.setCookie(prequest, presponse); pfilterChain.doFilter(prequest, presponse); } }; }
From source file:org.surfnet.oaaas.consent.FormUserConsentHandler.java
@Override public void handleUserConsent(HttpServletRequest request, HttpServletResponse response, FilterChain chain, String authStateValue, String returnUri, Client client) throws IOException, ServletException { if (isUserConsentPost(request)) { if (processForm(request, response)) { chain.doFilter(request, response); }// ww w . j a va 2 s . co m } else { processInitial(request, response, chain, returnUri, authStateValue, client); } }