List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:net.sourceforge.vulcan.web.ContentTypeFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { final String contentType = detectContentType(request); final HttpServletResponseContentTypeWrapper responseWrapper = new HttpServletResponseContentTypeWrapper( request, response, suppressContentTypes, contentType); response.addHeader("Cache-Control", "max-age=0"); chain.doFilter(request, responseWrapper); }
From source file:com.googlesource.gerrit.plugins.github.oauth.OAuthWebFilter.java
private void logout(ServletRequest request, ServletResponse response, FilterChain chain, HttpServletRequest httpRequest) throws IOException, ServletException { getGitHubLogin(request).logout();//from ww w . j a v a2s .c o m GitHubLogoutServletResponse bufferedResponse = new GitHubLogoutServletResponse( (HttpServletResponse) response, config.logoutRedirectUrl); chain.doFilter(httpRequest, bufferedResponse); }
From source file:com.adobe.acs.commons.wcm.impl.AemEnvironmentIndicatorFilter.java
@Override @SuppressWarnings("squid:S3776") public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { if (!(servletRequest instanceof HttpServletRequest) || !(servletResponse instanceof HttpServletResponse)) { filterChain.doFilter(servletRequest, servletResponse); return;//www .j a v a2s .co m } final HttpServletRequest request = (HttpServletRequest) servletRequest; final HttpServletResponse response = (HttpServletResponse) servletResponse; if (!this.accepts(request)) { filterChain.doFilter(request, response); return; } final BufferingResponse capturedResponse = new BufferingResponse(response); filterChain.doFilter(request, capturedResponse); boolean doInclude = true; if (ArrayUtils.isNotEmpty(excludedWCMModes)) { // Test for configured WCM modes, where the indicators are not displayed WCMMode wcmmode = extractFromRequest(request); if (wcmmode != null) { for (String m : excludedWCMModes) { if (StringUtils.equalsIgnoreCase(wcmmode.name(), m)) { doInclude = false; break; } } } else { // No wcmmode could be extracted from the request } } // Get contents final String contents = capturedResponse.getContents(); if (doInclude && contents != null && StringUtils.contains(response.getContentType(), "html")) { final int bodyIndex = contents.indexOf("</body>"); if (bodyIndex != -1) { final PrintWriter printWriter = response.getWriter(); printWriter.write(contents.substring(0, bodyIndex)); if (StringUtils.isNotBlank(css)) { printWriter.write("<style>" + css + " </style>"); printWriter.write("<div id=\"" + DIV_ID + "\">" + innerHTML + "</div>"); } if (StringUtils.isNotBlank(titlePrefix)) { printWriter.printf(TITLE_UPDATE_SCRIPT, titlePrefix); } printWriter.write(contents.substring(bodyIndex)); return; } } if (contents != null) { response.getWriter().write(contents); } }
From source file:com.cisco.oss.foundation.http.server.HttpMethodFilter.java
@Override public void doFilterImpl(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String method = httpServletRequest.getMethod(); if (methods.contains(method)) { LOGGER.error("method {} is not allowed", method); ((HttpServletResponse) response).sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } else {/*w w w . j a va 2 s. c o m*/ chain.doFilter(request, response); } }
From source file:fr.putnami.pwt.plugin.ajaxbot.filter.AjaxPageFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; if (HttpMethod.GET.toString().equals(request.getMethod()) && req.getParameter(QUERY_PARAM_ESCAPED_FRAGMENT) != null) { ByteStreams.copy(this.getHtmlStream(request), resp.getOutputStream()); } else {//from w ww. j a va2 s . c om chain.doFilter(req, resp); } }
From source file:org.openlmis.fulfillment.security.ResourceServerSecurityConfiguration.java
@Override public void configure(HttpSecurity http) throws Exception { http.addFilterAfter(new OncePerRequestFilter() { @Override/* www. j av a 2 s . c o m*/ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { // We don't want to allow access to a resource with no token so clear // the security context in case it is actually an OAuth2Authentication if (tokenExtractor.extract(request) == null) { SecurityContextHolder.clearContext(); } filterChain.doFilter(request, response); } }, AbstractPreAuthenticatedProcessingFilter.class); http.csrf().disable(); http.authorizeRequests() .antMatchers("/fulfillment", "/webjars/**", "/fulfillment/webjars/**", "/fulfillment/docs/**") .permitAll().antMatchers("/**").fullyAuthenticated(); }
From source file:org.surfnet.oaaas.conext.SAMLAuthenticator.java
private void proceedWithChain(HttpServletRequest request, HttpServletResponse response, FilterChain chain, AuthenticatedPrincipal principal, String authStateValue) throws IOException, ServletException { super.setPrincipal(request, principal); super.setAuthStateValue(request, authStateValue); chain.doFilter(request, response); }
From source file:edu.uiowa.icts.filter.IctsSecurityFilter.java
/** {@inheritDoc} */ @Override/*w w w. ja v a2s .c om*/ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest servletRequest = (HttpServletRequest) request; log.debug("filtering request " + servletRequest.getRequestURI()); // ServletContext sc = getServletContext(); // Enumeration names = sc.getInitParameterNames(); // while( names.hasMoreElements() ){ // log.debug(names.nextElement()); // } chain.doFilter(request, response); }
From source file:chiron.maxscore.servlet.SecurityServlet.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpSession session = ((HttpServletRequest) request).getSession(); Object role = session.getAttribute("role"); if (role == null) { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> map = new HashMap<>(); map.put("success", false); map.put("msg", ""); mapper.writeValue(response.getWriter(), map); }/*www . j a v a 2 s . c o m*/ chain.doFilter(request, response); }
From source file:org.spee.sbweb.domain.SimpleCORSFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { // TODO Auto-generated method stub HttpServletResponse response = (HttpServletResponse) resp; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); chain.doFilter(req, resp); }