Example usage for javax.servlet FilterChain doFilter

List of usage examples for javax.servlet FilterChain doFilter

Introduction

In this page you can find the example usage for javax.servlet FilterChain doFilter.

Prototype

public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;

Source Link

Document

Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked.

Usage

From source file:com.wavemaker.tools.security.CloudFoundrySecurityFilter.java

private void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws IOException {
    try {//from w ww.  j a  va 2  s  .c om
        if (isSecurityEnabled()) {
            checkAuthenticationCookie(request);
        }
        chain.doFilter(request, response);
    } catch (Exception e) {
        if (log.isInfoEnabled()) {
            log.info("Redirecting to spinup following security error", e);
        }
        redirectToSpinup(response);
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.filters.PageRoutingFilter.java

protected void doNonDisplayPage(String path, ServletRequest arg0, ServletResponse arg1, FilterChain chain)
        throws IOException, ServletException {
    log.debug(path + "this isn't a request to a page defined in the display model, handle it normally.");
    chain.doFilter(arg0, arg1);
}

From source file:com.epam.cme.storefront.filters.btg.AbstractBtgFilter.java

@Override
public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain chain) throws IOException, ServletException {
    final AbstractBTGRuleDataEvent<Serializable> event = getEvent(request);
    publishEvent(event);/*from   w  w  w  .  j a  v a 2  s  . c o  m*/
    try {
        chain.doFilter(request, response);
    } finally {
        if (isRequestScoped() && event != null) {
            publishEvent(getCleanupEvent(event));
        }
    }

}

From source file:com.zimbra.common.filters.Base64Filter.java

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {
    if (!(req instanceof HttpServletRequest)) {
        chain.doFilter(req, resp);
        return;//from w w w.  ja v a2 s.  c om
    }

    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) resp;

    if (isEncodeable(request)) {
        Base64ResponseWrapper wrappedResponse = new Base64ResponseWrapper(response);
        chain.doFilter(req, wrappedResponse);
        wrappedResponse.finishResponse();
    } else {
        chain.doFilter(req, resp);
    }
}

From source file:com.openedit.generators.FilterGenerator.java

public void generate(WebPageRequest inContext, Page inPage, Output inOut) throws OpenEditException {
    HttpServletRequest httpRequest = inContext.getRequest();
    HttpServletResponse httpResponse = inContext.getResponse();
    Page page = (Page) inContext.getPageValue("page");

    //load the standard context objects
    httpRequest.setAttribute("context", inContext);
    httpRequest.setAttribute("pages", inContext.getPageStreamer());
    httpRequest.setAttribute("content", inContext.getContentPage());

    /* I commented this out since it conflics with existing JSP pages. Blojsom has its own "page" variable, get stuff from the context
     for (Iterator iter = inContext.getPageMap().entrySet().iterator(); iter.hasNext();)
     {//from   www  .  j  av a2s  .  c o m
     Map.Entry entry = (Map.Entry) iter.next();
     String key = (String) entry.getKey();
     httpRequest.setAttribute(key, inContext.getPageValue(key));
     }
     */

    DecoratedServletResponse response = new DecoratedServletResponse(httpResponse,
            new DecoratedServletOutputStream(inOut));

    DecoratedServletRequest newrequest = new DecoratedServletRequest(httpRequest);

    String requestPath = page.getContentItem().getActualPath();
    newrequest.setrequestURI(requestPath);
    try {
        inOut.getWriter().flush();
        //URLUtilities urls = (URLUtilities)inContext.getPageValue(PageRequestKeys.URL_UTILITIES);
        if (requestPath.endsWith(".jsp")) {
            //A dispatcherallow us to use the base directory and draft modes
            RequestDispatcher jspDispatcher = httpRequest.getRequestDispatcher(requestPath);
            jspDispatcher.include(newrequest, response); //This only applies for jsp pages.
        } else {
            FilterChain chain = (FilterChain) httpRequest.getAttribute("servletchain");
            chain.doFilter(newrequest, response); //This will capture output to our existing output class
        }
        inOut.getWriter().flush();
    } catch (ServletException ex) {
        throw new OpenEditException(ex);
    } catch (IOException ex) {
        throw new OpenEditException(ex);
    }
}

From source file:com.edgenius.wiki.security.acegi.CaptchaValidationProcessingFilter.java

private void processVerify(ServletRequest request, ServletResponse response, FilterChain chain, boolean valid)
        throws IOException, ServletException {

    if (valid) {//w ww  . ja v  a 2  s .c o m
        //success
        chain.doFilter(request, response);
    } else {
        //failed
        if (((HttpServletRequest) request).getRequestURI().endsWith("j_spring_security_check")) {
            //as user login using Form submit style authentication rather than RPC's so that I have to do special handling here
            //code ugly, it could be changed to RPC authentication in future.
            response.getWriter()
                    .write(SharedConstants.FORM_RET_HEADER + SharedConstants.FORM_RET_HEADER_ERROR_CAPTCHA);
        } else {
            // Put exception into request scope (perhaps of use to a view)
            ((HttpServletRequest) request).setAttribute(ACEGI_SECURITY_CAPTCHA_VALID_FAILED, true);

            // Perform RequestDispatcher "forward"
            RequestDispatcher rd = request.getRequestDispatcher(errorPage);
            rd.forward(request, response);
        }
    }

}

From source file:sk.openhouse.web.filter.LocaleConfigurerFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {

    if (localeResolver != null) {
        Locale locale = localeResolver.resolveLocale(request);
        LocaleContextHolder.setLocale(locale);
    }// w ww . j a va 2s  .c om

    filterChain.doFilter(request, response);

    if (localeResolver != null) {
        LocaleContextHolder.resetLocaleContext();
    }
}

From source file:com.anderl.hibernate.ext.IgnorableFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {

    if (isIgnoredUrl(request)) {
        log.debug("{} has been ignored. see init params in web.xml", request.getServletPath());
        filterChain.doFilter(request, response);
    } else {/*from   w  w w  . j a  v  a  2 s. co m*/
        doFilterUnignored(request, response, filterChain);
    }
}

From source file:com.flexive.war.filter.JsonRpcFilter.java

/**
 * {@inheritDoc}//from  ww w.j  av  a 2s .  co  m
 */
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException {
    // set JSON bridge
    getJsonBridge(((HttpServletRequest) servletRequest).getSession());
    filterChain.doFilter(servletRequest, servletResponse);
}

From source file:se.vgregion.javg.web.filter.WebErrorHandlingFilter.java

public void doFilter(ServletRequest request, ServletResponse arg1, FilterChain arg2)
        throws IOException, ServletException {
    // System.out.println("in doFilter(ServletRequest");
    try {//from w w w .  j  a va  2s .  c o m

        arg2.doFilter(request, arg1);
    } catch (Exception e) {

        arg1.getWriter()
                .write(createTyckTillPopupLink(e.toString(), ((HttpServletRequest) request).getRemoteUser()));
    }
}