List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:cn.guoyukun.spring.web.filter.BaseFilter.java
/** * ?/*from ww w . j a v a2 s. c o m*/ * * @param request * @param response * @param chain * @throws IOException * @throws ServletException */ public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response); }
From source file:de.codecentric.boot.admin.web.SimpleCORSFilter.java
/** * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, * javax.servlet.FilterChain)//from www . j a v a 2 s . c om */ @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse res = (HttpServletResponse) response; res.setHeader("Access-Control-Allow-Origin", origin); chain.doFilter(request, res); }
From source file:com.amalto.core.servlet.TransactionFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { TransactionState state = getState(servletRequest); try {// w ww. j a va 2 s. c o m state.preRequest(); filterChain.doFilter(servletRequest, servletResponse); } catch (Throwable t) { state.cancelRequest(); throw new ServletException(t); } finally { state.postRequest(); } }
From source file:io.restassured.examples.springmvc.controller.AutoSpringSecurityConfigurerITest.java
@Test public void doesnt_add_spring_security_configurer_automatically_when_a_spring_security_configurer_has_been_manually_applied() { final AtomicBoolean filterUsed = new AtomicBoolean(false); RestAssuredMockMvc.given().webAppContextSetup(context, springSecurity(), springSecurity(new Filter() { public void init(FilterConfig filterConfig) throws ServletException { }//from w w w.j a v a 2s.c om public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { filterUsed.set(true); chain.doFilter(request, response); } public void destroy() { } })).postProcessors(httpBasic("username", "password")).param("name", "Johan").when().get("/secured/greeting") .then().statusCode(200).body("content", equalTo("Hello, Johan!")) .expect(authenticated().withUsername("username")); assertThat(filterUsed.get(), is(true)); }
From source file:com.jayway.restassured.examples.springmvc.controller.AutoSpringSecurityConfigurerITest.java
@Test public void doesnt_add_spring_security_configurer_automatically_when_a_spring_security_configurer_has_been_manually_applied() { final AtomicBoolean filterUsed = new AtomicBoolean(false); given().webAppContextSetup(context, springSecurity(), springSecurity(new Filter() { public void init(FilterConfig filterConfig) throws ServletException { }/*from w w w. j ava 2 s . com*/ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { filterUsed.set(true); chain.doFilter(request, response); } public void destroy() { } })).postProcessors(httpBasic("username", "password")).param("name", "Johan").when().get("/secured/greeting") .then().statusCode(200).body("content", equalTo("Hello, Johan!")) .expect(authenticated().withUsername("username")); assertThat(filterUsed.get(), is(true)); }
From source file:edu.cornell.mannlib.vitro.webapp.filters.TestFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { log.debug("in TestFilter.doFilter()"); request.setAttribute("TestAttr", "This is a test value, it could be a setup VitroFacade"); chain.doFilter(request, response); }
From source file:org.opendatakit.security.spring.DigestAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (SecurityContextHolder.getContext().getAuthentication() == null) { super.doFilter(request, response, chain); } else {/* w ww. jav a 2 s.c om*/ chain.doFilter(request, response); } }
From source file:info.matsumana.config.AppConfig.java
@Bean public FilterRegistrationBean filterRegistrationBean() { Filter filter = new Filter() { @Override//from w w w . j a v a2 s .co m public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { counterService.increment("active-http-sessions"); filterChain.doFilter(servletRequest, servletResponse); } finally { counterService.decrement("active-http-sessions"); } } @Override public void destroy() { } }; FilterRegistrationBean registrationBean = new FilterRegistrationBean(); registrationBean.setFilter(filter); registrationBean.addUrlPatterns("/sample/api/*"); return registrationBean; }
From source file:MyServlet.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { long start = System.currentTimeMillis(); String address = request.getRemoteAddr(); String file = ((HttpServletRequest) request).getRequestURI(); chain.doFilter(request, response); filterConfig.getServletContext().log("User access! " + " User IP: " + address + " Resource: " + file + " Milliseconds used: " + (System.currentTimeMillis() - start)); }
From source file:it.scoppelletti.programmerpower.web.spring.FilterChainBean.java
/** * Filtro di una richiesta./*from ww w . j ava 2s. com*/ * * @param req Richiesta. * @param resp Risposta. * @param chain Catena dei filtri. */ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { FilterChain filter; if (myChain == null) { throw new PropertyNotSetException(toString(), "chain"); } filter = new FilterChainImpl(myChain, chain); filter.doFilter(req, resp); }