@Test public void mustAllowSecurePortRequests() throws Exception { SecurityFilter filter = new SecurityFilter(); MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletRequest request = this.getDefaultRequest(); request.setServerPort(8441); request.setLocalPort(8441); request.setRequestURI("/certs/"); MockFilterChain chain = new MockFilterChain(); filter.doFilter(request, response, chain); assertEquals(request, chain.getRequest()); assertEquals(response, chain.getResponse()); }
@Override public void doFilter(ServletRequest serReq, ServletResponse serResp, FilterChain filtCh) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) serReq; String reqUrl = req.getRequestURL().toString(); LOG.debug("Filtering " + reqUrl + " for security purposes"); if (serReq.getLocalPort() != config.getTwoWayAuthPort()) { if (isRequestAllowed(reqUrl)) { filtCh.doFilter(serReq, serResp); } else { LOG.warn("This request is not allowed on this port: " + reqUrl); } } else { LOG.debug("Request can continue on secure port " + serReq.getLocalPort()); filtCh.doFilter(serReq, serResp); } }
SecurityFilter implements Filter { @Override public void doFilter(ServletRequest serReq, ServletResponse serResp, FilterChain filtCh) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) serReq; String reqUrl = req.getRequestURL().toString(); LOG.debug("Filtering " + reqUrl + " for security purposes"); if (serReq.getLocalPort() != config.getTwoWayAuthPort()) { if (isRequestAllowed(reqUrl)) { filtCh.doFilter(serReq, serResp); } else { LOG.warn("This request is not allowed on this port: " + reqUrl); } } else { LOG.debug("Request can continue on secure port " + serReq.getLocalPort()); filtCh.doFilter(serReq, serResp); } } }
SecurityFilter implements Filter { @Override public void doFilter(ServletRequest serReq, ServletResponse serResp, FilterChain filtCh) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) serReq; String reqUrl = req.getRequestURL().toString(); LOG.debug("Filtering " + reqUrl + " for security purposes"); if (serReq.getLocalPort() != config.getTwoWayAuthPort()) { if (isRequestAllowed(reqUrl)) { filtCh.doFilter(serReq, serResp); } else { LOG.warn("This request is not allowed on this port: " + reqUrl); } } else { LOG.debug("Request can continue on secure port " + serReq.getLocalPort()); filtCh.doFilter(serReq, serResp); } }  }
SecurityFilter implements Filter { @Override public void doFilter(ServletRequest serReq, ServletResponse serResp, FilterChain filtCh) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) serReq; String reqUrl = req.getRequestURL().toString(); LOG.debug("Filtering " + reqUrl + " for security purposes"); if (serReq.getLocalPort() != config.getTwoWayAuthPort()) { if (isRequestAllowed(reqUrl)) { filtCh.doFilter(serReq, serResp); } else { LOG.warn("This request is not allowed on this port: " + reqUrl); } } else { LOG.debug("Request can continue on secure port " + serReq.getLocalPort()); filtCh.doFilter(serReq, serResp); } }  @Override void destroy(); @Override void doFilter(ServletRequest serReq, ServletResponse serResp,
		FilterChain filtCh); @Override void init(FilterConfig arg0); static void init(Configuration instance); }
SecurityFilter implements Filter { @Override public void doFilter(ServletRequest serReq, ServletResponse serResp, FilterChain filtCh) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) serReq; String reqUrl = req.getRequestURL().toString(); LOG.debug("Filtering " + reqUrl + " for security purposes"); if (serReq.getLocalPort() != config.getTwoWayAuthPort()) { if (isRequestAllowed(reqUrl)) { filtCh.doFilter(serReq, serResp); } else { LOG.warn("This request is not allowed on this port: " + reqUrl); } } else { LOG.debug("Request can continue on secure port " + serReq.getLocalPort()); filtCh.doFilter(serReq, serResp); } }  @Override void destroy(); @Override void doFilter(ServletRequest serReq, ServletResponse serResp,
		FilterChain filtCh); @Override void init(FilterConfig arg0); static void init(Configuration instance);  }