You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by kr...@apache.org on 2018/09/27 17:31:52 UTC
knox git commit: KNOX-1468 - Remove explicit guava dependency from
gateway-service-nifi
Repository: knox
Updated Branches:
refs/heads/master c0f52c201 -> c4f946382
KNOX-1468 - Remove explicit guava dependency from gateway-service-nifi
Signed-off-by: Kevin Risden <kr...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/c4f94638
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/c4f94638
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/c4f94638
Branch: refs/heads/master
Commit: c4f946382a96478d4fc1a232b75d5bda6a3e4ed3
Parents: c0f52c2
Author: Kevin Risden <kr...@apache.org>
Authored: Thu Sep 27 12:36:41 2018 -0400
Committer: Kevin Risden <kr...@apache.org>
Committed: Thu Sep 27 13:31:31 2018 -0400
----------------------------------------------------------------------
.../org/apache/knox/gateway/dispatch/NiFiRequestUtil.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/knox/blob/c4f94638/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
----------------------------------------------------------------------
diff --git a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
index ac5de7a..585f2c9 100644
--- a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
+++ b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
@@ -17,8 +17,6 @@
*/
package org.apache.knox.gateway.dispatch;
-import com.google.common.base.Objects;
-import com.google.common.base.Strings;
import org.apache.commons.lang.StringUtils;
import org.apache.http.Header;
import org.apache.http.client.methods.HttpUriRequest;
@@ -45,7 +43,7 @@ class NiFiRequestUtil {
final Header originalXForwardedContextHeader = outboundRequest.getFirstHeader(NiFiHeaders.X_FORWARDED_CONTEXT);
if (originalXForwardedContextHeader != null) {
String xForwardedContextHeaderValue = originalXForwardedContextHeader.getValue();
- if (!Strings.isNullOrEmpty(xForwardedContextHeaderValue)) {
+ if (xForwardedContextHeaderValue != null && !xForwardedContextHeaderValue.isEmpty()) {
// Inspect the inbound request and outbound request to determine the additional context path from the rewrite
// rules that needs to be added to the X-Forwarded-Context header to allow proper proxying to NiFi.
//
@@ -75,7 +73,11 @@ class NiFiRequestUtil {
// as empty angle brackets "<>".
final Subject subject = SubjectUtils.getCurrentSubject();
String effectivePrincipalName = SubjectUtils.getEffectivePrincipalName(subject);
- outboundRequest.setHeader(NiFiHeaders.X_PROXIED_ENTITIES_CHAIN, Objects.firstNonNull(inboundRequest.getHeader(NiFiHeaders.X_PROXIED_ENTITIES_CHAIN), "") +
+ String proxiedEntitesChainHeader = inboundRequest.getHeader(NiFiHeaders.X_PROXIED_ENTITIES_CHAIN);
+ if(proxiedEntitesChainHeader == null) {
+ proxiedEntitesChainHeader = "";
+ }
+ outboundRequest.setHeader(NiFiHeaders.X_PROXIED_ENTITIES_CHAIN, proxiedEntitesChainHeader +
String.format(Locale.ROOT, "<%s>", effectivePrincipalName.equalsIgnoreCase("anonymous") ? "" : effectivePrincipalName));
// Make sure headers named "Cookie" are removed from the request to NiFi, since NiFi does not use cookies.