You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by gq...@apache.org on 2015/03/25 02:58:28 UTC
incubator-sentry git commit: SENTRY-645: Add sqoop authorizable model
for sentry authorization (Guoquan Shen, reviewed by Prasad Mujumdar)
Repository: incubator-sentry
Updated Branches:
refs/heads/master f1f7812ff -> da98b3db0
SENTRY-645: Add sqoop authorizable model for sentry authorization (Guoquan Shen, reviewed by Prasad Mujumdar)
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/da98b3db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/da98b3db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/da98b3db
Branch: refs/heads/master
Commit: da98b3db06c8aca1df318d842acd8edfb14ec153
Parents: f1f7812
Author: Guoquan Shen <gu...@intel.com>
Authored: Wed Mar 25 09:36:24 2015 +0800
Committer: Guoquan Shen <gu...@intel.com>
Committed: Wed Mar 25 09:36:24 2015 +0800
----------------------------------------------------------------------
pom.xml | 5 +
sentry-core/pom.xml | 1 +
sentry-core/sentry-core-model-sqoop/pom.xml | 43 +++++++++
.../sentry/core/model/sqoop/Connector.java | 48 ++++++++++
.../org/apache/sentry/core/model/sqoop/Job.java | 46 +++++++++
.../apache/sentry/core/model/sqoop/Link.java | 46 +++++++++
.../apache/sentry/core/model/sqoop/Server.java | 47 ++++++++++
.../core/model/sqoop/SqoopActionConstant.java | 25 +++++
.../core/model/sqoop/SqoopActionFactory.java | 98 ++++++++++++++++++++
.../core/model/sqoop/SqoopAuthorizable.java | 35 +++++++
.../core/model/sqoop/TestSqoopAction.java | 78 ++++++++++++++++
.../core/model/sqoop/TestSqoopAuthorizable.java | 61 ++++++++++++
sentry-dist/pom.xml | 4 +
13 files changed, 537 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 48b84d2..2f97880 100644
--- a/pom.xml
+++ b/pom.xml
@@ -308,6 +308,11 @@ limitations under the License.
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.sentry</groupId>
+ <artifactId>sentry-core-model-sqoop</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>${hive.version}</version>
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-core/pom.xml b/sentry-core/pom.xml
index 1552133..707534e 100644
--- a/sentry-core/pom.xml
+++ b/sentry-core/pom.xml
@@ -33,6 +33,7 @@ limitations under the License.
<module>sentry-core-model-db</module>
<module>sentry-core-model-indexer</module>
<module>sentry-core-model-search</module>
+ <module>sentry-core-model-sqoop</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/pom.xml b/sentry-core/sentry-core-model-sqoop/pom.xml
new file mode 100644
index 0000000..3626190
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.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.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sentry</groupId>
+ <artifactId>sentry-core</artifactId>
+ <version>1.5.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>sentry-core-model-sqoop</artifactId>
+ <name>Sentry Core Model Sqoop</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.sentry</groupId>
+ <artifactId>sentry-core-common</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/da98b3db/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Connector.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Connector.java b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Connector.java
new file mode 100644
index 0000000..f42669b
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Connector.java
@@ -0,0 +1,48 @@
+/*
+ * 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.core.model.sqoop;
+
+/**
+ * Represents the Connector authorizable in the Sqoop model
+ */
+public class Connector implements SqoopAuthorizable {
+ /**
+ * Represents all connectors
+ */
+ public static final Connector ALL = new Connector(SqoopAuthorizable.ALL);
+
+ private String name;
+ public Connector(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public AuthorizableType getAuthzType() {
+ return AuthorizableType.CONNECTOR;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getTypeName() {
+ return getAuthzType().name();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Job.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Job.java b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Job.java
new file mode 100644
index 0000000..e7f43ef
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Job.java
@@ -0,0 +1,46 @@
+/*
+ * 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.core.model.sqoop;
+/**
+ * Represents the Job authorizable in the Sqoop model
+ */
+public class Job implements SqoopAuthorizable {
+ /**
+ * Represents all jobs
+ */
+ public static Job ALL = new Job(SqoopAuthorizable.ALL);
+
+ private String name;
+ public Job(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public AuthorizableType getAuthzType() {
+ return AuthorizableType.JOB;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getTypeName() {
+ return getAuthzType().name();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Link.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Link.java b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Link.java
new file mode 100644
index 0000000..53194ea
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Link.java
@@ -0,0 +1,46 @@
+/*
+ * 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.core.model.sqoop;
+/**
+ * Represents the Link authorizable in the Sqoop model
+ */
+public class Link implements SqoopAuthorizable {
+ /**
+ * Represents all links
+ */
+ public static Link ALL = new Link(SqoopAuthorizable.ALL);
+
+ private String name;
+ public Link(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public AuthorizableType getAuthzType() {
+ return AuthorizableType.LINK;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getTypeName() {
+ return getAuthzType().name();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Server.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Server.java b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Server.java
new file mode 100644
index 0000000..8d86a38
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/Server.java
@@ -0,0 +1,47 @@
+/*
+ * 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.core.model.sqoop;
+/**
+ * Represents the Server authorizable in the Sqoop model
+ */
+public class Server implements SqoopAuthorizable {
+ /**
+ * Represents all servers
+ */
+ public static Server ALL = new Server(SqoopAuthorizable.ALL);
+
+ private String name;
+ public Server(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public AuthorizableType getAuthzType() {
+ return AuthorizableType.SERVER;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getTypeName() {
+ return getAuthzType().name();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionConstant.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionConstant.java b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionConstant.java
new file mode 100644
index 0000000..2b867fa
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionConstant.java
@@ -0,0 +1,25 @@
+/*
+ * 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.core.model.sqoop;
+
+public class SqoopActionConstant {
+ public static final String ALL = "*";
+ public static final String ALL_NAME = "ALL";
+ public static final String READ = "read";
+ public static final String WRITE = "write";
+ public static final String NAME = "action";
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionFactory.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionFactory.java b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionFactory.java
new file mode 100644
index 0000000..c1f33ec
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopActionFactory.java
@@ -0,0 +1,98 @@
+/*
+ * 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.core.model.sqoop;
+
+import java.util.List;
+
+import org.apache.sentry.core.common.BitFieldAction;
+import org.apache.sentry.core.common.BitFieldActionFactory;
+
+import com.google.common.collect.Lists;
+
+public class SqoopActionFactory extends BitFieldActionFactory {
+ enum SqoopActionType {
+ READ(SqoopActionConstant.READ,1),
+ WRITE(SqoopActionConstant.WRITE,2),
+ ALL(SqoopActionConstant.ALL,READ.getCode() | WRITE.getCode());
+
+ private String name;
+ private int code;
+ SqoopActionType(String name, int code) {
+ this.name = name;
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ static SqoopActionType getActionByName(String name) {
+ for (SqoopActionType action : SqoopActionType.values()) {
+ if (action.name.equalsIgnoreCase(name)) {
+ return action;
+ }
+ }
+ throw new RuntimeException("can't get sqoopActionType by name:" + name);
+ }
+
+ static List<SqoopActionType> getActionByCode(int code) {
+ List<SqoopActionType> actions = Lists.newArrayList();
+ for (SqoopActionType action : SqoopActionType.values()) {
+ if (((action.code & code) == action.code ) &&
+ (action != SqoopActionType.ALL)) {
+ //SqoopActionType.ALL action should not return in the list
+ actions.add(action);
+ }
+ }
+ if (actions.isEmpty()) {
+ throw new RuntimeException("can't get sqoopActionType by code:" + code);
+ }
+ return actions;
+ }
+ }
+
+ public static class SqoopAction extends BitFieldAction {
+ public SqoopAction(String name) {
+ this(SqoopActionType.getActionByName(name));
+ }
+ public SqoopAction(SqoopActionType sqoopActionType) {
+ super(sqoopActionType.name, sqoopActionType.code);
+ }
+ }
+
+ @Override
+ public BitFieldAction getActionByName(String name) {
+ //Check the name is All
+ if (SqoopActionConstant.ALL_NAME.equalsIgnoreCase(name)) {
+ return new SqoopAction(SqoopActionType.ALL);
+ }
+ return new SqoopAction(name);
+ }
+
+ @Override
+ public List<? extends BitFieldAction> getActionsByCode(int code) {
+ List<SqoopAction> actions = Lists.newArrayList();
+ for (SqoopActionType action : SqoopActionType.getActionByCode(code)) {
+ actions.add(new SqoopAction(action));
+ }
+ return actions;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopAuthorizable.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopAuthorizable.java b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopAuthorizable.java
new file mode 100644
index 0000000..b57f4a7
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/main/java/org/apache/sentry/core/model/sqoop/SqoopAuthorizable.java
@@ -0,0 +1,35 @@
+/*
+ * 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.core.model.sqoop;
+
+import org.apache.sentry.core.common.Authorizable;
+
+/**
+ * This interface represents authorizable resource in the sqoop component.
+ * It used conjunction with the generic authorization model(SENTRY-398).
+ */
+public interface SqoopAuthorizable extends Authorizable {
+ public static final String ALL = "*";
+ public enum AuthorizableType {
+ SERVER,
+ CONNECTOR,
+ LINK,
+ JOB
+ };
+
+ public AuthorizableType getAuthzType();
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAction.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAction.java b/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAction.java
new file mode 100644
index 0000000..8a86f73
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAction.java
@@ -0,0 +1,78 @@
+/*
+ * 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.core.model.sqoop;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import org.apache.sentry.core.model.sqoop.SqoopActionFactory.SqoopAction;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+public class TestSqoopAction {
+ private SqoopActionFactory factory = new SqoopActionFactory();
+
+ @Test
+ public void testImpliesAction() {
+ SqoopAction readAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.READ);
+ SqoopAction writeAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.WRITE);
+ SqoopAction allAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.ALL);
+ SqoopAction allNameAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.ALL_NAME);
+
+ assertTrue(allAction.implies(readAction));
+ assertTrue(allAction.implies(writeAction));
+ assertTrue(allAction.implies(allAction));
+
+ assertTrue(readAction.implies(readAction));
+ assertFalse(readAction.implies(writeAction));
+ assertFalse(readAction.implies(allAction));
+
+ assertTrue(writeAction.implies(writeAction));
+ assertFalse(writeAction.implies(readAction));
+ assertFalse(writeAction.implies(allAction));
+
+ assertTrue(allNameAction.implies(readAction));
+ assertTrue(allNameAction.implies(writeAction));
+ assertTrue(allNameAction.implies(allAction));
+ }
+
+ @Test
+ public void testGetActionByName() throws Exception {
+ SqoopAction readAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.READ);
+ SqoopAction writeAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.WRITE);
+ SqoopAction allAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.ALL);
+ SqoopAction allNameAction = (SqoopAction)factory.getActionByName(SqoopActionConstant.ALL_NAME);
+
+ assertTrue(readAction.equals(new SqoopAction(SqoopActionConstant.READ)));
+ assertTrue(writeAction.equals(new SqoopAction(SqoopActionConstant.WRITE)));
+ assertTrue(allAction.equals(new SqoopAction(SqoopActionConstant.ALL)));
+ assertTrue(allNameAction.equals(new SqoopAction(SqoopActionConstant.ALL)));
+ }
+
+ @Test
+ public void testGetActionsByCode() throws Exception {
+ SqoopAction readAction = new SqoopAction(SqoopActionConstant.READ);
+ SqoopAction writeAction = new SqoopAction(SqoopActionConstant.WRITE);
+ SqoopAction allAction = new SqoopAction(SqoopActionConstant.ALL);
+
+ assertEquals(Lists.newArrayList(readAction, writeAction), factory.getActionsByCode(allAction.getActionCode()));
+ assertEquals(Lists.newArrayList(readAction), factory.getActionsByCode(readAction.getActionCode()));
+ assertEquals(Lists.newArrayList(writeAction), factory.getActionsByCode(writeAction.getActionCode()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAuthorizable.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAuthorizable.java b/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAuthorizable.java
new file mode 100644
index 0000000..c346290
--- /dev/null
+++ b/sentry-core/sentry-core-model-sqoop/src/test/java/org/apache/sentry/core/model/sqoop/TestSqoopAuthorizable.java
@@ -0,0 +1,61 @@
+/*
+ * 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.core.model.sqoop;
+
+import junit.framework.Assert;
+
+import org.apache.sentry.core.model.sqoop.Connector;
+import org.apache.sentry.core.model.sqoop.Job;
+import org.apache.sentry.core.model.sqoop.Link;
+import org.apache.sentry.core.model.sqoop.Server;
+import org.apache.sentry.core.model.sqoop.SqoopAuthorizable.AuthorizableType;
+import org.junit.Test;
+
+public class TestSqoopAuthorizable {
+
+ @Test
+ public void testSimpleName() throws Exception {
+ String name = "simple";
+ Server server = new Server(name);
+ Assert.assertEquals(server.getName(), name);
+
+ Connector connector = new Connector(name);
+ Assert.assertEquals(connector.getName(), name);
+
+ Link link = new Link(name);
+ Assert.assertEquals(link.getName(), name);
+
+ Job job = new Job(name);
+ Assert.assertEquals(job.getName(), name);
+ }
+
+ @Test
+ public void testAuthType() throws Exception {
+ Server server = new Server("server1");
+ Assert.assertEquals(server.getAuthzType(), AuthorizableType.SERVER);
+
+ Connector connector = new Connector("connector1");
+ Assert.assertEquals(connector.getAuthzType(), AuthorizableType.CONNECTOR);
+
+ Link link = new Link("link1");
+ Assert.assertEquals(link.getAuthzType(), AuthorizableType.LINK);
+
+ Job job = new Job("job1");
+ Assert.assertEquals(job.getAuthzType(), AuthorizableType.JOB);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/da98b3db/sentry-dist/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-dist/pom.xml b/sentry-dist/pom.xml
index f63b33b..f7a663b 100644
--- a/sentry-dist/pom.xml
+++ b/sentry-dist/pom.xml
@@ -44,6 +44,10 @@ limitations under the License.
</dependency>
<dependency>
<groupId>org.apache.sentry</groupId>
+ <artifactId>sentry-core-model-sqoop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sentry</groupId>
<artifactId>sentry-binding-hive</artifactId>
</dependency>
<dependency>