sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2739: Sqoop2: Use resource name instead of resource id in authorization engine
Date Fri, 18 Dec 2015 07:14:48 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 c5962f8e1 -> f4909a563


SQOOP-2739: Sqoop2: Use resource name instead of resource id in authorization engine

(Colin Ma via Jarek Jarcec Cecho)


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

Branch: refs/heads/sqoop2
Commit: f4909a5634b085c9291efb95e1dd3b8579f4b1b5
Parents: c5962f8
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Fri Dec 18 08:14:17 2015 +0100
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Fri Dec 18 08:14:17 2015 +0100

----------------------------------------------------------------------
 .../authorization/AuthorizationEngine.java      | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4909a56/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
----------------------------------------------------------------------
diff --git a/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
b/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
index 091d1c4..36e0092 100644
--- a/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
+++ b/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
@@ -33,18 +33,14 @@ import java.util.List;
 
 public class AuthorizationEngine {
 
-  private static String getResourceName(MResource.TYPE resourceType, long resourceId) {
-    Repository repository = RepositoryManager.getInstance().getRepository();
-
-    switch (resourceType) {
-    case CONNECTOR:
-      return repository.findConnector(resourceId).getUniqueName();
-    case LINK:
-      return repository.findLink(resourceId).getName();
-    case JOB:
-      return repository.findJob(resourceId).getName();
+  private static String getResourceName(Object resource) {
+    if (resource instanceof MConnector) {
+      return ((MConnector)resource).getUniqueName();
+    } else if (resource instanceof MLink) {
+      return ((MLink)resource).getName();
+    } else if (resource instanceof MJob) {
+      return ((MJob)resource).getName();
     }
-
     return null;
   }
 
@@ -56,7 +52,7 @@ public class AuthorizationEngine {
       @Override
       public boolean apply(T input) {
         try {
-          String name = getResourceName(type, input.getPersistenceId());
+          String name = getResourceName(input);
           checkPrivilege(doUserName, getPrivilege(type, name, MPrivilege.ACTION.READ));
           // add valid resource
           return true;


Mime
View raw message