diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java index 0f28e26b627..e50f0dc8eda 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/security/Superusers.java @@ -42,6 +42,7 @@ public final class Superusers { private static List superUsers; private static List superGroups; + private static User systemUser; private Superusers(){} @@ -55,17 +56,17 @@ public final class Superusers { public static void initialize(Configuration conf) throws IOException { superUsers = new ArrayList<>(); superGroups = new ArrayList<>(); - User user = User.getCurrent(); + systemUser = User.getCurrent(); - if (user == null) { + if (systemUser == null) { throw new IllegalStateException("Unable to obtain the current user, " + "authorization checks for internal operations will not work correctly!"); } if (LOG.isTraceEnabled()) { - LOG.trace("Current user name is " + user.getShortName()); + LOG.trace("Current user name is " + systemUser.getShortName()); } - String currentUser = user.getShortName(); + String currentUser = systemUser.getShortName(); String[] superUserList = conf.getStrings(SUPERUSER_CONF_KEY, new String[0]); for (String name : superUserList) { if (AuthUtil.isGroupPrincipal(name)) { @@ -125,4 +126,8 @@ public final class Superusers { public static List getSuperUsers() { return superUsers; } + + public static User getSystemUser() { + return systemUser; + } } \ No newline at end of file diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java index 9905767a502..a7e34d8bc0d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java @@ -66,10 +66,8 @@ public class AddColumnFamilyProcedure this.traceEnabled = null; } - public AddColumnFamilyProcedure( - final MasterProcedureEnv env, - final TableName tableName, - final HColumnDescriptor cfDescriptor) throws IOException { + public AddColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName, + final HColumnDescriptor cfDescriptor) { this.tableName = tableName; this.cfDescriptor = cfDescriptor; this.user = env.getRequestUser().getUGI(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateNamespaceProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateNamespaceProcedure.java index 1dd39d9a92a..e87315644ea 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateNamespaceProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateNamespaceProcedure.java @@ -55,9 +55,8 @@ public class CreateNamespaceProcedure this.traceEnabled = null; } - public CreateNamespaceProcedure( - final MasterProcedureEnv env, - final NamespaceDescriptor nsDescriptor) throws IOException { + public CreateNamespaceProcedure(final MasterProcedureEnv env, + final NamespaceDescriptor nsDescriptor) { this.nsDescriptor = nsDescriptor; this.traceEnabled = null; this.setOwner(env.getRequestUser().getUGI().getShortUserName()); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java index c351cea2d01..74433b40756 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java @@ -77,15 +77,13 @@ public class CreateTableProcedure } public CreateTableProcedure(final MasterProcedureEnv env, - final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions) - throws IOException { + final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions) { this(env, hTableDescriptor, newRegions, null); } public CreateTableProcedure(final MasterProcedureEnv env, final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions, - final ProcedurePrepareLatch syncLatch) - throws IOException { + final ProcedurePrepareLatch syncLatch) { this.hTableDescriptor = hTableDescriptor; this.newRegions = newRegions != null ? Lists.newArrayList(newRegions) : null; this.user = env.getRequestUser().getUGI(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java index 54d8fe51939..bb8a2016dbe 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java @@ -67,10 +67,8 @@ public class DeleteColumnFamilyProcedure this.traceEnabled = null; } - public DeleteColumnFamilyProcedure( - final MasterProcedureEnv env, - final TableName tableName, - final byte[] familyName) throws IOException { + public DeleteColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName, + final byte[] familyName) { this.tableName = tableName; this.familyName = familyName; this.user = env.getRequestUser().getUGI(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteNamespaceProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteNamespaceProcedure.java index 3a4ccbb0002..a7ebc3063ee 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteNamespaceProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteNamespaceProcedure.java @@ -63,9 +63,7 @@ public class DeleteNamespaceProcedure this.traceEnabled = null; } - public DeleteNamespaceProcedure( - final MasterProcedureEnv env, - final String namespaceName) throws IOException { + public DeleteNamespaceProcedure(final MasterProcedureEnv env, final String namespaceName) { this.namespaceName = namespaceName; this.nsDescriptor = null; this.traceEnabled = null; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java index 38b83a28d2e..44dde9eca07 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java @@ -74,13 +74,12 @@ public class DeleteTableProcedure syncLatch = null; } - public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName) - throws IOException { + public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName) { this(env, tableName, null); } public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableName, - final ProcedurePrepareLatch syncLatch) throws IOException { + final ProcedurePrepareLatch syncLatch) { this.tableName = tableName; this.user = env.getRequestUser().getUGI(); this.setOwner(this.user.getShortUserName()); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java index 9491fb159c4..185c0d0b096 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.java @@ -83,12 +83,9 @@ public class DisableTableProcedure * @param env MasterProcedureEnv * @param tableName the table to operate on * @param skipTableStateCheck whether to check table state - * @throws IOException */ - public DisableTableProcedure( - final MasterProcedureEnv env, - final TableName tableName, - final boolean skipTableStateCheck) throws IOException { + public DisableTableProcedure(final MasterProcedureEnv env, final TableName tableName, + final boolean skipTableStateCheck) { this(env, tableName, skipTableStateCheck, null); } @@ -97,13 +94,9 @@ public class DisableTableProcedure * @param env MasterProcedureEnv * @param tableName the table to operate on * @param skipTableStateCheck whether to check table state - * @throws IOException */ - public DisableTableProcedure( - final MasterProcedureEnv env, - final TableName tableName, - final boolean skipTableStateCheck, - final ProcedurePrepareLatch syncLatch) throws IOException { + public DisableTableProcedure(final MasterProcedureEnv env, final TableName tableName, + final boolean skipTableStateCheck, final ProcedurePrepareLatch syncLatch) { this.tableName = tableName; this.skipTableStateCheck = skipTableStateCheck; this.user = env.getRequestUser().getUGI(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java index e7d66852a17..14f68e2fbc0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java @@ -82,12 +82,9 @@ public class EnableTableProcedure * @param env MasterProcedureEnv * @param tableName the table to operate on * @param skipTableStateCheck whether to check table state - * @throws IOException */ - public EnableTableProcedure( - final MasterProcedureEnv env, - final TableName tableName, - final boolean skipTableStateCheck) throws IOException { + public EnableTableProcedure(final MasterProcedureEnv env, final TableName tableName, + final boolean skipTableStateCheck) { this(env, tableName, skipTableStateCheck, null); } @@ -96,13 +93,9 @@ public class EnableTableProcedure * @param env MasterProcedureEnv * @param tableName the table to operate on * @param skipTableStateCheck whether to check table state - * @throws IOException */ - public EnableTableProcedure( - final MasterProcedureEnv env, - final TableName tableName, - final boolean skipTableStateCheck, - final ProcedurePrepareLatch syncLatch) throws IOException { + public EnableTableProcedure(final MasterProcedureEnv env, final TableName tableName, + final boolean skipTableStateCheck, final ProcedurePrepareLatch syncLatch) { this.tableName = tableName; this.skipTableStateCheck = skipTableStateCheck; this.user = env.getRequestUser().getUGI(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java index 090b8ccc5da..3911f54790a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureEnv.java @@ -36,7 +36,7 @@ import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.store.ProcedureStore; import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore; import org.apache.hadoop.hbase.security.User; -import org.apache.hadoop.hbase.security.UserProvider; +import org.apache.hadoop.hbase.security.Superusers; import org.apache.hadoop.hbase.util.CancelableProgressable; import org.apache.hadoop.hbase.util.FSUtils; @@ -96,10 +96,10 @@ public class MasterProcedureEnv { master.getTableLockManager()); } - public User getRequestUser() throws IOException { + public User getRequestUser() { User user = RpcServer.getRequestUser(); if (user == null) { - user = UserProvider.instantiate(getMasterConfiguration()).getCurrent(); + user = Superusers.getSystemUser(); } return user; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java index fd212eb22ce..5e81dbf9414 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyColumnFamilyProcedure.java @@ -64,10 +64,8 @@ public class ModifyColumnFamilyProcedure this.traceEnabled = null; } - public ModifyColumnFamilyProcedure( - final MasterProcedureEnv env, - final TableName tableName, - final HColumnDescriptor cfDescriptor) throws IOException { + public ModifyColumnFamilyProcedure(final MasterProcedureEnv env, final TableName tableName, + final HColumnDescriptor cfDescriptor) { this.tableName = tableName; this.cfDescriptor = cfDescriptor; this.user = env.getRequestUser().getUGI(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyNamespaceProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyNamespaceProcedure.java index d8b1bedc9f7..5d9548bdd65 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyNamespaceProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyNamespaceProcedure.java @@ -55,9 +55,8 @@ public class ModifyNamespaceProcedure this.traceEnabled = null; } - public ModifyNamespaceProcedure( - final MasterProcedureEnv env, - final NamespaceDescriptor newNsDescriptor) throws IOException { + public ModifyNamespaceProcedure(final MasterProcedureEnv env, + final NamespaceDescriptor newNsDescriptor) { this.oldNsDescriptor = null; this.newNsDescriptor = newNsDescriptor; this.traceEnabled = null; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java index f1f64571893..b04a6383f23 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ModifyTableProcedure.java @@ -72,9 +72,7 @@ public class ModifyTableProcedure initilize(); } - public ModifyTableProcedure( - final MasterProcedureEnv env, - final HTableDescriptor htd) throws IOException { + public ModifyTableProcedure(final MasterProcedureEnv env, final HTableDescriptor htd) { initilize(); this.modifiedHTableDescriptor = htd; this.user = env.getRequestUser().getUGI(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java index 3623f35fa73..3a3739d068a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TruncateTableProcedure.java @@ -61,7 +61,7 @@ public class TruncateTableProcedure } public TruncateTableProcedure(final MasterProcedureEnv env, final TableName tableName, - boolean preserveSplits) throws IOException { + boolean preserveSplits) { this.tableName = tableName; this.preserveSplits = preserveSplits; this.user = env.getRequestUser().getUGI();