From c03d7c798025d7d433b4fafbcba9ec4e1d0d3673 Mon Sep 17 00:00:00 2001 From: Xu Huisheng Date: Tue, 4 Aug 2015 18:20:31 +0800 Subject: [PATCH] When serverName contains schema, the URIBuilder will throw an UnsupportedOperationException while adding a parameter. --- .../java/org/jasig/cas/client/util/URIBuilder.java | 2 +- .../jasig/cas/client/util/CommonUtilsTests.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/util/URIBuilder.java b/cas-client-core/src/main/java/org/jasig/cas/client/util/URIBuilder.java index ef0db52..f57499d 100644 --- a/cas-client-core/src/main/java/org/jasig/cas/client/util/URIBuilder.java +++ b/cas-client-core/src/main/java/org/jasig/cas/client/util/URIBuilder.java @@ -126,7 +126,7 @@ public final class URIBuilder { } catch (final UnsupportedEncodingException e) { LOGGER.error(e.getMessage(), e); } - return Collections.emptyList(); + return new ArrayList(); } /** diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/util/CommonUtilsTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/util/CommonUtilsTests.java index aaac4e6..8ec0541 100644 --- a/cas-client-core/src/test/java/org/jasig/cas/client/util/CommonUtilsTests.java +++ b/cas-client-core/src/test/java/org/jasig/cas/client/util/CommonUtilsTests.java @@ -152,6 +152,20 @@ public final class CommonUtilsTests extends TestCase { assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl); } + public void testConstructServiceUrlWithParamsCasAndServerNameWithSchema() { + final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/"; + final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); + request.setScheme("https"); + request.setSecure(true); + request.setQueryString("service=this&ticket=that&custom=custom"); + + final MockHttpServletResponse response = new MockHttpServletResponse(); + final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "https://www.myserver.com", + Protocol.CAS3.getServiceParameterName(), Protocol.CAS3.getArtifactParameterName() , false); + + assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl); + } + public void testConstructServiceUrlWithParamsSaml() { final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";