List of usage examples for javax.servlet FilterChain doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException;
From source file:org.appverse.web.framework.backend.api.helpers.security.RPCTimeoutRedirectFilter.java
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { try {//from www. j a v a2s . c o m chain.doFilter(request, response); logger.debug("Chain processed normally"); } catch (IOException ex) { throw ex; } catch (Exception ex) { Throwable[] causeChain = throwableAnalyzer.determineCauseChain(ex); RuntimeException ase = (AuthenticationException) throwableAnalyzer .getFirstThrowableOfType(AuthenticationException.class, causeChain); if (ase == null) { ase = (AccessDeniedException) throwableAnalyzer.getFirstThrowableOfType(AccessDeniedException.class, causeChain); } if (ase != null) { if (ase instanceof AuthenticationException) { String rpcContentType = ((HttpServletRequest) request).getHeader("Content-Type"); if (rpcContentType != null && rpcContentType.contains(GWT_RPC_CONTENT_TYPE)) { logger.info("gwt-rpc call detected, send {} error code", this.customSessionExpiredErrorCode); HttpServletResponse resp = (HttpServletResponse) response; resp.sendError(this.customSessionExpiredErrorCode); } else { logger.info("Redirect to login page"); throw ase; } } else if (ase instanceof AccessDeniedException) { if (authenticationTrustResolver .isAnonymous(SecurityContextHolder.getContext().getAuthentication())) { logger.info("User session expired or not logged in yet"); if (SecurityContextHolder.getContext().getAuthentication() == null) { logger.debug("SecurityContextHolder.getContext().getAuthentication() is NULL" + SecurityContextHolder.getContext().getAuthentication()); } else { logger.debug(new StringBuffer().append( "SecurityContextHolder.getContext().getAuthentication().getPrincipal(): ") .append(SecurityContextHolder.getContext().getAuthentication().getPrincipal()) .toString()); logger.debug(new StringBuffer().append( "SecurityContextHolder.getContext().getAuthentication().getAuthorities(): ") .append(SecurityContextHolder.getContext().getAuthentication().getAuthorities()) .toString()); logger.debug(new StringBuffer().append( "SecurityContextHolder.getContext().getAuthentication().getCredentials(): ") .append(SecurityContextHolder.getContext().getAuthentication().getCredentials()) .toString()); logger.debug(new StringBuffer() .append("SecurityContextHolder.getContext().getAuthentication().getDetails(): ") .append(SecurityContextHolder.getContext().getAuthentication().getDetails()) .toString()); logger.debug(new StringBuffer().append( "SecurityContextHolder.getContext().getAuthentication().isAuthenticated(): ") .append(SecurityContextHolder.getContext().getAuthentication() .isAuthenticated()) .toString()); } String rpcContentType = ((HttpServletRequest) request).getHeader("Content-Type"); if (rpcContentType != null && rpcContentType.contains(GWT_RPC_CONTENT_TYPE)) { logger.info("gwt-rpc call detected, send {} error code", this.customSessionExpiredErrorCode); HttpServletResponse resp = (HttpServletResponse) response; resp.sendError(this.customSessionExpiredErrorCode); } else { logger.info("Redirect to login page"); throw ase; } } else { throw ase; } } } } }
From source file:com.github.nblair.web.ProfileConditionalDelegatingFilterProxy.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (requiredProfilesAreActive()) { super.doFilter(request, response, filterChain); } else {//from w w w . j ava2 s . c o m filterChain.doFilter(request, response); } }
From source file:cn.vlabs.duckling.vwb.PromitionLogFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(request instanceof HttpServletRequest)) { chain.doFilter(request, response); return;//from www .j av a2s. c o m } HttpServletRequest httpRequest = (HttpServletRequest) request; String serverName = request.getServerName(); if (!StringUtils.equals(serverName, VWBContext.getContainer().getDomainService().getSiteDefaultDomain(ADMIN_SITE_ID))) { chain.doFilter(request, response); return; } HttpSession session = httpRequest.getSession(); String promotionHost = (String) session.getAttribute(PROMOTION_HOST); String requestUrl = httpRequest.getRequestURI(); if (StringUtils.equals(requestUrl, createUrl)) { logCreateJson(promotionHost, requestUrl); } if (StringUtils.isNotBlank(promotionHost)) { chain.doFilter(request, response); return; } String paramRef = request.getParameter(PARAM_REF); if (StringUtils.isNotBlank(paramRef)) { session.setAttribute(PROMOTION_HOST, paramRef); logAccessJson("", paramRef, paramRef, requestUrl); chain.doFilter(request, response); return; } String referer = httpRequest.getHeader("Referer"); String referHost = getRefererHost(referer); if (StringUtils.isNotBlank(referHost)) { session.setAttribute(PROMOTION_HOST, getRefererNameByHost(referHost)); logAccessJson(referer, referHost, getRefererNameByHost(referHost), requestUrl); chain.doFilter(request, response); } }
From source file:com.npower.dm.tracking.servlet.AccessTrackingFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) { try {//from ww w . jav a2 s . c o m if (request instanceof HttpServletRequest) { HttpServletRequest req = (HttpServletRequest) request; this.tracker4Access.log(req); } filterChain.doFilter(request, response); } catch (ServletException sx) { filterConfig.getServletContext().log(sx.getMessage()); log.error(sx.getMessage(), sx); log.error(sx.getMessage(), sx.getCause()); } catch (Throwable ex) { filterConfig.getServletContext().log(ex.getMessage()); log.error(ex.getMessage(), ex); } finally { } }
From source file:io.neba.core.resourcemodels.caching.RequestScopedResourceModelCache.java
/** * {@inheritDoc}//from w ww .j a va2s . co m */ @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!this.configuration.enabled()) { chain.doFilter(request, response); return; } if (!(request instanceof SlingHttpServletRequest)) { throw new IllegalStateException( "Expected a " + SlingHttpServletRequest.class.getName() + ", but got: " + request + "."); } final SlingHttpServletRequest slingHttpServletRequest = (SlingHttpServletRequest) request; this.requestHolder.set(slingHttpServletRequest); this.cacheHolder.set(new HashMap<>(1024)); try { chain.doFilter(slingHttpServletRequest, response); } finally { this.cacheHolder.remove(); this.requestHolder.remove(); } }
From source file:org.opendatakit.security.spring.BasicAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (SecurityContextHolder.getContext().getAuthentication() == null) { impl.doFilter(request, response, chain); } else {//from w w w . j ava 2s . c o m chain.doFilter(request, response); } }
From source file:org.zht.framework.filter.UserAccessLogFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; String requestUrl = httpRequest.getServletPath(); if (isIgnorUrl(requestUrl)) { filterChain.doFilter(request, response); return;//from www . j a v a2 s.c om } //? OperationLog operationLog = LogUtil.genOperationLog(httpRequest); if (isPersistToDataBase) { if (operationLog != null) { try { operateLogService.$base_save(operationLog); } catch (Exception e) { } } } filterChain.doFilter(request, response); }
From source file:com.isalnikov.config.auth.UserAuthorizationFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; if (RequestMethod.POST.name().equals(request.getMethod())) { super.doFilter(req, resp, chain); } else {/*from w ww . j a v a2 s . c om*/ chain.doFilter(req, resp); } }
From source file:io.specto.hoverfly.recorder.HoverflyFilter.java
@Override public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { HttpServletResponseCopier responseCopier = new HttpServletResponseCopier( (HttpServletResponse) servletResponse); try {/*ww w . j a va 2s. c o m*/ filterChain.doFilter(servletRequest, responseCopier); responseCopier.flushBuffer(); } finally { final HoverflyRecording.HoverFlyRequest hoverFlyRequest = recordRequest( (HttpServletRequest) servletRequest); final HoverflyRecording.HoverFlyResponse hoverFlyResponse = recordResponse(responseCopier); hoverflyRecordings.add(new HoverflyRecording(hoverFlyRequest, hoverFlyResponse)); } }
From source file:com.sivalabs.jcart.admin.security.PostAuthorizationFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { String uri = request.getRequestURI(); if (!isIgnorableURI(uri)) { String menu = MenuConfiguration.getMatchingMenu(uri); request.setAttribute("CURRENT_MENU", menu); }/*from ww w .ja v a 2s. c o m*/ chain.doFilter(request, response); }