List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:net.navasoft.madcoin.backend.services.security.AuthenticationFilter.java
/** * Successful authentication.//from w ww .jav a 2s . c o m * * @param request * the request * @param response * the response * @param chain * the chain * @param authResult * the auth result * @throws IOException * Signals that an I/O exception has occurred. * @throws ServletException * the servlet exception * @since 27/07/2014, 06:48:55 PM */ @Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { super.successfulAuthentication(request, response, chain, authResult); chain.doFilter(request, response); }
From source file:com.zuoxiaolong.blog.api.component.authorization.AuthorizationFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String token = request.getHeader("token"); if (StringUtils.isEmpty(token)) { filterChain.doFilter(request, response); return;// w ww . j a v a 2 s .c o m } WebUser webUser = webUserService.checkToken(token); if (ObjectUtils.isNull(webUser)) { filterChain.doFilter(request, response); return; } if (AuthorizationHelper.isTokenExpired(token, webUser.getPassword())) { filterChain.doFilter(request, response); return; } HttpSession session = request.getSession(true); session.setAttribute("username", webUser.getUsername()); session.setAttribute("webUserId", webUser.getId()); filterChain.doFilter(request, response); }
From source file:fr.putnami.pwt.plugin.spring.rpc.server.filter.RequestContextFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {/*from www . jav a 2 s .c o m*/ RequestThreadLocalUtils.initContext((HttpServletRequest) request, (HttpServletResponse) response); chain.doFilter(request, response); } finally { RequestThreadLocalUtils.resetContext(); } }
From source file:com.knowbout.hibernate.OpenSessionInViewFilter.java
/** * // w ww . j a v a2s .c o m * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HibernateUtil.openSession(); try { chain.doFilter(request, response); } catch (ServletException se) { String message = se.toString(); if (se.getRootCause() != null) { message = se.getRootCause().toString(); } if (printFullExceptions) { if (se.getRootCause() != null) { log.error(message, se.getRootCause()); } else { log.error(message, se); } } else { log.error(message); } throw se; } catch (Throwable t) { if (printFullExceptions) { log.error(t.getMessage(), t); } else { log.error(t.toString()); } throw new ServletException(t); } finally { HibernateUtil.closeSession(); } }
From source file:alpine.filters.ClickjackingFilter.java
@Override public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) throws IOException, ServletException { final HttpServletResponse response = (HttpServletResponse) res; chain.doFilter(req, response); response.addHeader("X-Frame-Options", mode); }
From source file:org.openmrs.module.openhmis.cashier.web.filter.CashierLogoutFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { LOG.debug("doCashierLogoutFilter"); clockOutCashier();/*w w w . jav a 2s . c om*/ chain.doFilter(request, response); }
From source file:org.springmodules.validation.bean.context.web.ValidationContextFilter.java
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { try {//from w w w . j av a2 s. co m if (interceptor.preHandle(request, response, null)) { filterChain.doFilter(request, response); } } catch (Exception e) { throw new ServletException("Could not apply valication context filter", e); } finally { try { interceptor.postHandle(request, response, null, null); } catch (Exception e) { // do nothing } } }
From source file:com.confighub.api.server.filters.UrlRewriteFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { if (!(request instanceof HttpServletRequest)) { chain.doFilter(request, response); return;// w w w.j a v a 2 s. c om } String url = ((HttpServletRequest) request).getRequestURL().toString().toLowerCase(); URL aUrl = new URL(url); String path = aUrl.getPath(); if (path.startsWith("/email-verification") || path.startsWith("/passwordReset")) { request.getRequestDispatcher("/index.html").forward(request, response); return; } if (Utils.isBlank(path) || path.equals("/") || path.equals("/index.html") || path.startsWith("/rest")) { try { chain.doFilter(request, response); } catch (Exception e) { request.getRequestDispatcher("/404.html").forward(request, response); } return; } if (path.startsWith("/r/") || path.startsWith("/account/") || path.contains("edit/file/")) { request.getRequestDispatcher("/index.html").forward(request, response); return; } boolean hasExt = Utils.isBlank(FilenameUtils.getExtension(url)); if (!hasExt) { try { chain.doFilter(request, response); } catch (Exception e) { request.getRequestDispatcher("/404.html").forward(request, response); } return; } request.getRequestDispatcher("/index.html").forward(request, response); }
From source file:org.ng200.openolympus.controller.auth.RecaptchaAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!this.LOGIN_REQUEST_MATCHER.matches((HttpServletRequest) request)) { chain.doFilter(request, response); return;//from ww w . j av a2s .c o m } final String recaptchaResponse = request.getParameter("recaptchaResponse"); List<String> recaptchaErrors; try { recaptchaErrors = this.captchaService.checkCaptcha(recaptchaResponse); } catch (final URISyntaxException e) { throw new GeneralNestedRuntimeException("Couldn't access Recaptcha servers: ", e); } if (recaptchaErrors != null && !recaptchaErrors.isEmpty()) { this.recaptchaError(request, response, recaptchaErrors); return; } chain.doFilter(request, response); }
From source file:com.raissi.utils.CustomFileUploadFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (bypass) { filterChain.doFilter(request, response); return;/*from w ww .j ava2 s .co m*/ } HttpServletRequest httpServletRequest = (HttpServletRequest) request; boolean isMultipart = ServletFileUpload.isMultipartContent(httpServletRequest); if (isMultipart) { logger.debug("Parsing file upload request"); FileCleaningTracker fileCleaningTracker = FileCleanerCleanup .getFileCleaningTracker(request.getServletContext()); DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(); diskFileItemFactory.setFileCleaningTracker(fileCleaningTracker); if (thresholdSize != null) { diskFileItemFactory.setSizeThreshold(Integer.valueOf(thresholdSize)); } if (uploadDir != null) { diskFileItemFactory.setRepository(new File(uploadDir)); } ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory); MultipartRequest multipartRequest = new MultipartRequest(httpServletRequest, servletFileUpload); logger.debug( "File upload request parsed succesfully, continuing with filter chain with a wrapped multipart request"); filterChain.doFilter(multipartRequest, response); } else { filterChain.doFilter(request, response); } }