sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject git commit: SENTRY-62 - Solr binding should create a solr-usable Configuration to pass to the BackendProvider (Gregory Chanan via Brock Noland)
Date Fri, 08 Nov 2013 22:05:48 GMT
Updated Branches:
  refs/heads/master a41617c81 -> 7d1f14b32


SENTRY-62 - Solr binding should create a solr-usable Configuration to pass to the BackendProvider
(Gregory Chanan via Brock Noland)


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

Branch: refs/heads/master
Commit: 7d1f14b326b057fecc2260953d08843d0b1a5413
Parents: a41617c
Author: Brock Noland <brock@apache.org>
Authored: Fri Nov 8 16:05:39 2013 -0600
Committer: Brock Noland <brock@apache.org>
Committed: Fri Nov 8 16:05:39 2013 -0600

----------------------------------------------------------------------
 pom.xml                                         |  7 +++++++
 sentry-binding/sentry-binding-solr/pom.xml      |  4 ++++
 .../binding/solr/authz/SolrAuthzBinding.java    | 21 ++++++++++++++++++--
 .../file/SimpleFileProviderBackend.java         |  6 +++++-
 4 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/7d1f14b3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 997b1f4..f5cf265 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,6 +53,7 @@ limitations under the License.
     <maven.compile.source>1.6</maven.compile.source>
     <maven.compile.target>1.6</maven.compile.target>
     <hive.version>0.10.0-cdh4.4.0-SNAPSHOT</hive.version>
+    <solr.version>4.4.0-search-1.1.0-SNAPSHOT</solr.version>
     <hadoop.version>2.0.0-cdh4.4.0-SNAPSHOT</hadoop.version>
     <junit.version>4.9</junit.version>
     <fest.reflect.version>1.4.1</fest.reflect.version>
@@ -239,6 +240,12 @@ limitations under the License.
         <scope>provided</scope>
       </dependency>
       <dependency>
+        <groupId>org.apache.solr</groupId>
+        <artifactId>solr-core</artifactId>
+        <version>${solr.version}</version>
+        <scope>provided</scope>
+      </dependency>
+      <dependency>
         <groupId>org.apache.sentry</groupId>
         <artifactId>sentry-binding-hive</artifactId>
         <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/7d1f14b3/sentry-binding/sentry-binding-solr/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-solr/pom.xml b/sentry-binding/sentry-binding-solr/pom.xml
index 4ed491a..a1c8dbf 100644
--- a/sentry-binding/sentry-binding-solr/pom.xml
+++ b/sentry-binding/sentry-binding-solr/pom.xml
@@ -59,6 +59,10 @@ limitations under the License.
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-common</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.solr</groupId>
+      <artifactId>solr-core</artifactId>
+    </dependency>
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/7d1f14b3/sentry-binding/sentry-binding-solr/src/main/java/org/apache/sentry/binding/solr/authz/SolrAuthzBinding.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-solr/src/main/java/org/apache/sentry/binding/solr/authz/SolrAuthzBinding.java
b/sentry-binding/sentry-binding-solr/src/main/java/org/apache/sentry/binding/solr/authz/SolrAuthzBinding.java
index 94f9c57..d7b766c 100644
--- a/sentry-binding/sentry-binding-solr/src/main/java/org/apache/sentry/binding/solr/authz/SolrAuthzBinding.java
+++ b/sentry-binding/sentry-binding-solr/src/main/java/org/apache/sentry/binding/solr/authz/SolrAuthzBinding.java
@@ -16,10 +16,12 @@
  */
 package org.apache.sentry.binding.solr.authz;
 
+import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.util.Arrays;
 import java.util.Set;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.sentry.core.common.Subject;
 import org.apache.sentry.core.model.search.Collection;
 import org.apache.sentry.core.model.search.SearchModelAction;
@@ -28,6 +30,9 @@ import org.apache.sentry.binding.solr.conf.SolrAuthzConf.AuthzConfVars;
 import org.apache.sentry.policy.common.PolicyEngine;
 import org.apache.sentry.provider.common.AuthorizationProvider;
 import org.apache.sentry.provider.common.ProviderBackend;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.HdfsDirectoryFactory;
+import org.apache.solr.util.HdfsUtil;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,10 +65,11 @@ public class SolrAuthzBinding {
       + policyEngineName + ", provider backend " + providerBackendName);
     // load the provider backend class
     Constructor<?> providerBackendConstructor =
-      Class.forName(providerBackendName).getDeclaredConstructor(String.class);
+      Class.forName(providerBackendName).getDeclaredConstructor(Configuration.class, String.class);
     providerBackendConstructor.setAccessible(true);
+    Configuration conf = getConf();
     ProviderBackend providerBackend =
-      (ProviderBackend) providerBackendConstructor.newInstance(new Object[] {resourceName});
+      (ProviderBackend) providerBackendConstructor.newInstance(new Object[] {conf, resourceName});
 
     // load the policy engine class
     Constructor<?> policyConstructor =
@@ -100,4 +106,15 @@ public class SolrAuthzBinding {
         " does not have privileges for " + collection.getName());
     }
   }
+
+  private Configuration getConf() throws IOException {
+    Configuration conf = new Configuration();
+    String confDir = System.getProperty(HdfsDirectoryFactory.CONFIG_DIRECTORY);
+    try {
+      HdfsUtil.addHdfsResources(conf, confDir);
+    } catch (SolrException se) {
+      throw new IOException("Sentry binding encountered an exception trying to create Configuration",
se);
+    }
+    return conf;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/7d1f14b3/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
index 5e0aa66..f432915 100644
--- a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
+++ b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
@@ -72,7 +72,11 @@ public class SimpleFileProviderBackend implements ProviderBackend {
   private boolean processed;
 
   public SimpleFileProviderBackend(String resourcePath) throws IOException {
-    this(new Configuration(), new Path(resourcePath));
+    this(new Configuration(), resourcePath);
+  }
+
+  public SimpleFileProviderBackend(Configuration conf, String resourcePath) throws IOException
{
+    this(conf, new Path(resourcePath));
   }
 
   @VisibleForTesting


Mime
View raw message