diff --git a/core/src/main/java/org/acegisecurity/intercept/web/FilterInvocation.java b/core/src/main/java/org/acegisecurity/intercept/web/FilterInvocation.java index 8da6bb1ab0..40ccf4f84b 100644 --- a/core/src/main/java/org/acegisecurity/intercept/web/FilterInvocation.java +++ b/core/src/main/java/org/acegisecurity/intercept/web/FilterInvocation.java @@ -101,10 +101,11 @@ public class FilterInvocation { } public String getRequestUrl() { - return getHttpRequest().getServletPath() - + ((getHttpRequest().getQueryString() == null) ? "" - : ("?" - + getHttpRequest().getQueryString())); + String pathInfo = getHttpRequest().getPathInfo(); + String queryString = getHttpRequest().getQueryString(); + + return getHttpRequest().getServletPath() + (pathInfo == null ? "" : pathInfo) + + (queryString == null ? "" : ("?" + queryString)); } public ServletResponse getResponse() { diff --git a/core/src/test/java/org/acegisecurity/MockHttpServletRequest.java b/core/src/test/java/org/acegisecurity/MockHttpServletRequest.java index c06baea30d..009a7d93ed 100644 --- a/core/src/test/java/org/acegisecurity/MockHttpServletRequest.java +++ b/core/src/test/java/org/acegisecurity/MockHttpServletRequest.java @@ -59,6 +59,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private String serverName; private String servletPath; private int serverPort; + private String pathInfo; // null for no extra path //~ Constructors =========================================================== @@ -196,8 +197,13 @@ public class MockHttpServletRequest implements HttpServletRequest { throw new UnsupportedOperationException("mock method not implemented"); } + + public void setPathInfo(String pathInfo) { + this.pathInfo = pathInfo; + } + public String getPathInfo() { - throw new UnsupportedOperationException("mock method not implemented"); + return pathInfo; } public String getPathTranslated() { @@ -240,8 +246,8 @@ public class MockHttpServletRequest implements HttpServletRequest { throw new UnsupportedOperationException("mock method not implemented"); } - public void setRequestURL(String newRequestURL) { - requestURL = newRequestURL; + public void setRequestURL(String requestURL) { + this.requestURL = requestURL; } public StringBuffer getRequestURL() { @@ -268,8 +274,8 @@ public class MockHttpServletRequest implements HttpServletRequest { throw new UnsupportedOperationException("mock method not implemented"); } - public void setScheme(String newScheme) { - scheme = newScheme; + public void setScheme(String scheme) { + this.scheme = scheme; } public String getScheme() { @@ -280,16 +286,16 @@ public class MockHttpServletRequest implements HttpServletRequest { throw new UnsupportedOperationException("mock method not implemented"); } - public void setServerName(String newServerName) { - serverName = newServerName; + public void setServerName(String serverName) { + this.serverName = serverName; } public String getServerName() { return serverName; } - public void setServerPort(int newPort) { - serverPort = newPort; + public void setServerPort(int serverPort) { + this.serverPort = serverPort; } public int getServerPort() { diff --git a/core/src/test/java/org/acegisecurity/intercept/web/FilterInvocationTests.java b/core/src/test/java/org/acegisecurity/intercept/web/FilterInvocationTests.java index 44d86ac720..9f3a0c6e6c 100644 --- a/core/src/test/java/org/acegisecurity/intercept/web/FilterInvocationTests.java +++ b/core/src/test/java/org/acegisecurity/intercept/web/FilterInvocationTests.java @@ -68,7 +68,8 @@ public class FilterInvocationTests extends TestCase { public void testGettersAndStringMethods() { MockHttpServletRequest request = new MockHttpServletRequest(null, null); request.setServletPath("/HelloWorld"); - request.setRequestURL("http://www.example.com/mycontext/HelloWorld"); + request.setPathInfo("/some/more/segments.html"); + request.setRequestURL("http://www.example.com/mycontext/HelloWorld/some/more/segments.html"); MockHttpServletResponse response = new MockHttpServletResponse(); MockFilterChain chain = new MockFilterChain(); @@ -78,9 +79,9 @@ public class FilterInvocationTests extends TestCase { assertEquals(response, fi.getResponse()); assertEquals(response, fi.getHttpResponse()); assertEquals(chain, fi.getChain()); - assertEquals("/HelloWorld", fi.getRequestUrl()); - assertEquals("FilterInvocation: URL: /HelloWorld", fi.toString()); - assertEquals("http://www.example.com/mycontext/HelloWorld", + assertEquals("/HelloWorld/some/more/segments.html", fi.getRequestUrl()); + assertEquals("FilterInvocation: URL: /HelloWorld/some/more/segments.html", fi.toString()); + assertEquals("http://www.example.com/mycontext/HelloWorld/some/more/segments.html", fi.getFullRequestUrl()); }