sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject sentry git commit: SENTRY-2145 - Some misc code cleanups. Colm O hEigeartaigh, reviewed by Sergio Pena.
Date Wed, 28 Mar 2018 15:59:50 GMT
Repository: sentry
Updated Branches:
  refs/heads/master 51c02fa24 -> 4e2009104


SENTRY-2145 - Some misc code cleanups. Colm O hEigeartaigh, reviewed by Sergio Pena.


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

Branch: refs/heads/master
Commit: 4e2009104cf6bdc65b7ddd27e35ed5068f7b3d21
Parents: 51c02fa
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Mar 28 16:59:10 2018 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Mar 28 16:59:10 2018 +0100

----------------------------------------------------------------------
 .../binding/hive/authz/DefaultSentryValidator.java    |  9 +++++----
 .../apache/sentry/kafka/binding/KafkaAuthBinding.java |  6 +++---
 .../apache/sentry/core/model/solr/AdminOperation.java | 14 +++++++-------
 sentry-dist/src/license/THIRD-PARTY.properties        |  3 ++-
 4 files changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/4e200910/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/authz/DefaultSentryValidator.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/authz/DefaultSentryValidator.java
b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/authz/DefaultSentryValidator.java
index 319a1be..1ab5be3 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/authz/DefaultSentryValidator.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/authz/DefaultSentryValidator.java
@@ -201,19 +201,20 @@ public class DefaultSentryValidator extends SentryHiveAuthorizationValidator
{
           }
         }
       }
-      String permsRequired = "";
       SentryOnFailureHookContext hookCtx =
           new SentryOnFailureHookContextImpl(context.getCommandString(), null, null, hiveOp,
db,
               tab, Collections.<AccessURI>emptyList(), null,
                   authenticator.getUserName(), context.getIpAddress(), e, authzConf);
       SentryAuthorizerUtil.executeOnFailureHooks(hookCtx, authzConf);
+      StringBuilder permsRequired = new StringBuilder();
       for (String perm : hiveAuthzBinding.getLastQueryPrivilegeErrors()) {
-        permsRequired += perm + ";";
+        permsRequired.append(perm).append(";");
       }
-      SessionState.get().getConf().set(HiveAuthzConf.HIVE_SENTRY_AUTH_ERRORS, permsRequired);
+      String permsRequiredStr = permsRequired.toString();
+      SessionState.get().getConf().set(HiveAuthzConf.HIVE_SENTRY_AUTH_ERRORS, permsRequiredStr);
       String msg =
           HiveAuthzConf.HIVE_SENTRY_PRIVILEGE_ERROR_MESSAGE
-              + "\n Required privileges for this query: " + permsRequired;
+              + "\n Required privileges for this query: " + permsRequiredStr;
       throw new HiveAccessControlException(msg, e);
     } catch (Exception e) {
       throw new HiveAuthzPluginException(e.getClass()+ ": " + e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/sentry/blob/4e200910/sentry-binding/sentry-binding-kafka/src/main/java/org/apache/sentry/kafka/binding/KafkaAuthBinding.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-kafka/src/main/java/org/apache/sentry/kafka/binding/KafkaAuthBinding.java
b/sentry-binding/sentry-binding-kafka/src/main/java/org/apache/sentry/kafka/binding/KafkaAuthBinding.java
index 908c80f..e4abdc7 100644
--- a/sentry-binding/sentry-binding-kafka/src/main/java/org/apache/sentry/kafka/binding/KafkaAuthBinding.java
+++ b/sentry-binding/sentry-binding-kafka/src/main/java/org/apache/sentry/kafka/binding/KafkaAuthBinding.java
@@ -465,8 +465,8 @@ public class KafkaAuthBinding {
 
   private java.util.Map<Resource, scala.collection.immutable.Set<Acl>> rolePrivilegesToResourceAcls(java.util.Map<String,
scala.collection.immutable.Set<TSentryPrivilege>> rolePrivilegesMap) {
     final java.util.Map<Resource, scala.collection.immutable.Set<Acl>> resourceAclsMap
= new HashMap<>();
-    for (String role : rolePrivilegesMap.keySet()) {
-      scala.collection.immutable.Set<TSentryPrivilege> privileges = rolePrivilegesMap.get(role);
+    for (java.util.Map.Entry<String, scala.collection.immutable.Set<TSentryPrivilege>>
rolePrivilege : rolePrivilegesMap.entrySet()) {
+      scala.collection.immutable.Set<TSentryPrivilege> privileges = rolePrivilege.getValue();
       final Iterator<TSentryPrivilege> iterator = privileges.iterator();
       while (iterator.hasNext()) {
         TSentryPrivilege privilege = iterator.next();
@@ -481,7 +481,7 @@ public class KafkaAuthBinding {
             if (operation.equals("*")) {
               operation = "All";
             }
-            Acl acl = new Acl(new KafkaPrincipal("role", role), Allow$.MODULE$, host, Operation$.MODULE$.fromString(operation));
+            Acl acl = new Acl(new KafkaPrincipal("role", rolePrivilege.getKey()), Allow$.MODULE$,
host, Operation$.MODULE$.fromString(operation));
             Set<Acl> newAclsJava = new HashSet<Acl>();
             newAclsJava.add(acl);
             addExistingAclsForResource(resourceAclsMap, resource, newAclsJava);

http://git-wip-us.apache.org/repos/asf/sentry/blob/4e200910/sentry-core/sentry-core-model-solr/src/main/java/org/apache/sentry/core/model/solr/AdminOperation.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-solr/src/main/java/org/apache/sentry/core/model/solr/AdminOperation.java
b/sentry-core/sentry-core-model-solr/src/main/java/org/apache/sentry/core/model/solr/AdminOperation.java
index c054b7d..005d26c 100644
--- a/sentry-core/sentry-core-model-solr/src/main/java/org/apache/sentry/core/model/solr/AdminOperation.java
+++ b/sentry-core/sentry-core-model-solr/src/main/java/org/apache/sentry/core/model/solr/AdminOperation.java
@@ -26,15 +26,15 @@ import java.util.Collection;
  * - Solr auto-scaling operations
  */
 public class AdminOperation extends SolrModelAuthorizable {
-  public static Collection<String> ENTITY_NAMES =
+  public static final Collection<String> ENTITY_NAMES =
       Arrays.asList(SolrConstants.ALL, "collections", "cores", "security", "metrics", "autoscaling");
 
-  public static AdminOperation ALL = new AdminOperation(SolrConstants.ALL);
-  public static AdminOperation COLLECTIONS = new AdminOperation("collections");
-  public static AdminOperation CORES = new AdminOperation("cores");
-  public static AdminOperation SECURITY = new AdminOperation("security");
-  public static AdminOperation METRICS = new AdminOperation("metrics");
-  public static AdminOperation AUTOSCALING = new AdminOperation("autoscaling");
+  public static final AdminOperation ALL = new AdminOperation(SolrConstants.ALL);
+  public static final AdminOperation COLLECTIONS = new AdminOperation("collections");
+  public static final AdminOperation CORES = new AdminOperation("cores");
+  public static final AdminOperation SECURITY = new AdminOperation("security");
+  public static final AdminOperation METRICS = new AdminOperation("metrics");
+  public static final AdminOperation AUTOSCALING = new AdminOperation("autoscaling");
 
   public AdminOperation (String name) {
     super (AuthorizableType.Admin, name);

http://git-wip-us.apache.org/repos/asf/sentry/blob/4e200910/sentry-dist/src/license/THIRD-PARTY.properties
----------------------------------------------------------------------
diff --git a/sentry-dist/src/license/THIRD-PARTY.properties b/sentry-dist/src/license/THIRD-PARTY.properties
index 7226acd..2f9f0b0 100644
--- a/sentry-dist/src/license/THIRD-PARTY.properties
+++ b/sentry-dist/src/license/THIRD-PARTY.properties
@@ -19,6 +19,7 @@
 # - MIT License
 # - Mozilla Public License Version 1.1
 # - Public Domain
+# - The Apache License, Version 2.0
 # - The Apache Software License, Version 1.1
 # - The Apache Software License, Version 2.0
 # - The BSD 3-Clause License
@@ -27,7 +28,7 @@
 # Please fill the missing licenses for dependencies :
 #
 #
-#Fri Jan 05 17:47:47 CET 2018
+#Wed Mar 28 16:37:41 IST 2018
 ant--ant--1.5=The Apache Software License, Version 2.0
 asm--asm--3.1=BSD
 dom4j--dom4j--1.6.1=BSD


Mime
View raw message