cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6492] Support for Basic scheme with more than a single space between it and the encoded user/password
Date Wed, 24 Feb 2016 13:04:37 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 6b4d8e853 -> 322cc86ff


[CXF-6492] Support for Basic scheme with more than a single space between it and the encoded
user/password


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/322cc86f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/322cc86f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/322cc86f

Branch: refs/heads/3.0.x-fixes
Commit: 322cc86ff0bc34d22cdf33017f8f460069c76ed5
Parents: 6b4d8e8
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Feb 24 13:01:08 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Feb 24 13:04:23 2016 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/common/util/StringUtils.java   |  4 ++--
 .../apache/cxf/common/util/StringUtilsTest.java   | 18 ++++++++++++++++++
 .../transport/http/AbstractHTTPDestination.java   |  9 +++++----
 3 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/322cc86f/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
index b4f7a8c..9fe3726 100644
--- a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
@@ -93,8 +93,8 @@ public final class StringUtils {
     }
     
     public static List<String> getParts(String str, String separator) {
-        List<String> ret = new ArrayList<String>();
-        List<String> parts = Arrays.asList(split(str, separator));
+        String[] parts = split(str, separator);
+        List<String> ret = new ArrayList<String>(parts.length);
         for (String part : parts) {
             if (!isEmpty(part)) {
                 ret.add(part);

http://git-wip-us.apache.org/repos/asf/cxf/blob/322cc86f/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java b/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
index 1e38c3a..7480135 100644
--- a/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
@@ -53,6 +53,24 @@ public class StringUtilsTest extends Assert {
     }
     
     @Test
+    public void testGetPartsWithSingleSpace() throws Exception {
+        String str = "a b";
+        List<String> parts = StringUtils.getParts(str, " ");
+        assertEquals(2, parts.size());
+        assertEquals("a", parts.get(0));
+        assertEquals("b", parts.get(1));
+    }
+    
+    @Test
+    public void testGetPartsWithManySpaces() throws Exception {
+        String str = "a  b";
+        List<String> parts = StringUtils.getParts(str, " ");
+        assertEquals(2, parts.size());
+        assertEquals("a", parts.get(0));
+        assertEquals("b", parts.get(1));
+    }
+    
+    @Test
     public void testSplitWithDot() throws Exception {
         String str = "a.b.c";
         String[] parts = StringUtils.split(str, "\\.", -1);

http://git-wip-us.apache.org/repos/asf/cxf/blob/322cc86f/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
index 65e5ad5..92a4866 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
@@ -28,6 +28,7 @@ import java.net.URL;
 import java.security.Principal;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -161,10 +162,10 @@ public abstract class AbstractHTTPDestination
         if (credentials == null || StringUtils.isEmpty(credentials.trim())) {
             return null;
         }
-        String creds[] = StringUtils.split(credentials, " ");
-        String authType = creds[0];
-        if ("Basic".equals(authType)) {
-            String authEncoded = creds[1];
+        List<String> creds = StringUtils.getParts(credentials, " ");
+        String authType = creds.get(0);
+        if ("Basic".equals(authType) && creds.size() == 2) {
+            String authEncoded = creds.get(1);
             try {
                 String authDecoded = new String(Base64Utility.decode(authEncoded));
                 int idx = authDecoded.indexOf(':');


Mime
View raw message