@Test public void testdoFilterShouldNotPassRequestResponseToChainIfNotAdmin() throws IOException, ServletException { given(hostValidatorService.isRequestFromAdmin(servletRequest)).willReturn(false); given(servletResponse.getWriter()).willReturn(printWriter); underTest.doFilter(servletRequest, servletResponse, filterChain); verify(filterChain, never()).doFilter(servletRequest, servletResponse); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (hostValidatorService.isRequestFromAdmin(request)) { chain.doFilter(request, response); } else { if (request instanceof HttpServletRequest) { logger.info(urlAccessLogMessageAssembler.assembleDenyMessage((HttpServletRequest) request)); } sendBackNoAccessResponse(response); } }
HostBasedUrlAccessSecurityFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (hostValidatorService.isRequestFromAdmin(request)) { chain.doFilter(request, response); } else { if (request instanceof HttpServletRequest) { logger.info(urlAccessLogMessageAssembler.assembleDenyMessage((HttpServletRequest) request)); } sendBackNoAccessResponse(response); } } }
HostBasedUrlAccessSecurityFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (hostValidatorService.isRequestFromAdmin(request)) { chain.doFilter(request, response); } else { if (request instanceof HttpServletRequest) { logger.info(urlAccessLogMessageAssembler.assembleDenyMessage((HttpServletRequest) request)); } sendBackNoAccessResponse(response); } }  }
HostBasedUrlAccessSecurityFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (hostValidatorService.isRequestFromAdmin(request)) { chain.doFilter(request, response); } else { if (request instanceof HttpServletRequest) { logger.info(urlAccessLogMessageAssembler.assembleDenyMessage((HttpServletRequest) request)); } sendBackNoAccessResponse(response); } }  @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); @Override void destroy(); }
HostBasedUrlAccessSecurityFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (hostValidatorService.isRequestFromAdmin(request)) { chain.doFilter(request, response); } else { if (request instanceof HttpServletRequest) { logger.info(urlAccessLogMessageAssembler.assembleDenyMessage((HttpServletRequest) request)); } sendBackNoAccessResponse(response); } }  @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); @Override void destroy();  }