List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:nl.ctrlaltdev.harbinger.filter.BlacklistFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!ctx.isBlacklisted(request.getRemoteAddr(), Instant.now())) { chain.doFilter(request, response); } else if (response instanceof HttpServletResponse) { ((HttpServletResponse) response).sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); }// w w w . j a va 2 s . c o m }
From source file:com.ocpsoft.socialpm.web.filter.ResponseTimeLoggingFilter.java
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { Timer timer = Timer.getTimer(); timer.start();/*w w w . ja v a2 s . c o m*/ chain.doFilter(request, response); timer.stop(); double time = timer.getElapsedMilliseconds(); PrettyContext context = PrettyContext.getCurrentInstance((HttpServletRequest) request); if (context != null) { this.log.info("Reponse completed in: " + time / 1000.0 + " - " + context.getRequestURL() + context.getRequestQueryString()); } else { this.log.info("Reponse completed in: " + time / 1000.0 + " - " + ((HttpServletRequest) request).getRequestURL()); } }
From source file:grails.plugin.cache.web.filter.NoOpFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { ((HttpServletResponse) response).addHeader(PageFragmentCachingFilter.X_CACHED, "disabled"); chain.doFilter(request, response); }
From source file:org.carewebframework.logging.log4j.LogContextFilter.java
/** * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, * javax.servlet.ServletResponse, javax.servlet.FilterChain) *//*from w w w .j a v a 2 s. co m*/ @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { try { LogUtil.addStandardDiagnosticContextToCurrentThread(); chain.doFilter(request, response); } finally { LogUtil.removeDiagnosticContextFromCurrentThread(); } }
From source file:org.sventon.appl.ConfigAuthorizationFilter.java
private void dispatchRequest(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { request.setAttribute("isEdit", true); filterChain.doFilter(request, response); }
From source file:com.zeperdi.demo.webapp.DemoFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding(this.encoding); chain.doFilter(request, response); }
From source file:gov.nih.nci.caarray.web.filter.CacheControlFilter.java
/** * {@inheritDoc}//from w ww . j a v a 2 s .co m */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(response instanceof HttpServletResponse)) { chain.doFilter(request, response); return; } HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; if (StringUtils.substringAfterLast(httpRequest.getRequestURI(), ".").equals(DYNAMIC_URL_EXTENSION)) { if (!request.isSecure()) { // workaround for IE files bug http://support.microsoft.com/kb/812935 httpResponse.addHeader("Cache-control", "no-cache"); httpResponse.addHeader("Pragma", "no-cache"); } httpResponse.addIntHeader("Expires", 0); } chain.doFilter(request, response); }
From source file:org.eclipse.virgo.snaps.core.SnapHostFilterTests.java
@Test public void testRouteToChain() throws IOException, ServletException { MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletRequest request = new MockHttpServletRequest(); request.setPathInfo("/hotels/booking"); Snap snap = createMock(Snap.class); FilterChain chain = createMock(FilterChain.class); chain.doFilter(request, response); expectLastCall();// w ww . j a v a 2 s. co m MockServletContext servletContext = new MockServletContext(); MockFilterConfig config = new MockFilterConfig(servletContext); replay(snap, chain); TestFilter filter = new TestFilter(); filter.init(config); filter.doFilter(request, response, chain); filter.destroy(); verify(snap, chain); }
From source file:gov.nih.nci.protexpress.ui.filters.UserFilter.java
/** * {@inheritDoc}//from w w w. ja v a2s. c om */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(request instanceof HttpServletRequest)) { chain.doFilter(request, response); return; } String username = ((HttpServletRequest) request).getRemoteUser(); if (StringUtils.isNotBlank(username)) { User user = ProtExpressRegistry.getUserProvisioningManager().getUser(username); if (user == null) { user = new User(); user.setLoginName(username); } UserHolder.setUser(user); request.setAttribute("currentUser", UserHolder.getUser()); request.setAttribute("currentUserDisplayName", UserHolder.getDisplayNameForUser()); } else { UserHolder.setUser(null); } chain.doFilter(request, response); }
From source file:io.fabric8.spring.cloud.kubernetes.hystrix.HystrixRequestContextServletFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { HystrixRequestContext context = HystrixRequestContext.initializeContext(); try {/* www.j ava 2 s . c om*/ chain.doFilter(request, response); } finally { context.shutdown(); } }