Repository: incubator-sentry Updated Branches: refs/heads/master d96f95160 -> 20f3960ce
SENTRY-1036: Move ProviderConstants from sentry-provider-common to sentry-policy-common (Colin Ma, reviewed by Dapeng Sun) Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/20f3960c Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/20f3960c Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/20f3960c Branch: refs/heads/master Commit: 20f3960cead3cf5c357596cc7d11e29e55254837 Parents: d96f951 Author: Colin Ma <[email protected]> Authored: Fri Jan 29 17:08:24 2016 +0800 Committer: Colin Ma <[email protected]> Committed: Fri Jan 29 17:08:24 2016 +0800 ---------------------------------------------------------------------- .../hive/SentryIniPolicyFileFormatter.java | 6 +- .../hive/TestSentryIniPolicyFileFormatter.java | 6 +- sentry-policy/sentry-policy-common/pom.xml | 5 + .../apache/sentry/policy/common/KeyValue.java | 99 ++++++++++++++++++ .../sentry/policy/common/PolicyConstants.java | 38 +++++++ .../sentry/policy/common/TestKeyValue.java | 76 ++++++++++++++ .../policy/db/AbstractDBPrivilegeValidator.java | 4 +- .../sentry/policy/db/DBModelAuthorizables.java | 2 +- .../sentry/policy/db/DBWildcardPrivilege.java | 12 +-- .../policy/db/TestDBWildcardPrivilege.java | 8 +- .../AbstractIndexerPrivilegeValidator.java | 4 +- .../indexer/IndexerModelAuthorizables.java | 2 +- .../indexer/IndexerWildcardPrivilege.java | 10 +- .../indexer/TestIndexerWildcardPrivilege.java | 8 +- .../AbstractSearchPrivilegeValidator.java | 4 +- .../policy/search/SearchModelAuthorizables.java | 2 +- .../policy/search/SearchWildcardPrivilege.java | 10 +- .../search/TestSearchWildcardPrivilege.java | 8 +- .../policy/sqoop/ServerNameRequiredMatch.java | 4 +- .../policy/sqoop/SqoopModelAuthorizables.java | 2 +- .../policy/sqoop/SqoopWildcardPrivilege.java | 4 +- .../sqoop/TestSqoopWildcardPrivilege.java | 8 +- .../apache/sentry/provider/common/KeyValue.java | 102 ------------------- .../provider/common/ProviderConstants.java | 38 ------- .../common/ResourceAuthorizationProvider.java | 8 +- .../sentry/provider/common/TestKeyValue.java | 76 -------------- .../service/persistent/PrivilegeObject.java | 4 +- .../thrift/SentryGenericPolicyProcessor.java | 4 +- .../tools/SolrTSentryPrivilegeConvertor.java | 14 +-- .../db/service/model/MSentryGMPrivilege.java | 4 +- .../db/service/persistent/SentryStore.java | 8 +- .../db/tools/command/hive/CommandUtil.java | 6 +- .../tools/command/hive/ListPrivilegesCmd.java | 18 ++-- .../service/thrift/SentryServiceUtil.java | 22 ++-- .../thrift/TestSentryServiceImportExport.java | 6 +- .../provider/file/LocalGroupMappingService.java | 4 +- .../file/SimpleFileProviderBackend.java | 2 +- .../AbstractTestWithStaticConfiguration.java | 6 +- .../tests/e2e/hive/TestPolicyImportExport.java | 6 +- .../metastore/SentryPolicyProviderForDb.java | 6 +- 40 files changed, 329 insertions(+), 327 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryIniPolicyFileFormatter.java ---------------------------------------------------------------------- diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryIniPolicyFileFormatter.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryIniPolicyFileFormatter.java index 79164da..1e83a6b 100644 --- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryIniPolicyFileFormatter.java +++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryIniPolicyFileFormatter.java @@ -24,9 +24,9 @@ import java.util.Map; import java.util.Set; import org.apache.hadoop.conf.Configuration; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.PolicyFileConstants; import org.apache.sentry.provider.common.ProviderBackendContext; -import org.apache.sentry.provider.common.ProviderConstants; import org.apache.sentry.provider.file.SimpleFileProviderBackend; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -152,8 +152,8 @@ public class SentryIniPolicyFileFormatter implements SentryPolicyFileFormatter { List<String> lines = Lists.newArrayList(); lines.add("[" + name + "]"); for (String key : mappingData.keySet()) { - lines.add(ProviderConstants.KV_JOINER.join(key, - ProviderConstants.ROLE_JOINER.join(mappingData.get(key)))); + lines.add(PolicyConstants.KV_JOINER.join(key, + PolicyConstants.ROLE_JOINER.join(mappingData.get(key)))); } return Joiner.on(NL).join(lines); } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryIniPolicyFileFormatter.java ---------------------------------------------------------------------- diff --git a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryIniPolicyFileFormatter.java b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryIniPolicyFileFormatter.java index 655417b..f61dd0c 100644 --- a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryIniPolicyFileFormatter.java +++ b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryIniPolicyFileFormatter.java @@ -25,8 +25,8 @@ import java.util.Map; import java.util.Set; import org.apache.sentry.binding.hive.conf.HiveAuthzConf; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.junit.Test; import com.google.common.collect.Maps; @@ -208,8 +208,8 @@ public class TestSentryIniPolicyFileFormatter { for (String actualPrivilege : actualPrivileges) { boolean isFound = exceptedPrivileges.contains(actualPrivilege); if (!isFound) { - String withOptionPrivilege = ProviderConstants.AUTHORIZABLE_JOINER.join(actualPrivilege, - ProviderConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, + String withOptionPrivilege = PolicyConstants.AUTHORIZABLE_JOINER.join(actualPrivilege, + PolicyConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, "false")); isFound = exceptedPrivileges.contains(withOptionPrivilege); } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-common/pom.xml ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-common/pom.xml b/sentry-policy/sentry-policy-common/pom.xml index 68ada23..fbec06f 100644 --- a/sentry-policy/sentry-policy-common/pom.xml +++ b/sentry-policy/sentry-policy-common/pom.xml @@ -40,6 +40,11 @@ limitations under the License. <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/KeyValue.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/KeyValue.java b/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/KeyValue.java new file mode 100644 index 0000000..77e5fdf --- /dev/null +++ b/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/KeyValue.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sentry.policy.common; + +import java.util.List; + +import com.google.common.collect.Lists; + +public class KeyValue { + private final String key; + private final String value; + + public KeyValue(String keyValue) { + List<String> kvList = Lists.newArrayList(PolicyConstants.KV_SPLITTER.trimResults().limit(2).split(keyValue)); + if (kvList.size() != 2) { + throw new IllegalArgumentException("Invalid key value: " + keyValue + " " + kvList); + } + key = kvList.get(0); + value = kvList.get(1); + if (key.isEmpty()) { + throw new IllegalArgumentException("Key cannot be empty"); + } else if (value.isEmpty()) { + throw new IllegalArgumentException("Value cannot be empty"); + } + } + + public KeyValue(String key, String value) { + super(); + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return PolicyConstants.KV_JOINER.join(key, value); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((key == null) ? 0 : key.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + KeyValue other = (KeyValue) obj; + if (key == null) { + if (other.key != null) { + return false; + } + } else if (!key.equalsIgnoreCase(other.key)) { + return false; + } + if (value == null) { + if (other.value != null) { + return false; + } + } else if (!value.equalsIgnoreCase(other.value)) { + return false; + } + return true; + } +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyConstants.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyConstants.java b/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyConstants.java new file mode 100644 index 0000000..0bad8c1 --- /dev/null +++ b/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyConstants.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sentry.policy.common; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; + +public class PolicyConstants { + + public static final String ROLE_SEPARATOR = ","; + public static final String AUTHORIZABLE_SEPARATOR = "->"; + public static final String KV_SEPARATOR = "="; + + public static final Splitter ROLE_SPLITTER = Splitter.on(ROLE_SEPARATOR); + public static final Splitter AUTHORIZABLE_SPLITTER = Splitter.on(AUTHORIZABLE_SEPARATOR); + public static final Splitter KV_SPLITTER = Splitter.on(KV_SEPARATOR); + public static final Joiner ROLE_JOINER = Joiner.on(ROLE_SEPARATOR); + public static final Joiner AUTHORIZABLE_JOINER = Joiner.on(AUTHORIZABLE_SEPARATOR); + public static final Joiner KV_JOINER = Joiner.on(KV_SEPARATOR); + + // TODO change to privilege + public static final String PRIVILEGE_NAME = "action"; + public static final String PRIVILEGE_PREFIX = (PRIVILEGE_NAME + KV_SEPARATOR).toLowerCase(); +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-common/src/test/java/org/apache/sentry/policy/common/TestKeyValue.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-common/src/test/java/org/apache/sentry/policy/common/TestKeyValue.java b/sentry-policy/sentry-policy-common/src/test/java/org/apache/sentry/policy/common/TestKeyValue.java new file mode 100644 index 0000000..2dfc7c5 --- /dev/null +++ b/sentry-policy/sentry-policy-common/src/test/java/org/apache/sentry/policy/common/TestKeyValue.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sentry.policy.common; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; + +import org.junit.Test; + +public class TestKeyValue { + + @Test + public void testWithSeparators() throws Exception { + KeyValue kv = new KeyValue("URI=/u/h/w/t/partition=value/"); + assertEquals("URI", kv.getKey()); + assertEquals("/u/h/w/t/partition=value/", kv.getValue()); + } + + @Test(expected = IllegalArgumentException.class) + public void testEmptyKey() throws Exception { + new KeyValue(KV_JOINER.join("", "b")); + } + + @Test(expected = IllegalArgumentException.class) + public void testEmptyValue() throws Exception { + new KeyValue(KV_JOINER.join("a", "")); + } + + @Test + public void testOneParameterConstructor() throws Exception { + KeyValue kv1 = new KeyValue(KV_JOINER.join("k1", "v1")); + KeyValue kv2 = new KeyValue(KV_JOINER.join("k1", "v1")); + KeyValue kv3 = new KeyValue(KV_JOINER.join("k2", "v2")); + doTest(kv1, kv2, kv3); + } + + @Test + public void testTwoParameterConstructor() throws Exception { + KeyValue kv1 = new KeyValue("k1", "v1"); + KeyValue kv2 = new KeyValue("k1", "v1"); + KeyValue kv3 = new KeyValue("k2", "v2"); + doTest(kv1, kv2, kv3); + } + + private void doTest(KeyValue kv1, KeyValue kv2, KeyValue kv3) { + assertEquals(kv1, kv2); + assertFalse(kv1.equals(kv3)); + + assertEquals(kv1.toString(), kv2.toString()); + assertFalse(kv1.toString().equals(kv3.toString())); + + assertEquals(kv1.hashCode(), kv2.hashCode()); + assertFalse(kv1.hashCode() == kv3.hashCode()); + + assertEquals(kv1.getKey(), kv2.getKey()); + assertFalse(kv1.getKey().equals(kv3.getKey())); + + assertEquals(kv1.getValue(), kv2.getValue()); + assertFalse(kv1.getValue().equals(kv3.getValue())); + } +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/AbstractDBPrivilegeValidator.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/AbstractDBPrivilegeValidator.java b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/AbstractDBPrivilegeValidator.java index e940fc3..8bd311a 100644 --- a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/AbstractDBPrivilegeValidator.java +++ b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/AbstractDBPrivilegeValidator.java @@ -16,8 +16,8 @@ */ package org.apache.sentry.policy.db; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; -import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; import java.util.List; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBModelAuthorizables.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBModelAuthorizables.java b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBModelAuthorizables.java index f07eb11..96b172d 100644 --- a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBModelAuthorizables.java +++ b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBModelAuthorizables.java @@ -24,7 +24,7 @@ import org.apache.sentry.core.model.db.Database; import org.apache.sentry.core.model.db.Server; import org.apache.sentry.core.model.db.Table; import org.apache.sentry.core.model.db.View; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; public class DBModelAuthorizables { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBWildcardPrivilege.java b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBWildcardPrivilege.java index dfc2872..116e0aa 100644 --- a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/DBWildcardPrivilege.java @@ -26,10 +26,10 @@ import java.util.List; import org.apache.sentry.core.common.utils.PathUtils; import org.apache.sentry.core.model.db.AccessConstants; import org.apache.sentry.core.model.db.DBModelAuthorizable.AuthorizableType; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.policy.common.Privilege; import org.apache.sentry.policy.common.PrivilegeFactory; -import org.apache.sentry.provider.common.KeyValue; -import org.apache.sentry.provider.common.ProviderConstants; +import org.apache.sentry.policy.common.KeyValue; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; @@ -48,7 +48,7 @@ public class DBWildcardPrivilege implements Privilege { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); - for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.trimResults().split( + for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.trimResults().split( wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); @@ -117,11 +117,11 @@ public class DBWildcardPrivilege implements Privilege { if(policyPart.getValue().equals(AccessConstants.ALL) || policyPart.getValue().equalsIgnoreCase("ALL")) { return true; - } else if (!ProviderConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) + } else if (!PolicyConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) && AccessConstants.ALL.equalsIgnoreCase(requestPart.getValue())) { /* privilege request is to match with any object of given type */ return true; - } else if (!ProviderConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) + } else if (!PolicyConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) && AccessConstants.SOME.equalsIgnoreCase(requestPart.getValue())) { /* privilege request is to match with any object of given type */ return true; @@ -138,7 +138,7 @@ public class DBWildcardPrivilege implements Privilege { @Override public String toString() { - return ProviderConstants.AUTHORIZABLE_JOINER.join(parts); + return PolicyConstants.AUTHORIZABLE_JOINER.join(parts); } @Override http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-db/src/test/java/org/apache/sentry/policy/db/TestDBWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-db/src/test/java/org/apache/sentry/policy/db/TestDBWildcardPrivilege.java b/sentry-policy/sentry-policy-db/src/test/java/org/apache/sentry/policy/db/TestDBWildcardPrivilege.java index bf5cec5..9fcf853 100644 --- a/sentry-policy/sentry-policy-db/src/test/java/org/apache/sentry/policy/db/TestDBWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-db/src/test/java/org/apache/sentry/policy/db/TestDBWildcardPrivilege.java @@ -20,13 +20,13 @@ package org.apache.sentry.policy.db; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_SEPARATOR; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_SEPARATOR; import org.apache.sentry.core.model.db.AccessConstants; import org.apache.sentry.policy.common.Privilege; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; import org.junit.Test; public class TestDBWildcardPrivilege { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/AbstractIndexerPrivilegeValidator.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/AbstractIndexerPrivilegeValidator.java b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/AbstractIndexerPrivilegeValidator.java index 8520d1a..a01824c 100644 --- a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/AbstractIndexerPrivilegeValidator.java +++ b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/AbstractIndexerPrivilegeValidator.java @@ -16,8 +16,8 @@ */ package org.apache.sentry.policy.indexer; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; -import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; import java.util.List; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerModelAuthorizables.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerModelAuthorizables.java b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerModelAuthorizables.java index e561962..13893b3 100644 --- a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerModelAuthorizables.java +++ b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerModelAuthorizables.java @@ -19,7 +19,7 @@ package org.apache.sentry.policy.indexer; import org.apache.sentry.core.model.indexer.Indexer; import org.apache.sentry.core.model.indexer.IndexerModelAuthorizable; import org.apache.sentry.core.model.indexer.IndexerModelAuthorizable.AuthorizableType; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; public class IndexerModelAuthorizables { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerWildcardPrivilege.java b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerWildcardPrivilege.java index ab6b27f..0ec0ce1 100644 --- a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/IndexerWildcardPrivilege.java @@ -24,10 +24,10 @@ package org.apache.sentry.policy.indexer; import java.util.List; import org.apache.sentry.core.model.indexer.IndexerConstants; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.policy.common.Privilege; import org.apache.sentry.policy.common.PrivilegeFactory; -import org.apache.sentry.provider.common.KeyValue; -import org.apache.sentry.provider.common.ProviderConstants; +import org.apache.sentry.policy.common.KeyValue; import com.google.common.base.Preconditions; import com.google.common.base.Strings; @@ -44,7 +44,7 @@ public class IndexerWildcardPrivilege implements Privilege { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); - for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.trimResults().split( + for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.trimResults().split( wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); @@ -108,7 +108,7 @@ public class IndexerWildcardPrivilege implements Privilege { "Please report, this method should not be called with two different keys"); if(policyPart.getValue().equals(IndexerConstants.ALL) || policyPart.equals(requestPart)) { return true; - } else if (!ProviderConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) + } else if (!PolicyConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) && IndexerConstants.ALL.equalsIgnoreCase(requestPart.getValue())) { /* privilege request is to match with any object of given type */ return true; @@ -118,7 +118,7 @@ public class IndexerWildcardPrivilege implements Privilege { @Override public String toString() { - return ProviderConstants.AUTHORIZABLE_JOINER.join(parts); + return PolicyConstants.AUTHORIZABLE_JOINER.join(parts); } @Override http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-indexer/src/test/java/org/apache/sentry/policy/indexer/TestIndexerWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-indexer/src/test/java/org/apache/sentry/policy/indexer/TestIndexerWildcardPrivilege.java b/sentry-policy/sentry-policy-indexer/src/test/java/org/apache/sentry/policy/indexer/TestIndexerWildcardPrivilege.java index 5348f95..b599a84 100644 --- a/sentry-policy/sentry-policy-indexer/src/test/java/org/apache/sentry/policy/indexer/TestIndexerWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-indexer/src/test/java/org/apache/sentry/policy/indexer/TestIndexerWildcardPrivilege.java @@ -19,13 +19,13 @@ package org.apache.sentry.policy.indexer; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_SEPARATOR; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_SEPARATOR; import org.apache.sentry.core.model.indexer.IndexerConstants; import org.apache.sentry.policy.common.Privilege; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; import org.junit.Test; public class TestIndexerWildcardPrivilege { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/AbstractSearchPrivilegeValidator.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/AbstractSearchPrivilegeValidator.java b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/AbstractSearchPrivilegeValidator.java index 781e722..054c354 100644 --- a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/AbstractSearchPrivilegeValidator.java +++ b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/AbstractSearchPrivilegeValidator.java @@ -16,8 +16,8 @@ */ package org.apache.sentry.policy.search; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; -import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; import java.util.List; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchModelAuthorizables.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchModelAuthorizables.java b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchModelAuthorizables.java index dcf17a2..252f50a 100644 --- a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchModelAuthorizables.java +++ b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchModelAuthorizables.java @@ -19,7 +19,7 @@ package org.apache.sentry.policy.search; import org.apache.sentry.core.model.search.Collection; import org.apache.sentry.core.model.search.SearchModelAuthorizable; import org.apache.sentry.core.model.search.SearchModelAuthorizable.AuthorizableType; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; public class SearchModelAuthorizables { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchWildcardPrivilege.java b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchWildcardPrivilege.java index c522412..e25faf2 100644 --- a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SearchWildcardPrivilege.java @@ -24,10 +24,10 @@ package org.apache.sentry.policy.search; import java.util.List; import org.apache.sentry.core.model.search.SearchConstants; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.policy.common.Privilege; import org.apache.sentry.policy.common.PrivilegeFactory; -import org.apache.sentry.provider.common.KeyValue; -import org.apache.sentry.provider.common.ProviderConstants; +import org.apache.sentry.policy.common.KeyValue; import com.google.common.base.Preconditions; import com.google.common.base.Strings; @@ -44,7 +44,7 @@ public class SearchWildcardPrivilege implements Privilege { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); - for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.trimResults().split( + for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.trimResults().split( wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); @@ -108,7 +108,7 @@ public class SearchWildcardPrivilege implements Privilege { "Please report, this method should not be called with two different keys"); if(policyPart.getValue().equals(SearchConstants.ALL) || policyPart.equals(requestPart)) { return true; - } else if (!ProviderConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) + } else if (!PolicyConstants.PRIVILEGE_NAME.equalsIgnoreCase(policyPart.getKey()) && SearchConstants.ALL.equalsIgnoreCase(requestPart.getValue())) { /* privilege request is to match with any object of given type */ return true; @@ -118,7 +118,7 @@ public class SearchWildcardPrivilege implements Privilege { @Override public String toString() { - return ProviderConstants.AUTHORIZABLE_JOINER.join(parts); + return PolicyConstants.AUTHORIZABLE_JOINER.join(parts); } @Override http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-search/src/test/java/org/apache/sentry/policy/search/TestSearchWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-search/src/test/java/org/apache/sentry/policy/search/TestSearchWildcardPrivilege.java b/sentry-policy/sentry-policy-search/src/test/java/org/apache/sentry/policy/search/TestSearchWildcardPrivilege.java index 125f358..a4c8a2b 100644 --- a/sentry-policy/sentry-policy-search/src/test/java/org/apache/sentry/policy/search/TestSearchWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-search/src/test/java/org/apache/sentry/policy/search/TestSearchWildcardPrivilege.java @@ -19,13 +19,13 @@ package org.apache.sentry.policy.search; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_SEPARATOR; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_SEPARATOR; import org.apache.sentry.core.model.search.SearchConstants; import org.apache.sentry.policy.common.Privilege; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; import org.junit.Test; public class TestSearchWildcardPrivilege { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/ServerNameRequiredMatch.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/ServerNameRequiredMatch.java b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/ServerNameRequiredMatch.java index bbbcedd..ef1c88b 100644 --- a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/ServerNameRequiredMatch.java +++ b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/ServerNameRequiredMatch.java @@ -16,8 +16,8 @@ */ package org.apache.sentry.policy.sqoop; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; -import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; import java.util.List; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopModelAuthorizables.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopModelAuthorizables.java b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopModelAuthorizables.java index 223fb55..b03b4dc 100644 --- a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopModelAuthorizables.java +++ b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopModelAuthorizables.java @@ -22,7 +22,7 @@ import org.apache.sentry.core.model.sqoop.Link; import org.apache.sentry.core.model.sqoop.Server; import org.apache.sentry.core.model.sqoop.SqoopAuthorizable; import org.apache.sentry.core.model.sqoop.SqoopAuthorizable.AuthorizableType; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; public class SqoopModelAuthorizables { public static SqoopAuthorizable from(KeyValue keyValue) { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopWildcardPrivilege.java b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopWildcardPrivilege.java index 139cf7f..ae89cf4 100644 --- a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SqoopWildcardPrivilege.java @@ -16,14 +16,14 @@ */ package org.apache.sentry.policy.sqoop; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; import java.util.List; import org.apache.sentry.core.model.sqoop.SqoopActionConstant; import org.apache.sentry.policy.common.Privilege; import org.apache.sentry.policy.common.PrivilegeFactory; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; import com.google.common.base.Preconditions; import com.google.common.base.Strings; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-policy/sentry-policy-sqoop/src/test/java/org/apache/sentry/policy/sqoop/TestSqoopWildcardPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-policy/sentry-policy-sqoop/src/test/java/org/apache/sentry/policy/sqoop/TestSqoopWildcardPrivilege.java b/sentry-policy/sentry-policy-sqoop/src/test/java/org/apache/sentry/policy/sqoop/TestSqoopWildcardPrivilege.java index 1f03f05..f19a1f8 100644 --- a/sentry-policy/sentry-policy-sqoop/src/test/java/org/apache/sentry/policy/sqoop/TestSqoopWildcardPrivilege.java +++ b/sentry-policy/sentry-policy-sqoop/src/test/java/org/apache/sentry/policy/sqoop/TestSqoopWildcardPrivilege.java @@ -19,13 +19,13 @@ package org.apache.sentry.policy.sqoop; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_SEPARATOR; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_SEPARATOR; import org.apache.sentry.core.model.sqoop.SqoopActionConstant; import org.apache.sentry.policy.common.Privilege; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; import org.junit.Test; public class TestSqoopWildcardPrivilege { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/KeyValue.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/KeyValue.java b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/KeyValue.java deleted file mode 100644 index 984fe46..0000000 --- a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/KeyValue.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.sentry.provider.common; - -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_SPLITTER; - -import java.util.List; - -import com.google.common.collect.Lists; - -public class KeyValue { - private final String key; - private final String value; - - public KeyValue(String keyValue) { - List<String> kvList = Lists.newArrayList(KV_SPLITTER.trimResults().limit(2).split(keyValue)); - if (kvList.size() != 2) { - throw new IllegalArgumentException("Invalid key value: " + keyValue + " " + kvList); - } - key = kvList.get(0); - value = kvList.get(1); - if (key.isEmpty()) { - throw new IllegalArgumentException("Key cannot be empty"); - } else if (value.isEmpty()) { - throw new IllegalArgumentException("Value cannot be empty"); - } - } - - public KeyValue(String key, String value) { - super(); - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return KV_JOINER.join(key, value); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((key == null) ? 0 : key.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - KeyValue other = (KeyValue) obj; - if (key == null) { - if (other.key != null) { - return false; - } - } else if (!key.equalsIgnoreCase(other.key)) { - return false; - } - if (value == null) { - if (other.value != null) { - return false; - } - } else if (!value.equalsIgnoreCase(other.value)) { - return false; - } - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderConstants.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderConstants.java b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderConstants.java deleted file mode 100644 index c6f7e2c..0000000 --- a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sentry.provider.common; - -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; - -public class ProviderConstants { - - public static final String ROLE_SEPARATOR = ","; - public static final String AUTHORIZABLE_SEPARATOR = "->"; - public static final String KV_SEPARATOR = "="; - - public static final Splitter ROLE_SPLITTER = Splitter.on(ROLE_SEPARATOR); - public static final Splitter AUTHORIZABLE_SPLITTER = Splitter.on(AUTHORIZABLE_SEPARATOR); - public static final Splitter KV_SPLITTER = Splitter.on(KV_SEPARATOR); - public static final Joiner ROLE_JOINER = Joiner.on(ROLE_SEPARATOR); - public static final Joiner AUTHORIZABLE_JOINER = Joiner.on(AUTHORIZABLE_SEPARATOR); - public static final Joiner KV_JOINER = Joiner.on(KV_SEPARATOR); - - // TODO change to privilege - public static final String PRIVILEGE_NAME = "action"; - public static final String PRIVILEGE_PREFIX = (PRIVILEGE_NAME + KV_SEPARATOR).toLowerCase(); -} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java index fef4bd9..0cf0b5d 100644 --- a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java +++ b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java @@ -16,10 +16,10 @@ */ package org.apache.sentry.provider.common; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_NAME; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_NAME; import java.util.ArrayList; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestKeyValue.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestKeyValue.java b/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestKeyValue.java deleted file mode 100644 index 1ae4c0c..0000000 --- a/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestKeyValue.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sentry.provider.common; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; - -import org.junit.Test; - -public class TestKeyValue { - - @Test - public void testWithSeparators() throws Exception { - KeyValue kv = new KeyValue("URI=/u/h/w/t/partition=value/"); - assertEquals("URI", kv.getKey()); - assertEquals("/u/h/w/t/partition=value/", kv.getValue()); - } - - @Test(expected = IllegalArgumentException.class) - public void testEmptyKey() throws Exception { - new KeyValue(KV_JOINER.join("", "b")); - } - - @Test(expected = IllegalArgumentException.class) - public void testEmptyValue() throws Exception { - new KeyValue(KV_JOINER.join("a", "")); - } - - @Test - public void testOneParameterConstructor() throws Exception { - KeyValue kv1 = new KeyValue(KV_JOINER.join("k1", "v1")); - KeyValue kv2 = new KeyValue(KV_JOINER.join("k1", "v1")); - KeyValue kv3 = new KeyValue(KV_JOINER.join("k2", "v2")); - doTest(kv1, kv2, kv3); - } - - @Test - public void testTwoParameterConstructor() throws Exception { - KeyValue kv1 = new KeyValue("k1", "v1"); - KeyValue kv2 = new KeyValue("k1", "v1"); - KeyValue kv3 = new KeyValue("k2", "v2"); - doTest(kv1, kv2, kv3); - } - - private void doTest(KeyValue kv1, KeyValue kv2, KeyValue kv3) { - assertEquals(kv1, kv2); - assertFalse(kv1.equals(kv3)); - - assertEquals(kv1.toString(), kv2.toString()); - assertFalse(kv1.toString().equals(kv3.toString())); - - assertEquals(kv1.hashCode(), kv2.hashCode()); - assertFalse(kv1.hashCode() == kv3.hashCode()); - - assertEquals(kv1.getKey(), kv2.getKey()); - assertFalse(kv1.getKey().equals(kv3.getKey())); - - assertEquals(kv1.getValue(), kv2.getValue()); - assertFalse(kv1.getValue().equals(kv3.getValue())); - } -} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/persistent/PrivilegeObject.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/persistent/PrivilegeObject.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/persistent/PrivilegeObject.java index c6e4aa6..3c00d23 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/persistent/PrivilegeObject.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/persistent/PrivilegeObject.java @@ -17,8 +17,8 @@ */ package org.apache.sentry.provider.db.generic.service.persistent; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; import java.util.List; import org.apache.sentry.core.common.Authorizable; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/thrift/SentryGenericPolicyProcessor.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/thrift/SentryGenericPolicyProcessor.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/thrift/SentryGenericPolicyProcessor.java index 45f9ce4..78d3847 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/thrift/SentryGenericPolicyProcessor.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/service/thrift/SentryGenericPolicyProcessor.java @@ -17,8 +17,8 @@ */ package org.apache.sentry.provider.db.generic.service.thrift; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; import java.lang.reflect.Constructor; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SolrTSentryPrivilegeConvertor.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SolrTSentryPrivilegeConvertor.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SolrTSentryPrivilegeConvertor.java index f6a4f15..b636b4c 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SolrTSentryPrivilegeConvertor.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/tools/SolrTSentryPrivilegeConvertor.java @@ -23,10 +23,10 @@ import com.google.common.collect.Lists; import org.apache.sentry.core.model.search.Collection; import org.apache.sentry.core.model.search.SearchModelAuthorizable; import org.apache.sentry.core.model.search.SearchModelAuthorizable.AuthorizableType; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.policy.search.SearchModelAuthorizables; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.apache.sentry.provider.db.generic.service.thrift.TAuthorizable; import org.apache.sentry.provider.db.generic.service.thrift.TSentryGrantOption; import org.apache.sentry.provider.db.generic.service.thrift.TSentryPrivilege; @@ -48,7 +48,7 @@ public class SolrTSentryPrivilegeConvertor implements TSentryPrivilegeConvertor public TSentryPrivilege fromString(String privilegeStr) throws Exception { TSentryPrivilege tSentryPrivilege = new TSentryPrivilege(); List<TAuthorizable> authorizables = new LinkedList<TAuthorizable>(); - for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { + for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { KeyValue keyValue = new KeyValue(authorizable); String key = keyValue.getKey(); String value = keyValue.getValue(); @@ -88,23 +88,23 @@ public class SolrTSentryPrivilegeConvertor implements TSentryPrivilegeConvertor if (it != null) { while (it.hasNext()) { TAuthorizable tAuthorizable = it.next(); - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( tAuthorizable.getType(), tAuthorizable.getName())); } } if (!authorizables.isEmpty()) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_ACTION_NAME, action)); } // only append the grant option to privilege string if it's true if ("true".equals(grantOption)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, grantOption)); } } - return ProviderConstants.AUTHORIZABLE_JOINER.join(privileges); + return PolicyConstants.AUTHORIZABLE_JOINER.join(privileges); } private static void validatePrivilegeHierarchy(TSentryPrivilege tSentryPrivilege) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryGMPrivilege.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryGMPrivilege.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryGMPrivilege.java index 56bbb8f..13b48ea 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryGMPrivilege.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryGMPrivilege.java @@ -17,8 +17,8 @@ vim * Licensed to the Apache Software Foundation (ASF) under one */ package org.apache.sentry.provider.db.service.model; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; import java.lang.reflect.Field; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java index 530bdc7..521d945 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java @@ -18,8 +18,8 @@ package org.apache.sentry.provider.db.service.persistent; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_JOINER; -import static org.apache.sentry.provider.common.ProviderConstants.KV_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_JOINER; +import static org.apache.sentry.policy.common.PolicyConstants.KV_JOINER; import java.io.IOException; import java.util.ArrayList; @@ -49,7 +49,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.sentry.SentryUserException; import org.apache.sentry.core.model.db.AccessConstants; import org.apache.sentry.core.model.db.DBModelAuthorizable.AuthorizableType; -import org.apache.sentry.provider.common.ProviderConstants; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.db.SentryAccessDeniedException; import org.apache.sentry.provider.db.SentryAlreadyExistsException; import org.apache.sentry.provider.db.SentryGrantDeniedException; @@ -1307,7 +1307,7 @@ public class SentryStore { if (!isNULL(privilege.getAction()) && !privilege.getAction().equalsIgnoreCase(AccessConstants.ALL)) { authorizable - .add(KV_JOINER.join(ProviderConstants.PRIVILEGE_NAME.toLowerCase(), + .add(KV_JOINER.join(PolicyConstants.PRIVILEGE_NAME.toLowerCase(), privilege.getAction())); } return AUTHORIZABLE_JOINER.join(authorizable); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/CommandUtil.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/CommandUtil.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/CommandUtil.java index ffccec2..fa7fc6e 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/CommandUtil.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/CommandUtil.java @@ -18,9 +18,9 @@ package org.apache.sentry.provider.db.tools.command.hive; import org.apache.commons.lang.StringUtils; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.apache.sentry.provider.db.service.thrift.TSentryGrantOption; import org.apache.sentry.provider.db.service.thrift.TSentryPrivilege; import org.apache.sentry.service.thrift.ServiceConstants; @@ -32,7 +32,7 @@ public class CommandUtil { // parse the privilege in String and get the TSentryPrivilege as result public static TSentryPrivilege convertToTSentryPrivilege(String privilegeStr) throws Exception { TSentryPrivilege tSentryPrivilege = new TSentryPrivilege(); - for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { + for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { KeyValue tempKV = new KeyValue(authorizable); String key = tempKV.getKey(); String value = tempKV.getValue(); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/ListPrivilegesCmd.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/ListPrivilegesCmd.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/ListPrivilegesCmd.java index 98fae95..d990ef3 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/ListPrivilegesCmd.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/command/hive/ListPrivilegesCmd.java @@ -19,8 +19,8 @@ package org.apache.sentry.provider.db.tools.command.hive; import com.google.common.collect.Lists; import org.apache.commons.lang.StringUtils; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.apache.sentry.provider.db.service.thrift.SentryPolicyServiceClient; import org.apache.sentry.provider.db.service.thrift.TSentryGrantOption; import org.apache.sentry.provider.db.service.thrift.TSentryPrivilege; @@ -64,34 +64,34 @@ public class ListPrivilegesCmd implements Command { String grantOption = (tSentryPrivilege.getGrantOption() == TSentryGrantOption.TRUE ? "true" : "false"); if (!StringUtils.isEmpty(serverName)) { - privileges.add(ProviderConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_SERVER_NAME, + privileges.add(PolicyConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_SERVER_NAME, serverName)); if (!StringUtils.isEmpty(uri)) { - privileges.add(ProviderConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_URI_NAME, + privileges.add(PolicyConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_URI_NAME, uri)); } else if (!StringUtils.isEmpty(dbName)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_DATABASE_NAME, dbName)); if (!StringUtils.isEmpty(tableName)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_TABLE_NAME, tableName)); if (!StringUtils.isEmpty(columnName)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_COLUMN_NAME, columnName)); } } } if (!StringUtils.isEmpty(action)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_ACTION_NAME, action)); } } // only append the grant option to privilege string if it's true if ("true".equals(grantOption)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, grantOption)); } } - return ProviderConstants.AUTHORIZABLE_JOINER.join(privileges); + return PolicyConstants.AUTHORIZABLE_JOINER.join(privileges); } } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java index 46798a0..5b293ec 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java @@ -21,9 +21,9 @@ package org.apache.sentry.service.thrift; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.apache.sentry.provider.common.KeyValue; +import org.apache.sentry.policy.common.KeyValue; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.apache.sentry.provider.db.service.thrift.TSentryGrantOption; import org.apache.sentry.provider.db.service.thrift.TSentryPrivilege; import org.apache.sentry.service.thrift.ServiceConstants.PrivilegeScope; @@ -35,7 +35,7 @@ public class SentryServiceUtil { // parse the privilege in String and get the TSentryPrivilege as result public static TSentryPrivilege convertToTSentryPrivilege(String privilegeStr) { TSentryPrivilege tSentryPrivilege = new TSentryPrivilege(); - for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { + for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { KeyValue tempKV = new KeyValue(authorizable); String key = tempKV.getKey(); String value = tempKV.getValue(); @@ -94,34 +94,34 @@ public class SentryServiceUtil { String grantOption = (tSentryPrivilege.getGrantOption() == TSentryGrantOption.TRUE ? "true" : "false"); if (!StringUtils.isEmpty(serverName)) { - privileges.add(ProviderConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_SERVER_NAME, + privileges.add(PolicyConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_SERVER_NAME, serverName)); if (!StringUtils.isEmpty(uri)) { - privileges.add(ProviderConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_URI_NAME, + privileges.add(PolicyConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_URI_NAME, uri)); } else if (!StringUtils.isEmpty(dbName)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_DATABASE_NAME, dbName)); if (!StringUtils.isEmpty(tableName)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_TABLE_NAME, tableName)); if (!StringUtils.isEmpty(columnName)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_COLUMN_NAME, columnName)); } } } if (!StringUtils.isEmpty(action)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_ACTION_NAME, action)); } } // only append the grant option to privilege string if it's true if ("true".equals(grantOption)) { - privileges.add(ProviderConstants.KV_JOINER.join( + privileges.add(PolicyConstants.KV_JOINER.join( PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, grantOption)); } } - return ProviderConstants.AUTHORIZABLE_JOINER.join(privileges); + return PolicyConstants.AUTHORIZABLE_JOINER.join(privileges); } } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceImportExport.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceImportExport.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceImportExport.java index 9d0a2d6..1b11e62 100644 --- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceImportExport.java +++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceImportExport.java @@ -25,8 +25,8 @@ import static org.junit.Assert.fail; import java.util.Map; import java.util.Set; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.apache.sentry.service.thrift.SentryServiceIntegrationBase; import org.junit.Before; import org.junit.BeforeClass; @@ -526,8 +526,8 @@ public class TestSentryServiceImportExport extends SentryServiceIntegrationBase for (String actualPrivilege : actualPrivileges) { boolean isFound = exceptedPrivileges.contains(actualPrivilege); if (!isFound) { - String withOptionPrivilege = ProviderConstants.AUTHORIZABLE_JOINER.join(actualPrivilege, - ProviderConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, + String withOptionPrivilege = PolicyConstants.AUTHORIZABLE_JOINER.join(actualPrivilege, + PolicyConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, "false")); isFound = exceptedPrivileges.contains(withOptionPrivilege); } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/LocalGroupMappingService.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/LocalGroupMappingService.java b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/LocalGroupMappingService.java index 1c12f11..fed1195 100644 --- a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/LocalGroupMappingService.java +++ b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/LocalGroupMappingService.java @@ -26,9 +26,9 @@ import java.util.Set; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.GroupMappingService; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.apache.sentry.provider.common.SentryGroupNotFoundException; import org.apache.shiro.config.Ini; import org.apache.shiro.config.Ini.Section; @@ -111,7 +111,7 @@ public class LocalGroupMappingService implements GroupMappingService { " in the " + resourcePath); continue; } - Set<String> groupList = Sets.newHashSet(ProviderConstants.ROLE_SPLITTER.trimResults().split( + Set<String> groupList = Sets.newHashSet(PolicyConstants.ROLE_SPLITTER.trimResults().split( groupNames)); LOGGER.debug("Got user mapping: " + userName + ", Groups: " + groupNames); groupMap.put(userName, groupList); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/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 3a648a5..884de16 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 @@ -16,7 +16,7 @@ */ package org.apache.sentry.provider.file; -import static org.apache.sentry.provider.common.ProviderConstants.ROLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.ROLE_SPLITTER; import java.io.IOException; import java.net.URI; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java index 614856f..052c102 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java @@ -16,9 +16,9 @@ */ package org.apache.sentry.tests.e2e.hive; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; -import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX; -import static org.apache.sentry.provider.common.ProviderConstants.ROLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; +import static org.apache.sentry.policy.common.PolicyConstants.ROLE_SPLITTER; import static org.junit.Assert.assertTrue; import java.io.File; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPolicyImportExport.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPolicyImportExport.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPolicyImportExport.java index 2482eb4..4d2f572 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPolicyImportExport.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPolicyImportExport.java @@ -28,8 +28,8 @@ import java.util.Set; import org.apache.sentry.binding.hive.SentryPolicyFileFormatFactory; import org.apache.sentry.binding.hive.SentryPolicyFileFormatter; import org.apache.sentry.binding.hive.authz.SentryConfigTool; +import org.apache.sentry.policy.common.PolicyConstants; import org.apache.sentry.provider.common.PolicyFileConstants; -import org.apache.sentry.provider.common.ProviderConstants; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -183,8 +183,8 @@ public class TestPolicyImportExport extends AbstractTestWithStaticConfiguration for (String actualPrivilege : actualPrivileges) { boolean isFound = exceptedPrivileges.contains(actualPrivilege); if (!isFound) { - String withOptionPrivilege = ProviderConstants.AUTHORIZABLE_JOINER.join(actualPrivilege, - ProviderConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, + String withOptionPrivilege = PolicyConstants.AUTHORIZABLE_JOINER.join(actualPrivilege, + PolicyConstants.KV_JOINER.join(PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME, "false")); isFound = exceptedPrivileges.contains(withOptionPrivilege); } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/20f3960c/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java index d0994b6..4e1e750 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java @@ -16,9 +16,9 @@ */ package org.apache.sentry.tests.e2e.metastore; -import static org.apache.sentry.provider.common.ProviderConstants.AUTHORIZABLE_SPLITTER; -import static org.apache.sentry.provider.common.ProviderConstants.PRIVILEGE_PREFIX; -import static org.apache.sentry.provider.common.ProviderConstants.ROLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; +import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; +import static org.apache.sentry.policy.common.PolicyConstants.ROLE_SPLITTER; import static org.apache.sentry.tests.e2e.hive.StaticUserGroup.ADMIN1; import static org.apache.sentry.tests.e2e.hive.StaticUserGroup.ADMINGROUP;
