Repository: hbase
Updated Branches:
  refs/heads/0.98 a755b44f1 -> 0c58314f3


HBASE-12033 SecurityUtil#doAsLoginUser is absent in hadoop-1, making 
AccessController#postCreateTableHandler() ineffective


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

Branch: refs/heads/0.98
Commit: 0c58314f39bdc8c6f619c054bfd47b5c92990b0f
Parents: a755b44
Author: Ted Yu <te...@apache.org>
Authored: Sat Sep 20 02:44:56 2014 +0000
Committer: Ted Yu <te...@apache.org>
Committed: Sat Sep 20 02:44:56 2014 +0000

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hbase/security/User.java   | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/0c58314f/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java
----------------------------------------------------------------------
diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java
index fd12e47..8ff4b21 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java
@@ -173,13 +173,15 @@ public abstract class User {
    */
   @SuppressWarnings({ "rawtypes", "unchecked" })
   public static <T> T runAsLoginUser(PrivilegedExceptionAction<T> action) 
throws IOException {
+    return doAsUser(UserGroupInformation.getCurrentUser(), action);
+  }
+
+  private static <T> T doAsUser(UserGroupInformation ugi,
+      PrivilegedExceptionAction<T> action) throws IOException {
     try {
-      Class c = Class.forName("org.apache.hadoop.security.SecurityUtil");
-      Class [] types = new Class[]{PrivilegedExceptionAction.class};
-      Object[] args = new Object[]{action};
-      return (T) Methods.call(c, null, "doAsLoginUser", types, args);
-    } catch (Throwable e) {
-      throw new IOException(e);
+      return ugi.doAs(action);
+    } catch (InterruptedException ie) {
+      throw new IOException(ie);
     }
   }
 

Reply via email to