HBASE-18878 Use Optional in return types.

These functions have been changed to return Optional<T> instead of T, where T = old return type.
- ObserverContext#getCaller
- RpcCallContext#getRequestUser
- RpcCallContext#getRequestUserName
- RpcServer#getCurrentCall
- RpcServer#getRequestUser
- RpcServer#getRequestUserName
- RpcServer#getRemoteAddress
- ServerCall#getRequestUser

Change-Id: Ib7b4e6be637283755f55755dd4c5124729f7052e
Signed-off-by: Apekshit Sharma <appy@apache.org>
This commit is contained in:
zhangduo 2017-10-02 19:03:19 -07:00 committed by Apekshit Sharma
parent 1ec6ece918
commit 98d1637bcd
28 changed files with 335 additions and 380 deletions

View File

@ -17,7 +17,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.hadoop.hbase.util; package org.apache.hadoop.hbase.util;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
@ -64,10 +63,10 @@ public class Classes {
return valueType; return valueType;
} }
public static String stringify(Class[] classes) { public static String stringify(Class<?>[] classes) {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
if (classes != null) { if (classes != null) {
for (Class c : classes) { for (Class<?> c : classes) {
if (buf.length() > 0) { if (buf.length() > 0) {
buf.append(","); buf.append(",");
} }
@ -78,4 +77,9 @@ public class Classes {
} }
return buf.toString(); return buf.toString();
} }
@SuppressWarnings("unchecked")
public static <T> Class<T> cast(Class<?> clazz) {
return (Class<T>) clazz;
}
} }

View File

@ -453,10 +453,7 @@ public class Export extends ExportProtos.ExportService implements RegionCoproces
} }
private static User getActiveUser(final UserProvider userProvider, final Token userToken) throws IOException { private static User getActiveUser(final UserProvider userProvider, final Token userToken) throws IOException {
User user = RpcServer.getRequestUser(); User user = RpcServer.getRequestUser().orElse(userProvider.getCurrent());
if (user == null) {
user = userProvider.getCurrent();
}
if (user == null && userToken != null) { if (user == null && userToken != null) {
LOG.warn("No found of user credentials, but a token was got from user request"); LOG.warn("No found of user credentials, but a token was got from user request");
} else if (user != null && userToken != null) { } else if (user != null && userToken != null) {

View File

@ -79,8 +79,8 @@ public class ProtobufCoprocessorService extends TestRpcServiceProtos.TestProtobu
@Override @Override
public void addr(RpcController controller, EmptyRequestProto request, public void addr(RpcController controller, EmptyRequestProto request,
RpcCallback<AddrResponseProto> done) { RpcCallback<AddrResponseProto> done) {
done.run(AddrResponseProto.newBuilder().setAddr(RpcServer.getRemoteAddress().getHostAddress()) done.run(AddrResponseProto.newBuilder()
.build()); .setAddr(RpcServer.getRemoteAddress().get().getHostAddress()).build());
} }
@Override @Override

View File

@ -71,8 +71,7 @@ public final class VersionInfoUtil {
* @return the versionInfo extracted from the current RpcCallContext * @return the versionInfo extracted from the current RpcCallContext
*/ */
private static HBaseProtos.VersionInfo getCurrentClientVersionInfo() { private static HBaseProtos.VersionInfo getCurrentClientVersionInfo() {
RpcCallContext call = RpcServer.getCurrentCall(); return RpcServer.getCurrentCall().map(RpcCallContext::getClientVersionInfo).orElse(null);
return call != null ? call.getClientVersionInfo() : null;
} }
/** /**

View File

@ -549,7 +549,7 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends Coprocess
ObserverGetter<C, O> observerGetter; ObserverGetter<C, O> observerGetter;
ObserverOperation(ObserverGetter<C, O> observerGetter) { ObserverOperation(ObserverGetter<C, O> observerGetter) {
this(observerGetter, RpcServer.getRequestUser()); this(observerGetter, RpcServer.getRequestUser().orElse(null));
} }
ObserverOperation(ObserverGetter<C, O> observerGetter, User user) { ObserverOperation(ObserverGetter<C, O> observerGetter, User user) {

View File

@ -1,5 +1,4 @@
/* /*
*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
@ -16,16 +15,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.hadoop.hbase.coprocessor; package org.apache.hadoop.hbase.coprocessor;
import edu.umd.cs.findbugs.annotations.Nullable; import java.util.Optional;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability; import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.hbase.CoprocessorEnvironment; import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
/** /**
* Carries the execution state for a given invocation of an Observer coprocessor * Carries the execution state for a given invocation of an Observer coprocessor
@ -43,8 +43,9 @@ public class ObserverContext<E extends CoprocessorEnvironment> {
private E env; private E env;
private boolean bypass; private boolean bypass;
private boolean complete; private boolean complete;
private User caller; private final User caller;
@InterfaceAudience.Private
public ObserverContext(User caller) { public ObserverContext(User caller) {
this.caller = caller; this.caller = caller;
} }
@ -53,6 +54,7 @@ public class ObserverContext<E extends CoprocessorEnvironment> {
return env; return env;
} }
@InterfaceAudience.Private
public void prepare(E env) { public void prepare(E env) {
this.env = env; this.env = env;
} }
@ -97,58 +99,30 @@ public class ObserverContext<E extends CoprocessorEnvironment> {
} }
/** /**
* Returns the active user for the coprocessor call. * Returns the active user for the coprocessor call. If an explicit {@code User} instance was
* If an explicit {@code User} instance was provided to the constructor, that will be returned, * provided to the constructor, that will be returned, otherwise if we are in the context of an
* otherwise if we are in the context of an RPC call, the remote user is used. May return null * RPC call, the remote user is used. May not be present if the execution is outside of an RPC
* if the execution is outside of an RPC context. * context.
*/ */
@Nullable public Optional<User> getCaller() {
public User getCaller() { return Optional.ofNullable(caller);
return caller;
} }
/** /**
* Instantiates a new ObserverContext instance if the passed reference is * Instantiates a new ObserverContext instance if the passed reference is <code>null</code> and
* <code>null</code> and sets the environment in the new or existing instance. * sets the environment in the new or existing instance. This allows deferring the instantiation
* This allows deferring the instantiation of a ObserverContext until it is * of a ObserverContext until it is actually needed.
* actually needed.
*
* @param env The coprocessor environment to set
* @param context An existing ObserverContext instance to use, or <code>null</code>
* to create a new instance
* @param <E> The environment type for the context * @param <E> The environment type for the context
* @param env The coprocessor environment to set
* @return An instance of <code>ObserverContext</code> with the environment set * @return An instance of <code>ObserverContext</code> with the environment set
*/ */
@Deprecated @Deprecated
@InterfaceAudience.Private
@VisibleForTesting
// TODO: Remove this method, ObserverContext should not depend on RpcServer // TODO: Remove this method, ObserverContext should not depend on RpcServer
public static <E extends CoprocessorEnvironment> ObserverContext<E> createAndPrepare( public static <E extends CoprocessorEnvironment> ObserverContext<E> createAndPrepare(E env) {
E env, ObserverContext< E> context) { ObserverContext<E> ctx = new ObserverContext<>(RpcServer.getRequestUser().orElse(null));
if (context == null) { ctx.prepare(env);
context = new ObserverContext<>(RpcServer.getRequestUser()); return ctx;
}
context.prepare(env);
return context;
}
/**
* Instantiates a new ObserverContext instance if the passed reference is
* <code>null</code> and sets the environment in the new or existing instance.
* This allows deferring the instantiation of a ObserverContext until it is
* actually needed.
*
* @param env The coprocessor environment to set
* @param context An existing ObserverContext instance to use, or <code>null</code>
* to create a new instance
* @param user The requesting caller for the execution context
* @param <E> The environment type for the context
* @return An instance of <code>ObserverContext</code> with the environment set
*/
public static <E extends CoprocessorEnvironment> ObserverContext<E> createAndPrepare(
E env, ObserverContext<E> context, User user) {
if (context == null) {
context = new ObserverContext<>(user);
}
context.prepare(env);
return context;
} }
} }

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.ipc;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.util.Optional;
import org.apache.hadoop.hbase.CallDroppedException; import org.apache.hadoop.hbase.CallDroppedException;
import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.CellScanner;
@ -107,9 +108,9 @@ public class CallRunner {
this.status.setStatus("Setting up call"); this.status.setStatus("Setting up call");
this.status.setConnection(call.getRemoteAddress().getHostAddress(), call.getRemotePort()); this.status.setConnection(call.getRemoteAddress().getHostAddress(), call.getRemotePort());
if (RpcServer.LOG.isTraceEnabled()) { if (RpcServer.LOG.isTraceEnabled()) {
User remoteUser = call.getRequestUser(); Optional<User> remoteUser = call.getRequestUser();
RpcServer.LOG.trace(call.toShortString() + " executing as " + RpcServer.LOG.trace(call.toShortString() + " executing as " +
((remoteUser == null) ? "NULL principal" : remoteUser.getName())); (remoteUser.isPresent() ? "NULL principal" : remoteUser.get().getName()));
} }
Throwable errorThrowable = null; Throwable errorThrowable = null;
String error = null; String error = null;

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.ipc; package org.apache.hadoop.hbase.ipc;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Optional;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.VersionInfo; import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.VersionInfo;
@ -48,16 +49,18 @@ public interface RpcCallContext {
boolean isClientCellBlockSupported(); boolean isClientCellBlockSupported();
/** /**
* Returns the user credentials associated with the current RPC request or * Returns the user credentials associated with the current RPC request or not present if no
* <code>null</code> if no credentials were provided. * credentials were provided.
* @return A User * @return A User
*/ */
User getRequestUser(); Optional<User> getRequestUser();
/** /**
* @return Current request's user name or null if none ongoing. * @return Current request's user name or not present if none ongoing.
*/ */
String getRequestUserName(); default Optional<String> getRequestUserName() {
return getRequestUser().map(User::getShortName);
}
/** /**
* @return Address of remote client in this call * @return Address of remote client in this call

View File

@ -20,8 +20,6 @@ package org.apache.hadoop.hbase.ipc;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION; import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION;
import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -35,6 +33,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -46,8 +45,6 @@ import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.Server;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.apache.hadoop.hbase.conf.ConfigurationObserver; import org.apache.hadoop.hbase.conf.ConfigurationObserver;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException; import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.io.ByteBufferPool; import org.apache.hadoop.hbase.io.ByteBufferPool;
@ -62,6 +59,18 @@ import org.apache.hadoop.hbase.security.SaslUtil.QualityOfProtection;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.security.token.AuthenticationTokenSecretManager; import org.apache.hadoop.hbase.security.token.AuthenticationTokenSecretManager;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.AuthorizationException;
import org.apache.hadoop.security.authorize.PolicyProvider;
import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
import org.apache.hadoop.security.token.SecretManager;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.codehaus.jackson.map.ObjectMapper;
import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.BlockingService; import org.apache.hadoop.hbase.shaded.com.google.protobuf.BlockingService;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.MethodDescriptor; import org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.MethodDescriptor;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.Message; import org.apache.hadoop.hbase.shaded.com.google.protobuf.Message;
@ -70,14 +79,6 @@ import org.apache.hadoop.hbase.shaded.com.google.protobuf.TextFormat;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.ConnectionHeader; import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.ConnectionHeader;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.AuthorizationException;
import org.apache.hadoop.security.authorize.PolicyProvider;
import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
import org.apache.hadoop.security.token.SecretManager;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.codehaus.jackson.map.ObjectMapper;
/** /**
* An RPC server that hosts protobuf described Services. * An RPC server that hosts protobuf described Services.
@ -678,8 +679,8 @@ public abstract class RpcServer implements RpcServerInterface,
* call. * call.
* @return An RpcCallContext backed by the currently ongoing call (gotten from a thread local) * @return An RpcCallContext backed by the currently ongoing call (gotten from a thread local)
*/ */
public static RpcCall getCurrentCall() { public static Optional<RpcCall> getCurrentCall() {
return CurCall.get(); return Optional.ofNullable(CurCall.get());
} }
public static boolean isInRpcCallContext() { public static boolean isInRpcCallContext() {
@ -687,13 +688,13 @@ public abstract class RpcServer implements RpcServerInterface,
} }
/** /**
* Returns the user credentials associated with the current RPC request or * Returns the user credentials associated with the current RPC request or not present if no
* <code>null</code> if no credentials were provided. * credentials were provided.
* @return A User * @return A User
*/ */
public static User getRequestUser() { public static Optional<User> getRequestUser() {
RpcCallContext ctx = getCurrentCall(); Optional<RpcCall> ctx = getCurrentCall();
return ctx == null? null: ctx.getRequestUser(); return ctx.isPresent() ? ctx.get().getRequestUser() : Optional.empty();
} }
/** /**
@ -704,19 +705,17 @@ public abstract class RpcServer implements RpcServerInterface,
/** /**
* Returns the username for any user associated with the current RPC * Returns the username for any user associated with the current RPC
* request or <code>null</code> if no user is set. * request or not present if no user is set.
*/ */
public static String getRequestUserName() { public static Optional<String> getRequestUserName() {
User user = getRequestUser(); return getRequestUser().map(User::getShortName);
return user == null? null: user.getShortName();
} }
/** /**
* @return Address of remote client if a request is ongoing, else null * @return Address of remote client if a request is ongoing, else null
*/ */
public static InetAddress getRemoteAddress() { public static Optional<InetAddress> getRemoteAddress() {
RpcCallContext ctx = getCurrentCall(); return getCurrentCall().map(RpcCall::getRemoteAddress);
return ctx == null? null: ctx.getRemoteAddress();
} }
/** /**

View File

@ -22,6 +22,7 @@ import java.net.InetAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.DoNotRetryIOException;
@ -82,7 +83,7 @@ abstract class ServerCall<T extends ServerRpcConnection> implements RpcCall, Rpc
protected ByteBufferListOutputStream cellBlockStream = null; protected ByteBufferListOutputStream cellBlockStream = null;
protected CallCleanup reqCleanup = null; protected CallCleanup reqCleanup = null;
protected User user; protected final User user;
protected final InetAddress remoteAddress; protected final InetAddress remoteAddress;
protected RpcCallback rpcCallback; protected RpcCallback rpcCallback;
@ -110,10 +111,14 @@ abstract class ServerCall<T extends ServerRpcConnection> implements RpcCall, Rpc
this.isError = false; this.isError = false;
this.size = size; this.size = size;
this.tinfo = tinfo; this.tinfo = tinfo;
this.user = connection == null ? null : connection.user; // FindBugs: NP_NULL_ON_SOME_PATH if (connection != null) {
this.user = connection.user;
this.retryImmediatelySupported = connection.retryImmediatelySupported;
} else {
this.user = null;
this.retryImmediatelySupported = false;
}
this.remoteAddress = remoteAddress; this.remoteAddress = remoteAddress;
this.retryImmediatelySupported =
connection == null ? false : connection.retryImmediatelySupported;
this.timeout = timeout; this.timeout = timeout;
this.deadline = this.timeout > 0 ? this.receiveTime + this.timeout : Long.MAX_VALUE; this.deadline = this.timeout > 0 ? this.receiveTime + this.timeout : Long.MAX_VALUE;
this.reservoir = reservoir; this.reservoir = reservoir;
@ -432,14 +437,8 @@ abstract class ServerCall<T extends ServerRpcConnection> implements RpcCall, Rpc
} }
@Override @Override
public User getRequestUser() { public Optional<User> getRequestUser() {
return user; return Optional.ofNullable(user);
}
@Override
public String getRequestUserName() {
User user = getRequestUser();
return user == null? null: user.getShortName();
} }
@Override @Override

View File

@ -154,7 +154,8 @@ public class SimpleRpcScheduler extends RpcScheduler implements ConfigurationObs
@Override @Override
public boolean dispatch(CallRunner callTask) throws InterruptedException { public boolean dispatch(CallRunner callTask) throws InterruptedException {
RpcCall call = callTask.getRpcCall(); RpcCall call = callTask.getRpcCall();
int level = priority.getPriority(call.getHeader(), call.getParam(), call.getRequestUser()); int level = priority.getPriority(call.getHeader(), call.getParam(),
call.getRequestUser().orElse(null));
if (level == HConstants.PRIORITY_UNSET) { if (level == HConstants.PRIORITY_UNSET) {
level = HConstants.NORMAL_QOS; level = HConstants.NORMAL_QOS;
} }

View File

@ -110,11 +110,7 @@ public class MasterProcedureEnv implements ConfigurationObserver {
} }
public User getRequestUser() { public User getRequestUser() {
User user = RpcServer.getRequestUser(); return RpcServer.getRequestUser().orElse(Superusers.getSystemUser());
if (user == null) {
user = Superusers.getSystemUser();
}
return user;
} }
public MasterServices getMasterServices() { public MasterServices getMasterServices() {

View File

@ -41,8 +41,6 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.Stoppable; import org.apache.hadoop.hbase.Stoppable;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.client.TableState; import org.apache.hadoop.hbase.client.TableState;
@ -65,13 +63,8 @@ import org.apache.hadoop.hbase.procedure.ProcedureCoordinator;
import org.apache.hadoop.hbase.procedure.ProcedureCoordinatorRpcs; import org.apache.hadoop.hbase.procedure.ProcedureCoordinatorRpcs;
import org.apache.hadoop.hbase.procedure.ZKProcedureCoordinator; import org.apache.hadoop.hbase.procedure.ZKProcedureCoordinator;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription;
import org.apache.hadoop.hbase.security.AccessDeniedException; import org.apache.hadoop.hbase.security.AccessDeniedException;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.Type;
import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils; import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils;
import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException; import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException; import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
@ -87,8 +80,16 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.KeyLocker; import org.apache.hadoop.hbase.util.KeyLocker;
import org.apache.hadoop.hbase.util.NonceKey; import org.apache.hadoop.hbase.util.NonceKey;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.Type;
/** /**
* This class manages the procedure of taking and restoring snapshots. There is only one * This class manages the procedure of taking and restoring snapshots. There is only one
* SnapshotManager for the master. * SnapshotManager for the master.
@ -586,10 +587,11 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
if (!snapshot.hasVersion()) { if (!snapshot.hasVersion()) {
builder.setVersion(SnapshotDescriptionUtils.SNAPSHOT_LAYOUT_VERSION); builder.setVersion(SnapshotDescriptionUtils.SNAPSHOT_LAYOUT_VERSION);
} }
User user = RpcServer.getRequestUser(); RpcServer.getRequestUser().ifPresent(user -> {
if (User.isHBaseSecurityEnabled(master.getConfiguration()) && user != null) { if (User.isHBaseSecurityEnabled(master.getConfiguration())) {
builder.setOwner(user.getShortName()); builder.setOwner(user.getShortName());
} }
});
snapshot = builder.build(); snapshot = builder.build();
// call pre coproc hook // call pre coproc hook

View File

@ -176,13 +176,7 @@ public class RegionServerRpcQuotaManager {
private OperationQuota checkQuota(final Region region, private OperationQuota checkQuota(final Region region,
final int numWrites, final int numReads, final int numScans) final int numWrites, final int numReads, final int numScans)
throws IOException, ThrottlingException { throws IOException, ThrottlingException {
User user = RpcServer.getRequestUser(); UserGroupInformation ugi = RpcServer.getRequestUser().orElse(User.getCurrent()).getUGI();
UserGroupInformation ugi;
if (user != null) {
ugi = user.getUGI();
} else {
ugi = User.getCurrent().getUGI();
}
TableName table = region.getTableDescriptor().getTableName(); TableName table = region.getTableDescriptor().getTableName();
OperationQuota quota = getQuota(ugi, table); OperationQuota quota = getQuota(ugi, table);

View File

@ -135,7 +135,6 @@ import org.apache.hadoop.hbase.io.hfile.HFile;
import org.apache.hadoop.hbase.ipc.CallerDisconnectedException; import org.apache.hadoop.hbase.ipc.CallerDisconnectedException;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils; import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils;
import org.apache.hadoop.hbase.ipc.RpcCall; import org.apache.hadoop.hbase.ipc.RpcCall;
import org.apache.hadoop.hbase.ipc.RpcCallContext;
import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.monitoring.MonitoredTask; import org.apache.hadoop.hbase.monitoring.MonitoredTask;
import org.apache.hadoop.hbase.monitoring.TaskMonitor; import org.apache.hadoop.hbase.monitoring.TaskMonitor;
@ -5375,12 +5374,15 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
int timeout = rowLockWaitDuration; int timeout = rowLockWaitDuration;
boolean reachDeadlineFirst = false; boolean reachDeadlineFirst = false;
RpcCall call = RpcServer.getCurrentCall(); Optional<RpcCall> call = RpcServer.getCurrentCall();
if (call != null && call.getDeadline() < Long.MAX_VALUE) { if (call.isPresent()) {
int timeToDeadline = (int)(call.getDeadline() - System.currentTimeMillis()); long deadline = call.get().getDeadline();
if (timeToDeadline <= this.rowLockWaitDuration) { if (deadline < Long.MAX_VALUE) {
reachDeadlineFirst = true; int timeToDeadline = (int) (deadline - System.currentTimeMillis());
timeout = timeToDeadline; if (timeToDeadline <= this.rowLockWaitDuration) {
reachDeadlineFirst = true;
timeout = timeToDeadline;
}
} }
} }
@ -6085,7 +6087,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
if (scannerContext == null) { if (scannerContext == null) {
throw new IllegalArgumentException("Scanner context cannot be null"); throw new IllegalArgumentException("Scanner context cannot be null");
} }
RpcCallContext rpcCall = RpcServer.getCurrentCall(); Optional<RpcCall> rpcCall = RpcServer.getCurrentCall();
// Save the initial progress from the Scanner context in these local variables. The progress // Save the initial progress from the Scanner context in these local variables. The progress
// may need to be reset a few times if rows are being filtered out so we save the initial // may need to be reset a few times if rows are being filtered out so we save the initial
@ -6110,13 +6112,12 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
} else { } else {
scannerContext.clearProgress(); scannerContext.clearProgress();
} }
if (rpcCall.isPresent()) {
if (rpcCall != null) {
// If a user specifies a too-restrictive or too-slow scanner, the // If a user specifies a too-restrictive or too-slow scanner, the
// client might time out and disconnect while the server side // client might time out and disconnect while the server side
// is still processing the request. We should abort aggressively // is still processing the request. We should abort aggressively
// in that case. // in that case.
long afterTime = rpcCall.disconnectSince(); long afterTime = rpcCall.get().disconnectSince();
if (afterTime >= 0) { if (afterTime >= 0) {
throw new CallerDisconnectedException( throw new CallerDisconnectedException(
"Aborting on region " + getRegionInfo().getRegionNameAsString() + ", call " + "Aborting on region " + getRegionInfo().getRegionNameAsString() + ", call " +

View File

@ -2112,7 +2112,7 @@ public class HRegionServer extends HasThread implements
@Override @Override
public void stop(final String msg) { public void stop(final String msg) {
stop(msg, false, RpcServer.getRequestUser()); stop(msg, false, RpcServer.getRequestUser().orElse(null));
} }
/** /**

View File

@ -1547,11 +1547,11 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
// Quota support is enabled, the requesting user is not system/super user // Quota support is enabled, the requesting user is not system/super user
// and a quota policy is enforced that disables compactions. // and a quota policy is enforced that disables compactions.
if (QuotaUtil.isQuotaEnabled(getConfiguration()) && if (QuotaUtil.isQuotaEnabled(getConfiguration()) &&
!Superusers.isSuperUser(RpcServer.getRequestUser()) && !Superusers.isSuperUser(RpcServer.getRequestUser().orElse(null)) &&
this.regionServer.getRegionServerSpaceQuotaManager().areCompactionsDisabled( this.regionServer.getRegionServerSpaceQuotaManager()
region.getTableDescriptor().getTableName())) { .areCompactionsDisabled(region.getTableDescriptor().getTableName())) {
throw new DoNotRetryIOException("Compactions on this region are " throw new DoNotRetryIOException(
+ "disabled due to a space quota violation."); "Compactions on this region are " + "disabled due to a space quota violation.");
} }
region.startRegionOperation(Operation.COMPACT_REGION); region.startRegionOperation(Operation.COMPACT_REGION);
LOG.info("Compacting " + region.getRegionInfo().getRegionNameAsString()); LOG.info("Compacting " + region.getRegionInfo().getRegionNameAsString());
@ -1586,10 +1586,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
String log = "User-triggered " + (major ? "major " : "") + "compaction" + familyLogMsg; String log = "User-triggered " + (major ? "major " : "") + "compaction" + familyLogMsg;
if (family != null) { if (family != null) {
regionServer.compactSplitThread.requestCompaction(region, store, log, Store.PRIORITY_USER, regionServer.compactSplitThread.requestCompaction(region, store, log, Store.PRIORITY_USER,
CompactionLifeCycleTracker.DUMMY, RpcServer.getRequestUser()); CompactionLifeCycleTracker.DUMMY, RpcServer.getRequestUser().orElse(null));
} else { } else {
regionServer.compactSplitThread.requestCompaction(region, log, Store.PRIORITY_USER, regionServer.compactSplitThread.requestCompaction(region, log, Store.PRIORITY_USER,
CompactionLifeCycleTracker.DUMMY, RpcServer.getRequestUser()); CompactionLifeCycleTracker.DUMMY, RpcServer.getRequestUser().orElse(null));
} }
return CompactRegionResponse.newBuilder().build(); return CompactRegionResponse.newBuilder().build();
} catch (IOException ie) { } catch (IOException ie) {
@ -2407,7 +2407,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
ClientProtos.Get get = request.getGet(); ClientProtos.Get get = request.getGet();
Boolean existence = null; Boolean existence = null;
Result r = null; Result r = null;
RpcCallContext context = RpcServer.getCurrentCall(); RpcCallContext context = RpcServer.getCurrentCall().orElse(null);
quota = getRpcQuotaManager().checkQuota(region, OperationQuota.OperationType.GET); quota = getRpcQuotaManager().checkQuota(region, OperationQuota.OperationType.GET);
Get clientGet = ProtobufUtil.toGet(get); Get clientGet = ProtobufUtil.toGet(get);
@ -2558,7 +2558,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
RegionActionResult.Builder regionActionResultBuilder = RegionActionResult.newBuilder(); RegionActionResult.Builder regionActionResultBuilder = RegionActionResult.newBuilder();
Boolean processed = null; Boolean processed = null;
RegionScannersCloseCallBack closeCallBack = null; RegionScannersCloseCallBack closeCallBack = null;
RpcCallContext context = RpcServer.getCurrentCall(); RpcCallContext context = RpcServer.getCurrentCall().orElse(null);
this.rpcMultiRequestCount.increment(); this.rpcMultiRequestCount.increment();
this.requestCount.increment(); this.requestCount.increment();
Map<RegionSpecifier, ClientProtos.RegionLoadStats> regionStats = new HashMap<>(request Map<RegionSpecifier, ClientProtos.RegionLoadStats> regionStats = new HashMap<>(request
@ -2689,7 +2689,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
HBaseRpcController controller = (HBaseRpcController)rpcc; HBaseRpcController controller = (HBaseRpcController)rpcc;
CellScanner cellScanner = controller != null ? controller.cellScanner() : null; CellScanner cellScanner = controller != null ? controller.cellScanner() : null;
OperationQuota quota = null; OperationQuota quota = null;
RpcCallContext context = RpcServer.getCurrentCall(); RpcCallContext context = RpcServer.getCurrentCall().orElse(null);
ActivePolicyEnforcement spaceQuotaEnforcement = null; ActivePolicyEnforcement spaceQuotaEnforcement = null;
MutationType type = null; MutationType type = null;
long before = EnvironmentEdgeManager.currentTime(); long before = EnvironmentEdgeManager.currentTime();
@ -3269,7 +3269,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
} else { } else {
rows = closeScanner ? 0 : 1; rows = closeScanner ? 0 : 1;
} }
RpcCallContext context = RpcServer.getCurrentCall(); RpcCallContext context = RpcServer.getCurrentCall().orElse(null);
// now let's do the real scan. // now let's do the real scan.
long maxQuotaResultSize = Math.min(maxScannerResultSize, quota.getReadAvailable()); long maxQuotaResultSize = Math.min(maxScannerResultSize, quota.getReadAvailable());
RegionScanner scanner = rsh.s; RegionScanner scanner = rsh.s;
@ -3281,7 +3281,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
} else { } else {
limitOfRows = -1; limitOfRows = -1;
} }
MutableObject lastBlock = new MutableObject(); MutableObject<Object> lastBlock = new MutableObject<>();
boolean scannerClosed = false; boolean scannerClosed = false;
try { try {
List<Result> results = new ArrayList<>(); List<Result> results = new ArrayList<>();

View File

@ -15,9 +15,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.hadoop.hbase.regionserver; package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
import java.math.BigInteger;
import java.security.PrivilegedAction;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -29,19 +37,8 @@ import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.coprocessor.BulkLoadObserver;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CleanupBulkLoadRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.PrepareBulkLoadRequest;
import org.apache.hadoop.hbase.regionserver.Region.BulkLoadListener; import org.apache.hadoop.hbase.regionserver.Region.BulkLoadListener;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.security.UserProvider;
@ -55,15 +52,12 @@ import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Text;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
import org.apache.yetus.audience.InterfaceAudience;
import java.io.IOException; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
import java.math.BigInteger; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest;
import java.security.PrivilegedAction; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CleanupBulkLoadRequest;
import java.security.SecureRandom; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.PrepareBulkLoadRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Bulk loads in secure mode. * Bulk loads in secure mode.
@ -140,10 +134,12 @@ public class SecureBulkLoadManager {
public String prepareBulkLoad(final Region region, final PrepareBulkLoadRequest request) public String prepareBulkLoad(final Region region, final PrepareBulkLoadRequest request)
throws IOException { throws IOException {
region.getCoprocessorHost().prePrepareBulkLoad(getActiveUser()); User user = getActiveUser();
region.getCoprocessorHost().prePrepareBulkLoad(user);
String bulkToken = createStagingDir(baseStagingDir, getActiveUser(), String bulkToken =
region.getTableDescriptor().getTableName()).toString(); createStagingDir(baseStagingDir, user, region.getTableDescriptor().getTableName())
.toString();
return bulkToken; return bulkToken;
} }
@ -275,16 +271,12 @@ public class SecureBulkLoadManager {
} }
private User getActiveUser() throws IOException { private User getActiveUser() throws IOException {
User user = RpcServer.getRequestUser(); // for non-rpc handling, fallback to system user
if (user == null) { User user = RpcServer.getRequestUser().orElse(userProvider.getCurrent());
// for non-rpc handling, fallback to system user // this is for testing
user = userProvider.getCurrent(); if (userProvider.isHadoopSecurityEnabled() &&
} "simple".equalsIgnoreCase(conf.get(User.HBASE_SECURITY_CONF_KEY))) {
return User.createUserForTesting(conf, user.getShortName(), new String[] {});
//this is for testing
if (userProvider.isHadoopSecurityEnabled()
&& "simple".equalsIgnoreCase(conf.get(User.HBASE_SECURITY_CONF_KEY))) {
return User.createUserForTesting(conf, user.getShortName(), new String[]{});
} }
return user; return user;

View File

@ -18,6 +18,11 @@
*/ */
package org.apache.hadoop.hbase.security.access; package org.apache.hadoop.hbase.security.access;
import com.google.protobuf.Message;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
@ -34,10 +39,6 @@ import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import com.google.protobuf.Message;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -121,13 +122,6 @@ import org.apache.hadoop.hbase.security.Superusers;
import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.security.access.Permission.Action; import org.apache.hadoop.hbase.security.access.Permission.Action;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ArrayListMultimap;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ImmutableSet;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ListMultimap;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.MapMaker;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Maps;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Sets;
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
import org.apache.hadoop.hbase.util.ByteRange; import org.apache.hadoop.hbase.util.ByteRange;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
@ -138,6 +132,14 @@ import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ArrayListMultimap;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ImmutableSet;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ListMultimap;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.MapMaker;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Maps;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Sets;
/** /**
* Provides basic authorization checks for data access and administrative * Provides basic authorization checks for data access and administrative
* operations. * operations.
@ -404,13 +406,11 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
private void logResult(AuthResult result) { private void logResult(AuthResult result) {
if (AUDITLOG.isTraceEnabled()) { if (AUDITLOG.isTraceEnabled()) {
InetAddress remoteAddr = RpcServer.getRemoteAddress(); AUDITLOG.trace("Access " + (result.isAllowed() ? "allowed" : "denied") + " for user " +
AUDITLOG.trace("Access " + (result.isAllowed() ? "allowed" : "denied") + (result.getUser() != null ? result.getUser().getShortName() : "UNKNOWN") + "; reason: " +
" for user " + (result.getUser() != null ? result.getUser().getShortName() : "UNKNOWN") + result.getReason() + "; remote address: " +
"; reason: " + result.getReason() + RpcServer.getRemoteAddress().map(InetAddress::toString).orElse("") + "; request: " +
"; remote address: " + (remoteAddr != null ? remoteAddr : "") + result.getRequest() + "; context: " + result.toContextString());
"; request: " + result.getRequest() +
"; context: " + result.toContextString());
} }
} }
@ -419,13 +419,9 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
* If we are in the context of an RPC call, the remote user is used, * If we are in the context of an RPC call, the remote user is used,
* otherwise the currently logged in user is used. * otherwise the currently logged in user is used.
*/ */
private User getActiveUser(ObserverContext ctx) throws IOException { private User getActiveUser(ObserverContext<?> ctx) throws IOException {
User user = ctx.getCaller(); // for non-rpc handling, fallback to system user
if (user == null) { return ctx.getCaller().orElse(userProvider.getCurrent());
// for non-rpc handling, fallback to system user
user = userProvider.getCurrent();
}
return user;
} }
/** /**
@ -2165,9 +2161,10 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
* the checks performed in preScannerOpen() * the checks performed in preScannerOpen()
*/ */
private void requireScannerOwner(InternalScanner s) throws AccessDeniedException { private void requireScannerOwner(InternalScanner s) throws AccessDeniedException {
if (!RpcServer.isInRpcCallContext()) if (!RpcServer.isInRpcCallContext()) {
return; return;
String requestUserName = RpcServer.getRequestUserName(); }
String requestUserName = RpcServer.getRequestUserName().orElse(null);
String owner = scannerOwners.get(s); String owner = scannerOwners.get(s);
if (authorizationEnabled && owner != null && !owner.equals(requestUserName)) { if (authorizationEnabled && owner != null && !owner.equals(requestUserName)) {
throw new AccessDeniedException("User '"+ requestUserName +"' is not the scanner owner!"); throw new AccessDeniedException("User '"+ requestUserName +"' is not the scanner owner!");
@ -2257,7 +2254,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Received request to grant access permission " + perm.toString()); LOG.debug("Received request to grant access permission " + perm.toString());
} }
User caller = RpcServer.getRequestUser(); User caller = RpcServer.getRequestUser().orElse(null);
switch(request.getUserPermission().getPermission().getType()) { switch(request.getUserPermission().getPermission().getType()) {
case Global : case Global :
@ -2310,7 +2307,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Received request to revoke access permission " + perm.toString()); LOG.debug("Received request to revoke access permission " + perm.toString());
} }
User caller = RpcServer.getRequestUser(); User caller = RpcServer.getRequestUser().orElse(null);
switch(request.getUserPermission().getPermission().getType()) { switch(request.getUserPermission().getPermission().getType()) {
case Global : case Global :
@ -2359,7 +2356,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
if (!initialized) { if (!initialized) {
throw new CoprocessorException("AccessController not yet initialized"); throw new CoprocessorException("AccessController not yet initialized");
} }
User caller = RpcServer.getRequestUser(); User caller = RpcServer.getRequestUser().orElse(null);
List<UserPermission> perms = null; List<UserPermission> perms = null;
if (request.getType() == AccessControlProtos.Permission.Type.Table) { if (request.getType() == AccessControlProtos.Permission.Type.Table) {
@ -2420,7 +2417,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
} }
AccessControlProtos.CheckPermissionsResponse response = null; AccessControlProtos.CheckPermissionsResponse response = null;
try { try {
User user = RpcServer.getRequestUser(); User user = RpcServer.getRequestUser().orElse(null);
TableName tableName = regionEnv.getRegion().getTableDescriptor().getTableName(); TableName tableName = regionEnv.getRegion().getTableDescriptor().getTableName();
for (Permission permission : permissions) { for (Permission permission : permissions) {
if (permission instanceof TablePermission) { if (permission instanceof TablePermission) {

View File

@ -15,9 +15,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.hadoop.hbase.security.token; package org.apache.hadoop.hbase.security.token;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
@ -37,10 +40,6 @@ import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod; import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
import org.apache.hadoop.security.token.SecretManager; import org.apache.hadoop.security.token.SecretManager;
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
/** /**
@ -113,17 +112,12 @@ public class TokenProvider implements AuthenticationProtos.AuthenticationService
throw new IOException( throw new IOException(
"No secret manager configured for token authentication"); "No secret manager configured for token authentication");
} }
User currentUser = RpcServer.getRequestUser()
User currentUser = RpcServer.getRequestUser(); .orElseThrow(() -> new AccessDeniedException("No authenticated user for request!"));
UserGroupInformation ugi = null; UserGroupInformation ugi = currentUser.getUGI();
if (currentUser != null) { if (!isAllowedDelegationTokenOp(ugi)) {
ugi = currentUser.getUGI(); LOG.warn("Token generation denied for user=" + currentUser.getName() + ", authMethod=" +
} ugi.getAuthenticationMethod());
if (currentUser == null) {
throw new AccessDeniedException("No authenticated user for request!");
} else if (!isAllowedDelegationTokenOp(ugi)) {
LOG.warn("Token generation denied for user="+currentUser.getName()
+", authMethod="+ugi.getAuthenticationMethod());
throw new AccessDeniedException( throw new AccessDeniedException(
"Token generation only allowed for Kerberos authenticated clients"); "Token generation only allowed for Kerberos authenticated clients");
} }
@ -139,17 +133,16 @@ public class TokenProvider implements AuthenticationProtos.AuthenticationService
@Override @Override
public void whoAmI(RpcController controller, AuthenticationProtos.WhoAmIRequest request, public void whoAmI(RpcController controller, AuthenticationProtos.WhoAmIRequest request,
RpcCallback<AuthenticationProtos.WhoAmIResponse> done) { RpcCallback<AuthenticationProtos.WhoAmIResponse> done) {
User requestUser = RpcServer.getRequestUser();
AuthenticationProtos.WhoAmIResponse.Builder response = AuthenticationProtos.WhoAmIResponse.Builder response =
AuthenticationProtos.WhoAmIResponse.newBuilder(); AuthenticationProtos.WhoAmIResponse.newBuilder();
if (requestUser != null) { RpcServer.getRequestUser().ifPresent(requestUser -> {
response.setUsername(requestUser.getShortName()); response.setUsername(requestUser.getShortName());
AuthenticationMethod method = requestUser.getUGI().getAuthenticationMethod(); AuthenticationMethod method = requestUser.getUGI().getAuthenticationMethod();
if (method != null) { if (method != null) {
response.setAuthMethod(method.name()); response.setAuthMethod(method.name());
} }
} });
done.run(response.build()); done.run(response.build());
} }
} }

View File

@ -23,6 +23,11 @@ import static org.apache.hadoop.hbase.HConstants.OperationStatusCode.SUCCESS;
import static org.apache.hadoop.hbase.security.visibility.VisibilityConstants.LABELS_TABLE_FAMILY; import static org.apache.hadoop.hbase.security.visibility.VisibilityConstants.LABELS_TABLE_FAMILY;
import static org.apache.hadoop.hbase.security.visibility.VisibilityConstants.LABELS_TABLE_NAME; import static org.apache.hadoop.hbase.security.visibility.VisibilityConstants.LABELS_TABLE_NAME;
import com.google.protobuf.ByteString;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
@ -51,7 +56,6 @@ import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Tag; import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.TagType; import org.apache.hadoop.hbase.TagType;
import org.apache.hadoop.hbase.TagUtil; import org.apache.hadoop.hbase.TagUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Delete;
@ -82,8 +86,8 @@ import org.apache.hadoop.hbase.io.hfile.HFile;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils; import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils;
import org.apache.hadoop.hbase.ipc.RpcServer; import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.master.MasterServices; import org.apache.hadoop.hbase.master.MasterServices;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.RegionActionResult; import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.RegionActionResult;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair;
import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos; import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos;
import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.GetAuthsRequest; import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.GetAuthsRequest;
import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.GetAuthsResponse; import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.GetAuthsResponse;
@ -109,13 +113,10 @@ import org.apache.hadoop.hbase.security.access.AccessController;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists; import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.MapMaker; import org.apache.hadoop.hbase.shaded.com.google.common.collect.MapMaker;
import com.google.protobuf.ByteString;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;
/** /**
* Coprocessor that has both the MasterObserver and RegionObserver implemented that supports in * Coprocessor that has both the MasterObserver and RegionObserver implemented that supports in
@ -663,7 +664,7 @@ public class VisibilityController implements MasterCoprocessor, RegionCoprocesso
private void requireScannerOwner(InternalScanner s) throws AccessDeniedException { private void requireScannerOwner(InternalScanner s) throws AccessDeniedException {
if (!RpcServer.isInRpcCallContext()) if (!RpcServer.isInRpcCallContext())
return; return;
String requestUName = RpcServer.getRequestUserName(); String requestUName = RpcServer.getRequestUserName().orElse(null);
String owner = scannerOwners.get(s); String owner = scannerOwners.get(s);
if (authorizationEnabled && owner != null && !owner.equals(requestUName)) { if (authorizationEnabled && owner != null && !owner.equals(requestUName)) {
throw new AccessDeniedException("User '" + requestUName + "' is not the scanner owner!"); throw new AccessDeniedException("User '" + requestUName + "' is not the scanner owner!");
@ -892,7 +893,6 @@ public class VisibilityController implements MasterCoprocessor, RegionCoprocesso
List<byte[]> labelAuths, String regex) { List<byte[]> labelAuths, String regex) {
if (AUDITLOG.isTraceEnabled()) { if (AUDITLOG.isTraceEnabled()) {
// This is more duplicated code! // This is more duplicated code!
InetAddress remoteAddr = RpcServer.getRemoteAddress();
List<String> labelAuthsStr = new ArrayList<>(); List<String> labelAuthsStr = new ArrayList<>();
if (labelAuths != null) { if (labelAuths != null) {
int labelAuthsSize = labelAuths.size(); int labelAuthsSize = labelAuths.size();
@ -909,11 +909,12 @@ public class VisibilityController implements MasterCoprocessor, RegionCoprocesso
LOG.warn("Failed to get active system user."); LOG.warn("Failed to get active system user.");
LOG.debug("Details on failure to get active system user.", e); LOG.debug("Details on failure to get active system user.", e);
} }
AUDITLOG.trace("Access " + (isAllowed ? "allowed" : "denied") + " for user " AUDITLOG.trace("Access " + (isAllowed ? "allowed" : "denied") + " for user " +
+ (requestingUser != null ? requestingUser.getShortName() : "UNKNOWN") + "; reason: " (requestingUser != null ? requestingUser.getShortName() : "UNKNOWN") + "; reason: " +
+ reason + "; remote address: " + (remoteAddr != null ? remoteAddr : "") + "; request: " reason + "; remote address: " +
+ request + "; user: " + (user != null ? Bytes.toShort(user) : "null") + "; labels: " RpcServer.getRemoteAddress().map(InetAddress::toString).orElse("") + "; request: " +
+ labelAuthsStr + "; regex: " + regex); request + "; user: " + (user != null ? Bytes.toShort(user) : "null") + "; labels: " +
labelAuthsStr + "; regex: " + regex);
} }
} }

View File

@ -19,6 +19,8 @@ package org.apache.hadoop.hbase.security.visibility;
import static org.apache.hadoop.hbase.TagType.VISIBILITY_TAG_TYPE; import static org.apache.hadoop.hbase.TagType.VISIBILITY_TAG_TYPE;
import com.google.protobuf.ByteString;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -38,11 +40,9 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ArrayBackedTag; import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.Tag; import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.TagType; import org.apache.hadoop.hbase.TagType;
import org.apache.hadoop.hbase.TagUtil; import org.apache.hadoop.hbase.TagUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.exceptions.DeserializationException; import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.filter.Filter;
@ -60,11 +60,11 @@ import org.apache.hadoop.hbase.security.visibility.expression.ExpressionNode;
import org.apache.hadoop.hbase.security.visibility.expression.LeafExpressionNode; import org.apache.hadoop.hbase.security.visibility.expression.LeafExpressionNode;
import org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode; import org.apache.hadoop.hbase.security.visibility.expression.NonLeafExpressionNode;
import org.apache.hadoop.hbase.security.visibility.expression.Operator; import org.apache.hadoop.hbase.security.visibility.expression.Operator;
import com.google.protobuf.ByteString;
import org.apache.hadoop.hbase.util.ByteRange; import org.apache.hadoop.hbase.util.ByteRange;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.SimpleMutableByteRange; import org.apache.hadoop.hbase.util.SimpleMutableByteRange;
import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.util.ReflectionUtils;
import org.apache.yetus.audience.InterfaceAudience;
/** /**
* Utility method to support visibility * Utility method to support visibility
@ -283,10 +283,7 @@ public class VisibilityUtils {
* @throws IOException When there is IOE in getting the system user (During non-RPC handling). * @throws IOException When there is IOE in getting the system user (During non-RPC handling).
*/ */
public static User getActiveUser() throws IOException { public static User getActiveUser() throws IOException {
User user = RpcServer.getRequestUser(); User user = RpcServer.getRequestUser().orElse(User.getCurrent());
if (user == null) {
user = User.getCurrent();
}
if (LOG.isTraceEnabled()) { if (LOG.isTraceEnabled()) {
LOG.trace("Current active user name is " + user.getShortName()); LOG.trace("Current active user name is " + user.getShortName());
} }

View File

@ -114,7 +114,7 @@ public class TestProtobufRpcServiceImpl implements BlockingInterface {
@Override @Override
public AddrResponseProto addr(RpcController controller, EmptyRequestProto request) public AddrResponseProto addr(RpcController controller, EmptyRequestProto request)
throws ServiceException { throws ServiceException {
return AddrResponseProto.newBuilder().setAddr(RpcServer.getRemoteAddress().getHostAddress()) return AddrResponseProto.newBuilder()
.build(); .setAddr(RpcServer.getRemoteAddress().get().getHostAddress()).build();
} }
} }

View File

@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -169,6 +170,7 @@ public class TestSimpleRpcScheduler {
ServerCall call = mock(ServerCall.class); ServerCall call = mock(ServerCall.class);
CallRunner task = mock(CallRunner.class); CallRunner task = mock(CallRunner.class);
when(task.getRpcCall()).thenReturn(call); when(task.getRpcCall()).thenReturn(call);
when(call.getRequestUser()).thenReturn(Optional.empty());
return task; return task;
} }
@ -198,18 +200,21 @@ public class TestSimpleRpcScheduler {
RequestHeader smallHead = RequestHeader.newBuilder().setCallId(1).build(); RequestHeader smallHead = RequestHeader.newBuilder().setCallId(1).build();
when(smallCallTask.getRpcCall()).thenReturn(smallCall); when(smallCallTask.getRpcCall()).thenReturn(smallCall);
when(smallCall.getHeader()).thenReturn(smallHead); when(smallCall.getHeader()).thenReturn(smallHead);
when(smallCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner largeCallTask = mock(CallRunner.class); CallRunner largeCallTask = mock(CallRunner.class);
ServerCall largeCall = mock(ServerCall.class); ServerCall largeCall = mock(ServerCall.class);
RequestHeader largeHead = RequestHeader.newBuilder().setCallId(50).build(); RequestHeader largeHead = RequestHeader.newBuilder().setCallId(50).build();
when(largeCallTask.getRpcCall()).thenReturn(largeCall); when(largeCallTask.getRpcCall()).thenReturn(largeCall);
when(largeCall.getHeader()).thenReturn(largeHead); when(largeCall.getHeader()).thenReturn(largeHead);
when(largeCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner hugeCallTask = mock(CallRunner.class); CallRunner hugeCallTask = mock(CallRunner.class);
ServerCall hugeCall = mock(ServerCall.class); ServerCall hugeCall = mock(ServerCall.class);
RequestHeader hugeHead = RequestHeader.newBuilder().setCallId(100).build(); RequestHeader hugeHead = RequestHeader.newBuilder().setCallId(100).build();
when(hugeCallTask.getRpcCall()).thenReturn(hugeCall); when(hugeCallTask.getRpcCall()).thenReturn(hugeCall);
when(hugeCall.getHeader()).thenReturn(hugeHead); when(hugeCall.getHeader()).thenReturn(hugeHead);
when(hugeCall.getRequestUser()).thenReturn(Optional.empty());
when(priority.getDeadline(eq(smallHead), any(Message.class))).thenReturn(0L); when(priority.getDeadline(eq(smallHead), any(Message.class))).thenReturn(0L);
when(priority.getDeadline(eq(largeHead), any(Message.class))).thenReturn(50L); when(priority.getDeadline(eq(largeHead), any(Message.class))).thenReturn(50L);
@ -296,12 +301,14 @@ public class TestSimpleRpcScheduler {
when(putCallTask.getRpcCall()).thenReturn(putCall); when(putCallTask.getRpcCall()).thenReturn(putCall);
when(putCall.getHeader()).thenReturn(putHead); when(putCall.getHeader()).thenReturn(putHead);
when(putCall.getParam()).thenReturn(putCall.param); when(putCall.getParam()).thenReturn(putCall.param);
when(putCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner getCallTask = mock(CallRunner.class); CallRunner getCallTask = mock(CallRunner.class);
ServerCall getCall = mock(ServerCall.class); ServerCall getCall = mock(ServerCall.class);
RequestHeader getHead = RequestHeader.newBuilder().setMethodName("get").build(); RequestHeader getHead = RequestHeader.newBuilder().setMethodName("get").build();
when(getCallTask.getRpcCall()).thenReturn(getCall); when(getCallTask.getRpcCall()).thenReturn(getCall);
when(getCall.getHeader()).thenReturn(getHead); when(getCall.getHeader()).thenReturn(getHead);
when(getCall.getRequestUser()).thenReturn(Optional.empty());
CallRunner scanCallTask = mock(CallRunner.class); CallRunner scanCallTask = mock(CallRunner.class);
ServerCall scanCall = mock(ServerCall.class); ServerCall scanCall = mock(ServerCall.class);
@ -310,6 +317,7 @@ public class TestSimpleRpcScheduler {
when(scanCallTask.getRpcCall()).thenReturn(scanCall); when(scanCallTask.getRpcCall()).thenReturn(scanCall);
when(scanCall.getHeader()).thenReturn(scanHead); when(scanCall.getHeader()).thenReturn(scanHead);
when(scanCall.getParam()).thenReturn(scanCall.param); when(scanCall.getParam()).thenReturn(scanCall.param);
when(scanCall.getRequestUser()).thenReturn(Optional.empty());
ArrayList<Integer> work = new ArrayList<>(); ArrayList<Integer> work = new ArrayList<>();
doAnswerTaskExecution(putCallTask, work, 1, 1000); doAnswerTaskExecution(putCallTask, work, 1, 1000);
@ -387,6 +395,7 @@ public class TestSimpleRpcScheduler {
RequestHeader putHead = RequestHeader.newBuilder().setMethodName("mutate").build(); RequestHeader putHead = RequestHeader.newBuilder().setMethodName("mutate").build();
when(putCallTask.getRpcCall()).thenReturn(putCall); when(putCallTask.getRpcCall()).thenReturn(putCall);
when(putCall.getHeader()).thenReturn(putHead); when(putCall.getHeader()).thenReturn(putHead);
when(putCall.getRequestUser()).thenReturn(Optional.empty());
assertTrue(scheduler.dispatch(putCallTask)); assertTrue(scheduler.dispatch(putCallTask));

View File

@ -381,7 +381,7 @@ public class TestAccessController extends SecureTestUtil {
public Object run() throws Exception { public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName())); HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV, null), htd, null); ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV), htd, null);
return null; return null;
} }
}; };
@ -402,7 +402,7 @@ public class TestAccessController extends SecureTestUtil {
HTableDescriptor htd = new HTableDescriptor(TEST_TABLE); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
htd.addFamily(new HColumnDescriptor("fam_" + User.getCurrent().getShortName())); htd.addFamily(new HColumnDescriptor("fam_" + User.getCurrent().getShortName()));
ACCESS_CONTROLLER.preModifyTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preModifyTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE, htd); TEST_TABLE, htd);
return null; return null;
} }
@ -419,7 +419,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER ACCESS_CONTROLLER
.preDeleteTable(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE); .preDeleteTable(ObserverContext.createAndPrepare(CP_ENV), TEST_TABLE);
return null; return null;
} }
}; };
@ -435,7 +435,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER ACCESS_CONTROLLER
.preTruncateTable(ObserverContext.createAndPrepare(CP_ENV, null), .preTruncateTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE); TEST_TABLE);
return null; return null;
} }
@ -452,7 +452,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preAddColumnFamily(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE, ACCESS_CONTROLLER.preAddColumnFamily(ObserverContext.createAndPrepare(CP_ENV), TEST_TABLE,
hcd); hcd);
return null; return null;
} }
@ -470,7 +470,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preModifyColumnFamily(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preModifyColumnFamily(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE, hcd); TEST_TABLE, hcd);
return null; return null;
} }
@ -486,7 +486,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteColumnFamily(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteColumnFamily(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE, TEST_FAMILY); TEST_TABLE, TEST_FAMILY);
return null; return null;
} }
@ -502,7 +502,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction disableTable = new AccessTestAction() { AccessTestAction disableTable = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDisableTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE); TEST_TABLE);
return null; return null;
} }
@ -511,7 +511,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction disableAclTable = new AccessTestAction() { AccessTestAction disableAclTable = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDisableTable(ObserverContext.createAndPrepare(CP_ENV),
AccessControlLists.ACL_TABLE_NAME); AccessControlLists.ACL_TABLE_NAME);
return null; return null;
} }
@ -532,7 +532,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER ACCESS_CONTROLLER
.preEnableTable(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE); .preEnableTable(ObserverContext.createAndPrepare(CP_ENV), TEST_TABLE);
return null; return null;
} }
}; };
@ -614,7 +614,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER ACCESS_CONTROLLER
.preAbortProcedure(ObserverContext.createAndPrepare(CP_ENV, null), procExec, procId); .preAbortProcedure(ObserverContext.createAndPrepare(CP_ENV), procExec, procId);
return null; return null;
} }
}; };
@ -639,7 +639,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER ACCESS_CONTROLLER
.postGetProcedures(ObserverContext.createAndPrepare(CP_ENV, null), procList); .postGetProcedures(ObserverContext.createAndPrepare(CP_ENV), procList);
return null; return null;
} }
}; };
@ -655,7 +655,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preGetLocks(ObserverContext.createAndPrepare(CP_ENV, null)); ACCESS_CONTROLLER.preGetLocks(ObserverContext.createAndPrepare(CP_ENV));
return null; return null;
} }
}; };
@ -677,7 +677,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preMove(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preMove(ObserverContext.createAndPrepare(CP_ENV),
hri, server, server); hri, server, server);
return null; return null;
} }
@ -699,7 +699,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preAssign(ObserverContext.createAndPrepare(CP_ENV, null), hri); ACCESS_CONTROLLER.preAssign(ObserverContext.createAndPrepare(CP_ENV), hri);
return null; return null;
} }
}; };
@ -720,7 +720,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preUnassign(ObserverContext.createAndPrepare(CP_ENV, null), hri, false); ACCESS_CONTROLLER.preUnassign(ObserverContext.createAndPrepare(CP_ENV), hri, false);
return null; return null;
} }
}; };
@ -741,7 +741,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preRegionOffline(ObserverContext.createAndPrepare(CP_ENV, null), hri); ACCESS_CONTROLLER.preRegionOffline(ObserverContext.createAndPrepare(CP_ENV), hri);
return null; return null;
} }
}; };
@ -756,7 +756,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(ObserverContext.createAndPrepare(CP_ENV),
true, MasterSwitchType.MERGE); true, MasterSwitchType.MERGE);
return null; return null;
} }
@ -772,7 +772,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preBalance(ObserverContext.createAndPrepare(CP_ENV, null)); ACCESS_CONTROLLER.preBalance(ObserverContext.createAndPrepare(CP_ENV));
return null; return null;
} }
}; };
@ -787,7 +787,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preBalanceSwitch(ObserverContext.createAndPrepare(CP_ENV, null), true); ACCESS_CONTROLLER.preBalanceSwitch(ObserverContext.createAndPrepare(CP_ENV), true);
return null; return null;
} }
}; };
@ -802,7 +802,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preShutdown(ObserverContext.createAndPrepare(CP_ENV, null)); ACCESS_CONTROLLER.preShutdown(ObserverContext.createAndPrepare(CP_ENV));
return null; return null;
} }
}; };
@ -817,7 +817,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preStopMaster(ObserverContext.createAndPrepare(CP_ENV, null)); ACCESS_CONTROLLER.preStopMaster(ObserverContext.createAndPrepare(CP_ENV));
return null; return null;
} }
}; };
@ -841,7 +841,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSplitRegion( ACCESS_CONTROLLER.preSplitRegion(
ObserverContext.createAndPrepare(CP_ENV, null), ObserverContext.createAndPrepare(CP_ENV),
tableName, tableName,
TEST_ROW); TEST_ROW);
return null; return null;
@ -858,7 +858,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preFlush(ObserverContext.createAndPrepare(RCP_ENV, null)); ACCESS_CONTROLLER.preFlush(ObserverContext.createAndPrepare(RCP_ENV));
return null; return null;
} }
}; };
@ -873,7 +873,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preCompact(ObserverContext.createAndPrepare(RCP_ENV, null), null, null, ACCESS_CONTROLLER.preCompact(ObserverContext.createAndPrepare(RCP_ENV), null, null,
ScanType.COMPACT_RETAIN_DELETES, null, null); ScanType.COMPACT_RETAIN_DELETES, null, null);
return null; return null;
} }
@ -1939,7 +1939,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preStopRegionServer(ObserverContext.createAndPrepare(RSCP_ENV, null)); ACCESS_CONTROLLER.preStopRegionServer(ObserverContext.createAndPrepare(RSCP_ENV));
return null; return null;
} }
}; };
@ -1954,7 +1954,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContext.createAndPrepare(RSCP_ENV, null)); ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContext.createAndPrepare(RSCP_ENV));
return null; return null;
} }
}; };
@ -1969,7 +1969,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preOpen(ObserverContext.createAndPrepare(RCP_ENV, null)); ACCESS_CONTROLLER.preOpen(ObserverContext.createAndPrepare(RCP_ENV));
return null; return null;
} }
}; };
@ -1984,7 +1984,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preClose(ObserverContext.createAndPrepare(RCP_ENV, null), false); ACCESS_CONTROLLER.preClose(ObserverContext.createAndPrepare(RCP_ENV), false);
return null; return null;
} }
}; };
@ -2003,7 +2003,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction snapshotAction = new AccessTestAction() { AccessTestAction snapshotAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -2012,7 +2012,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction deleteAction = new AccessTestAction() { AccessTestAction deleteAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot); snapshot);
return null; return null;
} }
@ -2021,7 +2021,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction restoreAction = new AccessTestAction() { AccessTestAction restoreAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -2030,7 +2030,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction cloneAction = new AccessTestAction() { AccessTestAction cloneAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preCloneSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preCloneSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, null); snapshot, null);
return null; return null;
} }
@ -2063,7 +2063,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction snapshotAction = new AccessTestAction() { AccessTestAction snapshotAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -2075,7 +2075,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction deleteAction = new AccessTestAction() { AccessTestAction deleteAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot); snapshot);
return null; return null;
} }
@ -2087,7 +2087,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction restoreAction = new AccessTestAction() { AccessTestAction restoreAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -2099,7 +2099,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction cloneAction = new AccessTestAction() { AccessTestAction cloneAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preCloneSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preCloneSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -2655,7 +2655,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setUserQuotaAction = new AccessTestAction() { AccessTestAction setUserQuotaAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV),
null, null); null, null);
return null; return null;
} }
@ -2664,7 +2664,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setUserTableQuotaAction = new AccessTestAction() { AccessTestAction setUserTableQuotaAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV, null), null, ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV), null,
TEST_TABLE, null); TEST_TABLE, null);
return null; return null;
} }
@ -2673,7 +2673,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setUserNamespaceQuotaAction = new AccessTestAction() { AccessTestAction setUserNamespaceQuotaAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV),
null, (String)null, null); null, (String)null, null);
return null; return null;
} }
@ -2682,7 +2682,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setTableQuotaAction = new AccessTestAction() { AccessTestAction setTableQuotaAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetTableQuota(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetTableQuota(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE, null); TEST_TABLE, null);
return null; return null;
} }
@ -2691,7 +2691,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction setNamespaceQuotaAction = new AccessTestAction() { AccessTestAction setNamespaceQuotaAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContext.createAndPrepare(CP_ENV),
null, null); null, null);
return null; return null;
} }
@ -2874,14 +2874,14 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction prepareBulkLoadAction = new AccessTestAction() { AccessTestAction prepareBulkLoadAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.prePrepareBulkLoad(ObserverContext.createAndPrepare(RCP_ENV, null)); ACCESS_CONTROLLER.prePrepareBulkLoad(ObserverContext.createAndPrepare(RCP_ENV));
return null; return null;
} }
}; };
AccessTestAction cleanupBulkLoadAction = new AccessTestAction() { AccessTestAction cleanupBulkLoadAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preCleanupBulkLoad(ObserverContext.createAndPrepare(RCP_ENV, null)); ACCESS_CONTROLLER.preCleanupBulkLoad(ObserverContext.createAndPrepare(RCP_ENV));
return null; return null;
} }
}; };
@ -2894,8 +2894,8 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction replicateLogEntriesAction = new AccessTestAction() { AccessTestAction replicateLogEntriesAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV, null)); ACCESS_CONTROLLER.preReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV));
ACCESS_CONTROLLER.postReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV, null)); ACCESS_CONTROLLER.postReplicateLogEntries(ObserverContext.createAndPrepare(RSCP_ENV));
return null; return null;
} }
}; };
@ -2910,7 +2910,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action1 = new AccessTestAction() { AccessTestAction action1 = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preMoveServers(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preMoveServers(ObserverContext.createAndPrepare(CP_ENV),
null, null); null, null);
return null; return null;
} }
@ -2925,7 +2925,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action1 = new AccessTestAction() { AccessTestAction action1 = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preMoveTables(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preMoveTables(ObserverContext.createAndPrepare(CP_ENV),
null, null); null, null);
return null; return null;
} }
@ -2940,7 +2940,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action1 = new AccessTestAction() { AccessTestAction action1 = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preAddRSGroup(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preAddRSGroup(ObserverContext.createAndPrepare(CP_ENV),
null); null);
return null; return null;
} }
@ -2955,7 +2955,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action1 = new AccessTestAction() { AccessTestAction action1 = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preRemoveRSGroup(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preRemoveRSGroup(ObserverContext.createAndPrepare(CP_ENV),
null); null);
return null; return null;
} }
@ -2970,7 +2970,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action1 = new AccessTestAction() { AccessTestAction action1 = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preBalanceRSGroup(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preBalanceRSGroup(ObserverContext.createAndPrepare(CP_ENV),
null); null);
return null; return null;
} }
@ -2985,7 +2985,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preAddReplicationPeer(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preAddReplicationPeer(ObserverContext.createAndPrepare(CP_ENV),
"test", null); "test", null);
return null; return null;
} }
@ -3000,7 +3000,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preRemoveReplicationPeer(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preRemoveReplicationPeer(ObserverContext.createAndPrepare(CP_ENV),
"test"); "test");
return null; return null;
} }
@ -3015,7 +3015,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preEnableReplicationPeer(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preEnableReplicationPeer(ObserverContext.createAndPrepare(CP_ENV),
"test"); "test");
return null; return null;
} }
@ -3030,7 +3030,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableReplicationPeer(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDisableReplicationPeer(ObserverContext.createAndPrepare(CP_ENV),
"test"); "test");
return null; return null;
} }
@ -3046,7 +3046,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preGetReplicationPeerConfig( ACCESS_CONTROLLER.preGetReplicationPeerConfig(
ObserverContext.createAndPrepare(CP_ENV, null), "test"); ObserverContext.createAndPrepare(CP_ENV), "test");
return null; return null;
} }
}; };
@ -3061,7 +3061,7 @@ public class TestAccessController extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preUpdateReplicationPeerConfig( ACCESS_CONTROLLER.preUpdateReplicationPeerConfig(
ObserverContext.createAndPrepare(CP_ENV, null), "test", new ReplicationPeerConfig()); ObserverContext.createAndPrepare(CP_ENV), "test", new ReplicationPeerConfig());
return null; return null;
} }
}; };
@ -3075,7 +3075,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction action = new AccessTestAction() { AccessTestAction action = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preListReplicationPeers(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preListReplicationPeers(ObserverContext.createAndPrepare(CP_ENV),
"test"); "test");
return null; return null;
} }
@ -3106,7 +3106,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction namespaceLockAction = new AccessTestAction() { AccessTestAction namespaceLockAction = new AccessTestAction() {
@Override public Object run() throws Exception { @Override public Object run() throws Exception {
ACCESS_CONTROLLER.preRequestLock(ObserverContext.createAndPrepare(CP_ENV, null), namespace, ACCESS_CONTROLLER.preRequestLock(ObserverContext.createAndPrepare(CP_ENV), namespace,
null, null, LockType.EXCLUSIVE, null); null, null, LockType.EXCLUSIVE, null);
return null; return null;
} }
@ -3118,7 +3118,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction tableLockAction = new AccessTestAction() { AccessTestAction tableLockAction = new AccessTestAction() {
@Override public Object run() throws Exception { @Override public Object run() throws Exception {
ACCESS_CONTROLLER.preRequestLock(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preRequestLock(ObserverContext.createAndPrepare(CP_ENV),
null, tableName, null, LockType.EXCLUSIVE, null); null, tableName, null, LockType.EXCLUSIVE, null);
return null; return null;
} }
@ -3131,7 +3131,7 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction regionsLockAction = new AccessTestAction() { AccessTestAction regionsLockAction = new AccessTestAction() {
@Override public Object run() throws Exception { @Override public Object run() throws Exception {
ACCESS_CONTROLLER.preRequestLock(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preRequestLock(ObserverContext.createAndPrepare(CP_ENV),
null, null, regionInfos, LockType.EXCLUSIVE, null); null, null, regionInfos, LockType.EXCLUSIVE, null);
return null; return null;
} }
@ -3145,7 +3145,7 @@ public class TestAccessController extends SecureTestUtil {
LockProcedure proc = new LockProcedure(conf, tableName, LockType.EXCLUSIVE, "test", null); LockProcedure proc = new LockProcedure(conf, tableName, LockType.EXCLUSIVE, "test", null);
AccessTestAction regionLockHeartbeatAction = new AccessTestAction() { AccessTestAction regionLockHeartbeatAction = new AccessTestAction() {
@Override public Object run() throws Exception { @Override public Object run() throws Exception {
ACCESS_CONTROLLER.preLockHeartbeat(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preLockHeartbeat(ObserverContext.createAndPrepare(CP_ENV),
proc, false); proc, false);
return null; return null;
} }

View File

@ -30,7 +30,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
@ -288,7 +287,7 @@ public class TestAccessController3 extends SecureTestUtil {
public Object run() throws Exception { public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName())); HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV, null), htd, null); ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV), htd, null);
return null; return null;
} }
}; };

View File

@ -242,7 +242,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction modifyNamespace = new AccessTestAction() { AccessTestAction modifyNamespace = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preModifyNamespace(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preModifyNamespace(ObserverContext.createAndPrepare(CP_ENV),
NamespaceDescriptor.create(TEST_NAMESPACE).addConfiguration("abc", "156").build()); NamespaceDescriptor.create(TEST_NAMESPACE).addConfiguration("abc", "156").build());
return null; return null;
} }
@ -260,7 +260,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction createNamespace = new AccessTestAction() { AccessTestAction createNamespace = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preCreateNamespace(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preCreateNamespace(ObserverContext.createAndPrepare(CP_ENV),
NamespaceDescriptor.create(TEST_NAMESPACE2).build()); NamespaceDescriptor.create(TEST_NAMESPACE2).build());
return null; return null;
} }
@ -269,7 +269,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction deleteNamespace = new AccessTestAction() { AccessTestAction deleteNamespace = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteNamespace(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteNamespace(ObserverContext.createAndPrepare(CP_ENV),
TEST_NAMESPACE2); TEST_NAMESPACE2);
return null; return null;
} }
@ -294,7 +294,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
AccessTestAction getNamespaceAction = new AccessTestAction() { AccessTestAction getNamespaceAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContext.createAndPrepare(CP_ENV),
TEST_NAMESPACE); TEST_NAMESPACE);
return null; return null;
} }
@ -484,7 +484,7 @@ public class TestNamespaceCommands extends SecureTestUtil {
public Object run() throws Exception { public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TEST_TABLE)); HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TEST_TABLE));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV, null), htd, null); ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV), htd, null);
return null; return null;
} }
}; };

View File

@ -483,7 +483,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception { public Object run() throws Exception {
HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV, null), htd, ACCESS_CONTROLLER.preCreateTable(ObserverContext.createAndPrepare(CP_ENV), htd,
null); null);
return null; return null;
} }
@ -496,7 +496,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
htd.addFamily(new HColumnDescriptor(TEST_FAMILY2)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY2));
ACCESS_CONTROLLER.preModifyTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preModifyTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName(), htd); TEST_TABLE.getTableName(), htd);
return null; return null;
} }
@ -506,7 +506,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName()); TEST_TABLE.getTableName());
return null; return null;
} }
@ -516,7 +516,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preTruncateTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preTruncateTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName()); TEST_TABLE.getTableName());
return null; return null;
} }
@ -527,7 +527,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2); HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2);
ACCESS_CONTROLLER.preAddColumnFamily(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preAddColumnFamily(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName(), hcd); TEST_TABLE.getTableName(), hcd);
return null; return null;
} }
@ -538,7 +538,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2); HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2);
ACCESS_CONTROLLER.preModifyColumnFamily(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preModifyColumnFamily(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName(), hcd); TEST_TABLE.getTableName(), hcd);
return null; return null;
} }
@ -548,7 +548,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteColumnFamily(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteColumnFamily(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName(), TEST_FAMILY2); TEST_TABLE.getTableName(), TEST_FAMILY2);
return null; return null;
} }
@ -558,7 +558,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preEnableTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preEnableTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName()); TEST_TABLE.getTableName());
return null; return null;
} }
@ -568,7 +568,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDisableTable(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDisableTable(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName()); TEST_TABLE.getTableName());
return null; return null;
} }
@ -581,7 +581,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName()); HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName());
ServerName srcServer = ServerName.valueOf("1.1.1.1", 1, 0); ServerName srcServer = ServerName.valueOf("1.1.1.1", 1, 0);
ServerName destServer = ServerName.valueOf("2.2.2.2", 2, 0); ServerName destServer = ServerName.valueOf("2.2.2.2", 2, 0);
ACCESS_CONTROLLER.preMove(ObserverContext.createAndPrepare(CP_ENV, null), region, ACCESS_CONTROLLER.preMove(ObserverContext.createAndPrepare(CP_ENV), region,
srcServer, destServer); srcServer, destServer);
return null; return null;
} }
@ -592,7 +592,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName()); HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName());
ACCESS_CONTROLLER.preAssign(ObserverContext.createAndPrepare(CP_ENV, null), region); ACCESS_CONTROLLER.preAssign(ObserverContext.createAndPrepare(CP_ENV), region);
return null; return null;
} }
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
@ -602,7 +602,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName()); HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName());
ACCESS_CONTROLLER.preUnassign(ObserverContext.createAndPrepare(CP_ENV, null), region, ACCESS_CONTROLLER.preUnassign(ObserverContext.createAndPrepare(CP_ENV), region,
true); true);
return null; return null;
} }
@ -612,7 +612,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preBalance(ObserverContext.createAndPrepare(CP_ENV, null)); ACCESS_CONTROLLER.preBalance(ObserverContext.createAndPrepare(CP_ENV));
return null; return null;
} }
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
@ -621,7 +621,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preBalanceSwitch(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preBalanceSwitch(ObserverContext.createAndPrepare(CP_ENV),
true); true);
return null; return null;
} }
@ -633,7 +633,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception { public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo"); SnapshotDescription snapshot = new SnapshotDescription("foo");
HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
ACCESS_CONTROLLER.preSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -644,7 +644,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo"); SnapshotDescription snapshot = new SnapshotDescription("foo");
ACCESS_CONTROLLER.preListSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preListSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot); snapshot);
return null; return null;
} }
@ -656,7 +656,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception { public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo"); SnapshotDescription snapshot = new SnapshotDescription("foo");
HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
ACCESS_CONTROLLER.preCloneSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preCloneSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -668,7 +668,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public Object run() throws Exception { public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo"); SnapshotDescription snapshot = new SnapshotDescription("foo");
HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot, htd); snapshot, htd);
return null; return null;
} }
@ -679,7 +679,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
SnapshotDescription snapshot = new SnapshotDescription("foo"); SnapshotDescription snapshot = new SnapshotDescription("foo");
ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteSnapshot(ObserverContext.createAndPrepare(CP_ENV),
snapshot); snapshot);
return null; return null;
} }
@ -692,7 +692,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
List<TableName> tableNamesList = Lists.newArrayList(); List<TableName> tableNamesList = Lists.newArrayList();
tableNamesList.add(TEST_TABLE.getTableName()); tableNamesList.add(TEST_TABLE.getTableName());
List<TableDescriptor> descriptors = Lists.newArrayList(); List<TableDescriptor> descriptors = Lists.newArrayList();
ACCESS_CONTROLLER.preGetTableDescriptors(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preGetTableDescriptors(ObserverContext.createAndPrepare(CP_ENV),
tableNamesList, descriptors, ".+"); tableNamesList, descriptors, ".+");
return null; return null;
} }
@ -703,7 +703,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
List<TableDescriptor> descriptors = Lists.newArrayList(); List<TableDescriptor> descriptors = Lists.newArrayList();
ACCESS_CONTROLLER.preGetTableNames(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preGetTableNames(ObserverContext.createAndPrepare(CP_ENV),
descriptors, ".+"); descriptors, ".+");
return null; return null;
} }
@ -714,7 +714,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
NamespaceDescriptor ns = NamespaceDescriptor.create("test").build(); NamespaceDescriptor ns = NamespaceDescriptor.create("test").build();
ACCESS_CONTROLLER.preCreateNamespace(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preCreateNamespace(ObserverContext.createAndPrepare(CP_ENV),
ns); ns);
return null; return null;
} }
@ -724,7 +724,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDeleteNamespace(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preDeleteNamespace(ObserverContext.createAndPrepare(CP_ENV),
"test"); "test");
return null; return null;
} }
@ -735,7 +735,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
NamespaceDescriptor ns = NamespaceDescriptor.create("test").build(); NamespaceDescriptor ns = NamespaceDescriptor.create("test").build();
ACCESS_CONTROLLER.preModifyNamespace(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preModifyNamespace(ObserverContext.createAndPrepare(CP_ENV),
ns); ns);
return null; return null;
} }
@ -745,8 +745,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContext.createAndPrepare(CP_ENV, ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContext.createAndPrepare(CP_ENV),
null),
"test"); "test");
return null; return null;
} }
@ -757,8 +756,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
List<NamespaceDescriptor> descriptors = Lists.newArrayList(); List<NamespaceDescriptor> descriptors = Lists.newArrayList();
ACCESS_CONTROLLER.preListNamespaceDescriptors(ObserverContext.createAndPrepare(CP_ENV, ACCESS_CONTROLLER.preListNamespaceDescriptors(ObserverContext.createAndPrepare(CP_ENV),
null),
descriptors); descriptors);
return null; return null;
} }
@ -769,7 +767,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSplitRegion( ACCESS_CONTROLLER.preSplitRegion(
ObserverContext.createAndPrepare(CP_ENV, null), ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName(), TEST_TABLE.getTableName(),
Bytes.toBytes("ss")); Bytes.toBytes("ss"));
return null; return null;
@ -780,7 +778,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetUserQuota(ObserverContext.createAndPrepare(CP_ENV),
"testuser", null); "testuser", null);
return null; return null;
} }
@ -790,7 +788,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetTableQuota(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetTableQuota(ObserverContext.createAndPrepare(CP_ENV),
TEST_TABLE.getTableName(), null); TEST_TABLE.getTableName(), null);
return null; return null;
} }
@ -800,7 +798,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContext.createAndPrepare(CP_ENV, null), ACCESS_CONTROLLER.preSetNamespaceQuota(ObserverContext.createAndPrepare(CP_ENV),
"test", null); "test", null);
return null; return null;
} }
@ -815,7 +813,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preStopRegionServer(ObserverContext.createAndPrepare(RSCP_ENV, null)); ACCESS_CONTROLLER.preStopRegionServer(ObserverContext.createAndPrepare(RSCP_ENV));
return null; return null;
} }
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
@ -824,8 +822,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContext.createAndPrepare(RSCP_ENV, ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContext.createAndPrepare(RSCP_ENV));
null));
return null; return null;
} }
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
@ -840,7 +837,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preOpen(ObserverContext.createAndPrepare(RCP_ENV, null)); ACCESS_CONTROLLER.preOpen(ObserverContext.createAndPrepare(RCP_ENV));
return null; return null;
} }
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
@ -849,7 +846,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preFlush(ObserverContext.createAndPrepare(RCP_ENV, null)); ACCESS_CONTROLLER.preFlush(ObserverContext.createAndPrepare(RCP_ENV));
return null; return null;
} }
}, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);
@ -859,7 +856,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
List<Cell> cells = Lists.newArrayList(); List<Cell> cells = Lists.newArrayList();
ACCESS_CONTROLLER.preGetOp(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preGetOp(ObserverContext.createAndPrepare(RCP_ENV),
new Get(TEST_ROW), cells); new Get(TEST_ROW), cells);
return null; return null;
} }
@ -869,7 +866,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preExists(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preExists(ObserverContext.createAndPrepare(RCP_ENV),
new Get(TEST_ROW), true); new Get(TEST_ROW), true);
return null; return null;
} }
@ -879,7 +876,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.prePut(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.prePut(ObserverContext.createAndPrepare(RCP_ENV),
new Put(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT); new Put(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT);
return null; return null;
} }
@ -889,7 +886,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preDelete(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preDelete(ObserverContext.createAndPrepare(RCP_ENV),
new Delete(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT); new Delete(TEST_ROW), new WALEdit(), Durability.USE_DEFAULT);
return null; return null;
} }
@ -899,7 +896,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preBatchMutate(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preBatchMutate(ObserverContext.createAndPrepare(RCP_ENV),
new MiniBatchOperationInProgress<>(null, null, null, 0, 0)); new MiniBatchOperationInProgress<>(null, null, null, 0, 0));
return null; return null;
} }
@ -909,7 +906,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preCheckAndPut(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preCheckAndPut(ObserverContext.createAndPrepare(RCP_ENV),
TEST_ROW, TEST_FAMILY, TEST_Q1, CompareOperator.EQUAL, TEST_ROW, TEST_FAMILY, TEST_Q1, CompareOperator.EQUAL,
new BinaryComparator("foo".getBytes()), new Put(TEST_ROW), true); new BinaryComparator("foo".getBytes()), new Put(TEST_ROW), true);
return null; return null;
@ -920,7 +917,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preCheckAndDelete(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preCheckAndDelete(ObserverContext.createAndPrepare(RCP_ENV),
TEST_ROW, TEST_FAMILY, TEST_Q1, CompareOperator.EQUAL, TEST_ROW, TEST_FAMILY, TEST_Q1, CompareOperator.EQUAL,
new BinaryComparator("foo".getBytes()), new Delete(TEST_ROW), true); new BinaryComparator("foo".getBytes()), new Delete(TEST_ROW), true);
return null; return null;
@ -931,7 +928,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preAppend(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preAppend(ObserverContext.createAndPrepare(RCP_ENV),
new Append(TEST_ROW)); new Append(TEST_ROW));
return null; return null;
} }
@ -941,7 +938,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preIncrement(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preIncrement(ObserverContext.createAndPrepare(RCP_ENV),
new Increment(TEST_ROW)); new Increment(TEST_ROW));
return null; return null;
} }
@ -951,7 +948,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
verifyAllowed(new AccessTestAction() { verifyAllowed(new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
ACCESS_CONTROLLER.preScannerOpen(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preScannerOpen(ObserverContext.createAndPrepare(RCP_ENV),
new Scan(), mock(RegionScanner.class)); new Scan(), mock(RegionScanner.class));
return null; return null;
} }
@ -962,7 +959,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
List<Pair<byte[], String>> paths = Lists.newArrayList(); List<Pair<byte[], String>> paths = Lists.newArrayList();
ACCESS_CONTROLLER.preBulkLoadHFile(ObserverContext.createAndPrepare(RCP_ENV, null), ACCESS_CONTROLLER.preBulkLoadHFile(ObserverContext.createAndPrepare(RCP_ENV),
paths); paths);
return null; return null;
} }