knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject [07/37] knox git commit: KNOX-1061 - KnoxSSO Redirects with Query Params in the OriginalUrl Broken
Date Thu, 26 Oct 2017 14:22:43 GMT
KNOX-1061 - KnoxSSO Redirects with Query Params in the OriginalUrl Broken

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/3a0119b2
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/3a0119b2
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/3a0119b2

Branch: refs/heads/KNOX-1049
Commit: 3a0119b217bb71d107b335c27abac77847b2bfe4
Parents: 5432c87
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Fri Sep 22 17:30:13 2017 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Fri Sep 22 17:30:13 2017 -0400

----------------------------------------------------------------------
 ...entityAsserterHttpServletRequestWrapper.java | 25 +++++++++++++-------
 .../apache/hadoop/gateway/util/HttpUtils.java   |  7 +++---
 2 files changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/3a0119b2/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
b/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
index 961fef7..dfce6cd 100644
--- a/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
+++ b/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
@@ -71,21 +71,30 @@ private static SpiGatewayMessages log = MessagesFactory.get( SpiGatewayMessages.
     return super.getParameter(name);
   }
   
-  @SuppressWarnings("rawtypes")
   @Override
-  public Map getParameterMap() {
-    Map map = null;
+  public Map<String, String[]> getParameterMap() {
+    Map<String, String[]> map = null;
     try {
-      map = getParams();
+      map = convertValuesToStringArrays(getParams());
     } catch (UnsupportedEncodingException e) {
       log.unableToGetParamsFromQueryString(e);
     }
     return map;
   }
 
-  @SuppressWarnings({ "unchecked", "rawtypes" })
+  private Map<String, String[]> convertValuesToStringArrays(Map<String, List<String>>
params) {
+    Map<String, String[]> arrayMap = new HashMap<String, String[]>();
+    String name = null;
+    Enumeration<String> names = getParameterNames();
+    while (names.hasMoreElements()) {
+      name = (String) names.nextElement();
+      arrayMap.put(name, getParameterValues(name));
+    }
+    return arrayMap;
+  }
+
   @Override
-  public Enumeration getParameterNames() {
+  public Enumeration<String> getParameterNames() {
     Enumeration<String> e = null;
     Map<String, List<String>> params;
     try {
@@ -103,14 +112,14 @@ private static SpiGatewayMessages log = MessagesFactory.get( SpiGatewayMessages.
 
   @Override
   public String[] getParameterValues(String name) {
-    String[] p = null;
+    String[] p = {};
     Map<String, List<String>> params;
     try {
       params = getParams();
       if (params == null) {
         params = new HashMap<>();
       }
-      p = (String[]) params.get(name).toArray();
+      p = (String[]) params.get(name).toArray(p);
     } catch (UnsupportedEncodingException e) {
       log.unableToGetParamsFromQueryString(e);
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/3a0119b2/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/HttpUtils.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/HttpUtils.java
b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/HttpUtils.java
index 7f5e96a..2b2d0eb 100644
--- a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/HttpUtils.java
+++ b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/HttpUtils.java
@@ -20,10 +20,9 @@ package org.apache.hadoop.gateway.util;
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -32,7 +31,7 @@ public class HttpUtils {
 
   public static Map<String, List<String>> splitQuery(String queryString)
       throws UnsupportedEncodingException {
-    final Map<String, List<String>> queryPairs = new LinkedHashMap<String,
List<String>>();
+    final Map<String, List<String>> queryPairs = new HashMap<String, List<String>>();
     if (queryString == null || queryString.trim().isEmpty()) {
       return queryPairs;
     }
@@ -41,7 +40,7 @@ public class HttpUtils {
       final int idx = pair.indexOf("=");
       final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8")
: pair;
       if (!queryPairs.containsKey(key)) {
-        queryPairs.put(key, new LinkedList<String>());
+        queryPairs.put(key, new ArrayList<String>());
       }
       final String value = idx > 0 && pair.length() > idx + 1 
           ? URLDecoder.decode(pair.substring(idx + 1), "UTF-8") : "";


Mime
View raw message