From f4d6f49d2f4cbc248e18f59423465c7b8cb200ad Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 6 May 2015 14:32:06 +1000 Subject: [PATCH] 466329 Fixed local only TestFilter --- .../src/main/java/com/acme/TestFilter.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java index 4456c258173..95721c75240 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java +++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java @@ -64,6 +64,7 @@ public class TestFilter implements Filter _remote=Boolean.parseBoolean(filterConfig.getInitParameter("remote")); _allowed.add("/favicon.ico"); _allowed.add("/jetty_banner.gif"); + _allowed.add("/remote.html"); LOG.debug("TestFilter#remote="+_remote); } @@ -76,18 +77,13 @@ public class TestFilter implements Filter public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - String from = request.getRemoteHost(); - String to = request.getServerName(); + String from = request.getRemoteAddr(); + String to = request.getLocalAddr(); String path=((HttpServletRequest)request).getServletPath(); - - if (!"/remote.html".equals(path) && !_remote && !_allowed.contains(path) && ( - !from.equals("localhost") && !from.startsWith("127.") && from.indexOf(":1")<0 || - !to.equals("localhost")&&!to.startsWith("127.0.0.") && to.indexOf(":1")<0)) + + if (!_remote && !_allowed.contains(path) && !from.equals(to)) { - if ("/".equals(path)) - _context.getRequestDispatcher("/remote.html").forward(request,response); - else - ((HttpServletResponse)response).sendRedirect("/remote.html"); + _context.getRequestDispatcher("/remote.html").forward(request,response); return; }