ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbhowm...@apache.org
Subject 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)
Date Sat, 29 Apr 2017 17:46:32 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 4d59c595a -> 7d3435e36


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/7d3435e3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7d3435e3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7d3435e3

Branch: refs/heads/trunk
Commit: 7d3435e36724adba270e222d074ca273e43d66b1
Parents: 4d59c59
Author: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Authored: Sat Apr 29 23:15:08 2017 +0530
Committer: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Committed: Sat Apr 29 23:16:12 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/7d3435e3/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 {


Mime
View raw message