You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by db...@apache.org on 2017/04/29 17:45:25 UTC
ambari git commit: AMBARI-20722. Ranger authorizations tab prompts
for Hive Authentication password if admin credentials are incorrect in Hive
View 2.0 config. (dipayanb)
Repository: ambari
Updated Branches:
refs/heads/branch-2.5 9339282a1 -> ffee064a8
AMBARI-20722. Ranger authorizations tab prompts for Hive Authentication password if admin credentials are incorrect in Hive View 2.0 config. (dipayanb)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ffee064a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ffee064a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ffee064a
Branch: refs/heads/branch-2.5
Commit: ffee064a87a5540e9f174bd99401eddcd637e67c
Parents: 9339282
Author: Dipayan Bhowmick <di...@gmail.com>
Authored: Sat Apr 29 23:15:08 2017 +0530
Committer: Dipayan Bhowmick <di...@gmail.com>
Committed: Sat Apr 29 23:15:08 2017 +0530
----------------------------------------------------------------------
.../view/hive20/resources/system/ranger/RangerService.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/ffee064a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
index 816d0e0..6c68b2f 100644
--- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
+++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/resources/system/ranger/RangerService.java
@@ -33,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
+import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -119,7 +120,9 @@ public class RangerService {
if (parsedResult instanceof JSONObject) {
JSONObject obj = (JSONObject) parsedResult;
LOG.error("Bad response from Ranger: {}", rangerResponse);
- throw new RangerException((String)obj.get("msgDesc"), "RANGER_ERROR", ((Long)obj.get("statusCode")).intValue());
+ int status = ((Long) obj.get("statusCode")).intValue();
+ status = status == Response.Status.UNAUTHORIZED.getStatusCode() ? Response.Status.FORBIDDEN.getStatusCode() : status;
+ throw new RangerException((String) obj.get("msgDesc"), "RANGER_ERROR", status);
}
JSONArray jsonArray = (JSONArray) parsedResult;
if (jsonArray.size() == 0) {
@@ -143,7 +146,7 @@ public class RangerService {
JSONArray policyItems = (JSONArray) policyJson.get("policyItems");
Policy policy = new Policy(name);
- for(Object item: policyItems) {
+ for (Object item : policyItems) {
PolicyCondition condition = new PolicyCondition();
JSONObject policyItem = (JSONObject) item;
JSONArray usersJson = (JSONArray) policyItem.get("users");
@@ -239,7 +242,7 @@ public class RangerService {
private RangerCred getRangerCredFromConfig() {
return new RangerCred(context.getProperties().get("hive.ranger.username"),
- context.getProperties().get("hive.ranger.password"));
+ context.getProperties().get("hive.ranger.password"));
}
public String getRangerUrlFromAmbari() throws AmbariHttpException {