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:name.martingeisse.servlet_httpclient.sidekicks.fakecdn.FakeCdnFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String uri = httpRequest.getRequestURI();
    if (uri.startsWith(URI_PREFIX)) {
        String key = uri.substring(URI_PREFIX.length() - 1);
        doCdn(httpRequest, response, key);
    } else {/*from   ww  w  .j a v  a2 s  . c o  m*/
        filterChain.doFilter(request, response);
    }
}

From source file:com.acmemotors.rest.web.CORSFilter.java

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
        throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse) res;
    response.setHeader("Access-Control-Allow-Origin", "*");

    response.setHeader("Access-Control-Allow-Methods", "GET");
    response.setHeader("Access-Control-Max-Age", "3600");
    response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
    chain.doFilter(req, res);
}

From source file:com.adobe.acs.commons.wcm.views.impl.WCMViewsFilter.java

/**
 * Performs the filter chain inclusion, setting the WCMMode before and after the inclusion.
 *
 * @param request  the request/*from   ww w.java  2  s.  c  om*/
 * @param response the response
 * @param chain    the filter chain
 * @param before   the WCMMode to apply before the filter chaining
 * @param after    the WCMMode to apply before the filter chaining
 * @throws IOException
 * @throws ServletException
 */
private void processChain(final ServletRequest request, final ServletResponse response, final FilterChain chain,
        final WCMMode before, final WCMMode after) throws IOException, ServletException {

    before.toRequest(request);
    chain.doFilter(request, response);
    after.toRequest(request);
}

From source file:net.rgielen.struts1.filter.ParamWrapperFilter.java

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    ParamFilteredRequest wrapper = null;
    if (request instanceof HttpServletRequest)
        wrapper = new ParamFilteredRequest(request, pattern);

    if (wrapper != null)
        chain.doFilter(wrapper, response);
    else//from w  w w. jav  a2s.  c  o  m
        chain.doFilter(request, response);
}

From source file:cn.vlabs.umt.ui.servlet.filters.P3PConfigFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {
    if (resp instanceof HttpServletResponse) {
        HttpServletResponse re = (HttpServletResponse) resp;
        String s = p3p;/*from   ww w  .ja va2  s . c o  m*/
        if (StringUtils.isEmpty(s)) {
            s = "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"";
        }
        re.setHeader("P3P", s);
    }
    chain.doFilter(request, resp);
}

From source file:com.sun.socialsite.web.filters.RedirectorFilter.java

/**
 *
 *///ww  w  .j  ava2  s.  c o m
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest httpReq = (HttpServletRequest) req;
    HttpServletResponse httpResp = (HttpServletResponse) resp;

    String redirectionUri = getRedirectionUri(httpReq);
    if (redirectionUri == null) {
        chain.doFilter(req, resp);
    } else {
        httpResp.sendRedirect(redirectionUri);
    }

}

From source file:com.distributedapplication.springcontrollers.SimpleCORSFilter.java

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
        throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse) res;
    response.setHeader("Access-Control-Allow-Origin", "*");
    response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
    response.setHeader("Access-Control-Max-Age", "0");
    response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
    chain.doFilter(req, res);
}

From source file:com.iflytek.edu.cloud.frame.web.filter.CORSFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    String origin = request.getHeader("Origin");
    if (allowedOrigins.contains(origin)) {
        response.addHeader("Access-Control-Allow-Origin", origin);
        response.addHeader("Access-Control-Allow-Methods", "GET, POST");
        response.addHeader("Access-Control-Allow-Headers", "Content-Type");
    }/*from   ww  w .  j  a  va 2s.  c  om*/

    filterChain.doFilter(request, response);
}

From source file:cz.metacentrum.perun.oauth.PerunAuthenticator.java

@Override
public void authenticate(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
        String authStateValue, String returnUri) throws IOException, ServletException {
    setAuthStateValue(request, authStateValue);
    AuthenticatedPrincipal principal = setupPrincipal(request);
    setPrincipal(request, principal);/*  www .j ava2  s .c  om*/
    chain.doFilter(request, response);
}

From source file:org.smigo.config.RequestLogFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletResponse resp = (HttpServletResponse) response;
    HttpServletRequest req = (HttpServletRequest) request;
    resp.addHeader("SmigoUser", req.getRemoteUser());
    log.info("Incoming request:" + req.getMethod() + req.getRequestURL().toString());
    request.setAttribute(REQUEST_TIMER, System.nanoTime());
    chain.doFilter(request, response);
    logHandler.log(req, resp);/*from  w  ww  . j  a v a2s .c o  m*/
}