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.rockagen.gnext.Filter.AccessFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    accessLog(request);/*from  w  ww  .  j av  a2 s .  co m*/
    filterChain.doFilter(request, response);
}

From source file:shiver.me.timbers.spring.security.CookieAndHeaderJwtAuthenticationFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    if (request.getAttribute(FILTER_APPLIED) != null) {
        chain.doFilter(request, response);
        return;//  w  w  w  .  jav  a 2s.c om
    }

    try {
        final Authentication authentication = tokenParser.parse((HttpServletRequest) request);
        securityContextHolder.getContext().setAuthentication(authentication);
        authenticationApplier.apply(authentication, (HttpServletResponse) response);
        request.setAttribute(FILTER_APPLIED, TRUE);
    } catch (JwtInvalidTokenException e) {
        log.debug("Failed JWT authentication.", e);
    }
    chain.doFilter(request, response);
}

From source file:com.blacklocus.webapp.app.StaticResourceUTF8CharEncodingFilterHolder.java

public StaticResourceUTF8CharEncodingFilterHolder() {
    super(new Filter() {
        @Override/* w  w  w. j  ava 2  s  . co  m*/
        public void init(FilterConfig filterConfig) throws ServletException {
            // no-op
        }

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                throws IOException, ServletException {
            response.setCharacterEncoding(CharEncoding.UTF_8);
            chain.doFilter(request, response);
        }

        @Override
        public void destroy() {
            // no-op
        }
    });
}

From source file:net.mymam.upload.UploadMultipartRequestFilter.java

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

    if (!(request instanceof HttpServletRequest)) {
        chain.doFilter(request, response);
        return;/*ww w  .ja  v  a 2s.c  o m*/
    }

    HttpServletRequest httpRequest = (HttpServletRequest) request;

    if (!ServletFileUpload.isMultipartContent(httpRequest)) {
        chain.doFilter(request, response);
        return;
    }

    ServletFileUpload upload = new ServletFileUpload(factory);
    UploadMultipartRequestWrapper multipartRequest = new UploadMultipartRequestWrapper(httpRequest, upload);
    chain.doFilter(multipartRequest, response);
}

From source file:com.excilys.ebi.utils.web.flash.spring.SpringFlashFilter.java

public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    try {//from  w  w  w  .  j a va2s . co m
        handler.movePreviousFlashFromSessionToRequest(request);
        chain.doFilter(request, response);

    } finally {
        handler.storeCurrentFlashInSession(request);
    }
}

From source file:io.dropwizard.hystrix.path.tracker.filters.impl.PathTrackerFilter.java

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException {
    new TrackerCommand.VoidTracker(identifyKey(servletRequest),
            () -> filterChain.doFilter(servletRequest, servletResponse)).execute();
}

From source file:com.truthbean.demo.ssm.controller.UserSessionFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    Object object = request.getSession().getAttribute("user");
    if (object != null && object instanceof User) {
        filterChain.doFilter(request, response);
    } else {/*from  w w  w  .  j  a  va 2  s . c  om*/
        response.sendRedirect(request.getContextPath() + "/login.html");
    }
}

From source file:com.thoughtworks.go.server.security.PerformanceLoggingFilter.java

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException {
    long start = System.currentTimeMillis();
    try {/*from   w  ww  .  jav  a2s .co  m*/
        filterChain.doFilter(servletRequest, servletResponse);
    } finally {
        if (logRequestTimings) {
            long amountOfTimeItTookInMilliseconds = System.currentTimeMillis() - start;
            String requestURI = ((HttpServletRequest) servletRequest).getRequestURI();
            String requestor = servletRequest.getRemoteAddr();

            com.thoughtworks.go.server.util.ServletResponse response = ServletHelper.getInstance()
                    .getResponse(servletResponse);
            int status = response.getStatus();
            long contentCount = response.getContentCount();

            webRequestPerformanceLogger.logRequest(requestURI, requestor, status, contentCount,
                    amountOfTimeItTookInMilliseconds);
            LOGGER.warn(requestURI + " took: " + amountOfTimeItTookInMilliseconds + " ms");
        }
    }
}

From source file:com.autentia.intra.filter.UTF8Filter.java

/**
 * Metemos en la request el formato de codificacion UTF-8
 *///  www  .ja  v a2 s .  c o m
public void doFilter(ServletRequest request, ServletResponse response, FilterChain fc)
        throws IOException, ServletException {
    response.setContentType(contentType);
    request.setCharacterEncoding(encoding);
    fc.doFilter(request, response);
}

From source file:edu.duke.cabig.c3pr.utils.web.AuditInfoFilter.java

@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest httpReq = (HttpServletRequest) request;
    setAuditInfo(httpReq);/*from   w  w w .j  a  v a 2s.  com*/
    chain.doFilter(request, response);
    unsetAuditInfo();
}