sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [20/23] sentry git commit: Removing validators now that SENTRY-2012 is not going to make it into Sentry 2.0.0
Date Wed, 22 Nov 2017 15:56:40 GMT
Removing validators now that SENTRY-2012 is not going to make it into Sentry 2.0.0


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

Branch: refs/heads/master
Commit: b882eb496c9060e8dfeb0f648b2fd126384d077b
Parents: fe3ef23
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Nov 20 14:53:07 2017 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Nov 20 14:53:07 2017 +0000

----------------------------------------------------------------------
 .../org/apache/sentry/shell/TopLevelShell.java  | 60 +-------------------
 1 file changed, 2 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/b882eb49/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
index a602e3f..9cb9a53 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
@@ -19,13 +19,6 @@
 package org.apache.sentry.shell;
 
 import org.apache.sentry.core.common.exception.SentryUserException;
-import org.apache.sentry.core.model.kafka.KafkaAuthorizable;
-import org.apache.sentry.core.model.kafka.KafkaModelAuthorizables;
-import org.apache.sentry.core.model.kafka.KafkaPrivilegeModel;
-import org.apache.sentry.core.model.solr.SolrModelAuthorizables;
-import org.apache.sentry.core.model.solr.SolrPrivilegeModel;
-import org.apache.sentry.core.model.sqoop.SqoopModelAuthorizables;
-import org.apache.sentry.core.model.sqoop.SqoopPrivilegeModel;
 import org.apache.sentry.provider.common.AuthorizationComponent;
 import org.apache.sentry.provider.db.generic.service.thrift.SentryGenericServiceClient;
 import org.apache.sentry.provider.db.generic.tools.GenericPrivilegeConverter;
@@ -40,11 +33,6 @@ import com.budhash.cliche.Param;
 import com.budhash.cliche.Shell;
 import com.budhash.cliche.ShellDependent;
 import com.budhash.cliche.ShellFactory;
-import com.google.common.base.Function;
-
-import static org.apache.sentry.core.common.utils.SentryConstants.AUTHORIZABLE_SEPARATOR;
-import static org.apache.sentry.core.common.utils.SentryConstants.KV_SEPARATOR;
-import static org.apache.sentry.core.common.utils.SentryConstants.RESOURCE_WILDCARD_VALUE;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -53,8 +41,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import javax.annotation.Nullable;
-
 /**
  * Top level commands
  */
@@ -246,7 +232,7 @@ public class TopLevelShell implements ShellDependent, Runnable {
       } else {
         String component = getComponent(parsedType);
         String service = getService(parsedType);
-        TSentryPrivilegeConverter converter = getPrivilegeConverter(parsedType, component,
service);
+        TSentryPrivilegeConverter converter = new GenericPrivilegeConverter(component, service);
         shellCommand = new GenericShellCommand(sentryGenericClient, component, service, converter);
       }
     } catch (IllegalArgumentException ex) {
@@ -267,7 +253,7 @@ public class TopLevelShell implements ShellDependent, Runnable {
         shellCommand = new HiveShellCommand(sentryClient);
       } else {
         String component = getComponent(parsedType);
-        TSentryPrivilegeConverter converter = getPrivilegeConverter(parsedType, component,
service);
+        TSentryPrivilegeConverter converter = new GenericPrivilegeConverter(component, service);
         shellCommand = new GenericShellCommand(sentryGenericClient, component, service, converter);
       }
     } catch (IllegalArgumentException ex) {
@@ -313,46 +299,4 @@ public class TopLevelShell implements ShellDependent, Runnable {
     throw new IllegalArgumentException("Invalid type specified for SentryShellGeneric: "
+ type);
   }
 
-  private TSentryPrivilegeConverter getPrivilegeConverter(TYPE type, String component, String
service) {
-    if (type == TYPE.kafka) {
-      GenericPrivilegeConverter privilegeConverter = new GenericPrivilegeConverter(
-          component,
-          service,
-          KafkaPrivilegeModel.getInstance().getPrivilegeValidators(),
-          new KafkaModelAuthorizables(),
-          true
-      );
-      privilegeConverter.setPrivilegeStrParser(new Function<String, String>() {
-        @Nullable
-        @Override
-        public String apply(@Nullable String privilegeStr) {
-          final String hostPrefix = KafkaAuthorizable.AuthorizableType.HOST.name() + KV_SEPARATOR;
-          final String hostPrefixLowerCase = hostPrefix.toLowerCase();
-          if (!privilegeStr.toLowerCase().startsWith(hostPrefixLowerCase)) {
-            return hostPrefix + RESOURCE_WILDCARD_VALUE + AUTHORIZABLE_SEPARATOR + privilegeStr;
-          }
-          return privilegeStr;
-        }
-      });
-      return privilegeConverter;
-    } else if (type == TYPE.solr) {
-      return new GenericPrivilegeConverter(
-          component,
-          service,
-          SolrPrivilegeModel.getInstance().getPrivilegeValidators(),
-          new SolrModelAuthorizables(),
-          true
-      );
-    } else if (type == TYPE.sqoop) {
-      return new GenericPrivilegeConverter(
-          component,
-          service,
-          SqoopPrivilegeModel.getInstance().getPrivilegeValidators(service),
-          new SqoopModelAuthorizables(),
-          true
-      );
-    }
-
-    throw new IllegalArgumentException("Invalid type specified for SentryShellGeneric: "
+ type);
-  }
 }


Mime
View raw message