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-7443] Updating transport-level Headers to work with List of Objects
Date Thu, 13 Jul 2017 11:14:54 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 28aa1248b -> 4da186672


[CXF-7443] Updating transport-level Headers to work with List of Objects


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

Branch: refs/heads/master
Commit: 4da18667296504ca698c392608e3f48062a4a53b
Parents: 28aa124
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Jul 13 12:14:37 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Jul 13 12:14:37 2017 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/transport/http/Headers.java  | 21 +++++++++++---------
 .../apache/cxf/transport/http/HeadersTest.java  |  4 ++--
 2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4da18667/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
index 47d4b73..1ec9b0c 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
@@ -72,7 +72,7 @@ public class Headers {
     private static final Logger LOG = LogUtils.getL7dLogger(Headers.class);
 
     private static final List<String> SENSITIVE_HEADERS = Arrays.asList("Authorization",
"Proxy-Authorization");
-    private static final List<String> SENSITIVE_HEADER_MARKER = Arrays.asList("***");
+    private static final List<Object> SENSITIVE_HEADER_MARKER = Arrays.asList("***");
     private static final String ALLOW_LOGGING_SENSITIVE_HEADERS = "allow.logging.sensitive.headers";
     /**
      * Known HTTP headers whose values have to be represented as individual HTTP headers
@@ -119,8 +119,8 @@ public class Headers {
      * filtered keys), so it should be used sparingly - i.e. only when debug is
      * enabled.
      */
-    static String toString(Map<String, List<String>> headers, boolean logSensitiveHeaders)
{
-        Map<String, List<String>> filteredHeaders = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
+    static String toString(Map<String, List<Object>> headers, boolean logSensitiveHeaders)
{
+        Map<String, List<Object>> filteredHeaders = new TreeMap<String, List<Object>>(String.CASE_INSENSITIVE_ORDER);
         filteredHeaders.putAll(headers);
         if (!logSensitiveHeaders) {
             for (String filteredKey : SENSITIVE_HEADERS) {
@@ -312,14 +312,14 @@ public class Headers {
      * @param headers The Message protocol headers.
      */
     static void logProtocolHeaders(Logger logger, Level level,
-                                   Map<String, List<String>> headersMap,
+                                   Map<String, List<Object>> headersMap,
                                    boolean logSensitiveHeaders) {
         if (logger.isLoggable(level)) {
-            for (Map.Entry<String, List<String>> entry : headersMap.entrySet())
{
+            for (Map.Entry<String, List<Object>> entry : headersMap.entrySet())
{
                 String key = entry.getKey();
                 boolean sensitive = !logSensitiveHeaders && SENSITIVE_HEADERS.contains(key);
-                List<String> headerList = sensitive ? SENSITIVE_HEADER_MARKER : entry.getValue();
-                for (String value : headerList) {
+                List<Object> headerList = sensitive ? SENSITIVE_HEADER_MARKER : entry.getValue();
+                for (Object value : headerList) {
                     logger.log(level, key + ": "
                         + (value == null ? "<null>" : value.toString()));
                 }
@@ -367,7 +367,9 @@ public class Headers {
         }
 
         transferProtocolHeadersToURLConnection(connection);
-        logProtocolHeaders(LOG, Level.FINE, headers, logSensitiveHeaders());
+        
+        Map<String, List<Object>> theHeaders = CastUtils.cast(headers);
+        logProtocolHeaders(LOG, Level.FINE, theHeaders, logSensitiveHeaders());
     }
 
     public String determineContentType() {
@@ -456,7 +458,8 @@ public class Headers {
             headers.put(Message.CONTENT_TYPE, Collections.singletonList(req.getContentType()));
         }
         if (LOG.isLoggable(Level.FINE)) {
-            LOG.log(Level.FINE, "Request Headers: " + toString(headers,
+            Map<String, List<Object>> theHeaders = CastUtils.cast(headers);
+            LOG.log(Level.FINE, "Request Headers: " + toString(theHeaders,
                                                                logSensitiveHeaders()));
         }
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4da18667/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HeadersTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HeadersTest.java
b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HeadersTest.java
index 88f7f27..bc86dda 100755
--- a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HeadersTest.java
+++ b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HeadersTest.java
@@ -95,7 +95,7 @@ public class HeadersTest extends Assert {
 
     @Test
     public void sensitiveHeadersTest() {
-        Map<String, List<String>> headerMap = new HashMap<>();
+        Map<String, List<Object>> headerMap = new HashMap<>();
         headerMap.put("Authorization", Arrays.asList("FAIL"));
         headerMap.put("Proxy-Authorization", Arrays.asList("FAIL"));
         headerMap.put("Content-Type", Arrays.asList("application/xml"));
@@ -112,7 +112,7 @@ public class HeadersTest extends Assert {
 
     @Test
     public void logProtocolHeadersTest() {
-        Map<String, List<String>> headerMap = new HashMap<>();
+        Map<String, List<Object>> headerMap = new HashMap<>();
         headerMap.put("Normal-Header", Arrays.asList("normal"));
         headerMap.put("Multivalue-Header", Arrays.asList("first", "second"));
         headerMap.put("Authorization", Arrays.asList("myPassword"));


Mime
View raw message