Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,6 @@
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.coprocessor.BaseMasterAndRegionObserver;
import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
Expand All@@ -56,6 +55,7 @@
import org.apache.hadoop.hbase.security.access.UserPermission;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.phoenix.compat.hbase.CompatObserverContext;
import org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost.PhoenixMetaDataControllerEnvironment;
import org.apache.phoenix.query.QueryServices;
Expand All@@ -64,6 +64,7 @@
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.util.MetaDataUtil;
import org.apache.phoenix.util.ServerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand DownExpand Up@@ -277,7 +278,8 @@ private void grantPermissions(final String toUser, final byte[] table, final Act
User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
try (Connection conn = ConnectionFactory.createConnection(env.getConfiguration())) {
try (Connection conn = ServerUtil.ConnectionFactory.getConnection(ServerUtil.ConnectionType.DEFAULT_SERVER_CONNECTION,
env.getConfiguration(), (HRegionServer)env.getRegionServerServices())) {
AccessControlClient.grant(conn, TableName.valueOf(table), toUser , null, null,
actions);
} catch (Throwable e) {
Expand All@@ -294,7 +296,7 @@ private void authorizeOrGrantAccessToUsers(final String request, final TableName
User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws IOException {
try (Connection conn = ConnectionFactory.createConnection(env.getConfiguration())) {
try {
List<UserPermission> userPermissions = getUserPermissions(fromTable);
List<UserPermission> permissionsOnTheTable = getUserPermissions(toTable);
if (userPermissions != null) {
Expand DownExpand Up@@ -339,6 +341,8 @@ public Void run() throws IOException {
}
}
}
} catch (Throwable e) {
throw e;
}
return null;
}
Expand DownExpand Up@@ -478,7 +482,8 @@ private List<UserPermission> getUserPermissions(final TableName tableName) throw
public List<UserPermission> run() throws Exception {
final List<UserPermission> userPermissions = new ArrayList<UserPermission>();
final RpcServer.Call rpcContext = RpcUtil.getRpcContext();
try (Connection connection = ConnectionFactory.createConnection(env.getConfiguration())) {
try (Connection connection = ServerUtil.ConnectionFactory.getConnection(ServerUtil.ConnectionType.DEFAULT_SERVER_CONNECTION,
env.getConfiguration(), (HRegionServer)env.getRegionServerServices())) {
// Setting RPC context as null so that user can be resetted
RpcUtil.setRpcContext(null);
// Merge permissions from all accessController coprocessors loaded in memory
Expand DownExpand Up@@ -512,8 +517,8 @@ private void getUserDefinedPermissions(final TableName tableName, final List<Use
@Override
public List<UserPermission> run() throws Exception {
final RpcServer.Call rpcContext = RpcUtil.getRpcContext();
try (Connection connection =
ConnectionFactory.createConnection(env.getConfiguration())) {
try (Connection connection = ServerUtil.ConnectionFactory.getConnection(ServerUtil.ConnectionType.DEFAULT_SERVER_CONNECTION,
env.getConfiguration(), (HRegionServer)env.getRegionServerServices())) {
// Setting RPC context as null so that user can be resetted
RpcUtil.setRpcContext(null);
for (BaseMasterAndRegionObserver service : getAccessControllers()) {
Expand Down