|
17 | 17 | */
|
18 | 18 | package org.apache.drill.exec.store.phoenix.secured;
|
19 | 19 |
|
20 |
| -import static org.apache.hadoop.hbase.HConstants.HBASE_DIR; |
21 |
| -import static org.junit.Assert.assertNotNull; |
22 |
| -import static org.junit.Assert.assertTrue; |
23 |
| - |
24 |
| -import java.io.File; |
25 |
| -import java.io.IOException; |
26 |
| -import java.lang.reflect.Field; |
27 |
| -import java.net.InetAddress; |
28 |
| -import java.util.AbstractMap; |
29 |
| -import java.util.ArrayList; |
30 |
| -import java.util.List; |
31 |
| -import java.util.Map; |
32 |
| -import java.util.UUID; |
33 |
| - |
34 | 20 | import org.apache.commons.io.FileUtils;
|
35 | 21 | import org.apache.hadoop.conf.Configuration;
|
36 | 22 | import org.apache.hadoop.fs.Path;
|
37 | 23 | import org.apache.hadoop.hbase.HBaseConfiguration;
|
38 | 24 | import org.apache.hadoop.hbase.HBaseTestingUtility;
|
39 | 25 | import org.apache.hadoop.hbase.HConstants;
|
40 | 26 | import org.apache.hadoop.hbase.LocalHBaseCluster;
|
| 27 | +import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; |
41 | 28 | import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
|
42 | 29 | import org.apache.hadoop.hbase.security.User;
|
| 30 | +import org.apache.hadoop.hbase.security.access.AccessController; |
| 31 | +import org.apache.hadoop.hbase.security.token.TokenProvider; |
43 | 32 | import org.apache.hadoop.hdfs.DFSConfigKeys;
|
44 | 33 | import org.apache.hadoop.http.HttpConfig;
|
45 | 34 | import org.apache.hadoop.minikdc.MiniKdc;
|
|
49 | 38 | import org.apache.phoenix.util.InstanceResolver;
|
50 | 39 | import org.apache.phoenix.util.PhoenixRuntime;
|
51 | 40 |
|
| 41 | +import java.io.File; |
| 42 | +import java.io.IOException; |
| 43 | +import java.lang.reflect.Field; |
| 44 | +import java.net.InetAddress; |
| 45 | +import java.util.AbstractMap; |
| 46 | +import java.util.ArrayList; |
| 47 | +import java.util.List; |
| 48 | +import java.util.Map; |
| 49 | +import java.util.UUID; |
| 50 | + |
| 51 | +import static org.apache.hadoop.hbase.HConstants.HBASE_DIR; |
| 52 | +import static org.junit.Assert.assertNotNull; |
| 53 | +import static org.junit.Assert.assertTrue; |
| 54 | + |
52 | 55 | /**
|
53 | 56 | * This is a copy of class from `org.apache.phoenix:phoenix-queryserver-it`,
|
54 | 57 | * see original javadoc in {@code org.apache.phoenix.end2end.QueryServerEnvironment}.
|
@@ -195,8 +198,7 @@ private static void ensureIsEmptyDirectory(File f) throws IOException {
|
195 | 198 | /**
|
196 | 199 | * Setup and start kerberosed, hbase
|
197 | 200 | */
|
198 |
| - public PhoenixEnvironment(final Configuration confIn, int numberOfUsers, boolean tls) |
199 |
| - throws Exception { |
| 201 | + public PhoenixEnvironment(final Configuration confIn, int numberOfUsers, boolean tls) throws Exception { |
200 | 202 |
|
201 | 203 | Configuration conf = util.getConfiguration();
|
202 | 204 | conf.addResource(confIn);
|
@@ -228,6 +230,26 @@ public PhoenixEnvironment(final Configuration confIn, int numberOfUsers, boolean
|
228 | 230 | conf.setInt(HConstants.REGIONSERVER_PORT, 0);
|
229 | 231 | conf.setInt(HConstants.REGIONSERVER_INFO_PORT, 0);
|
230 | 232 |
|
| 233 | + conf.set("hadoop.security.authentication", "kerberos"); |
| 234 | + conf.set("hbase.security.authentication", "kerberos"); |
| 235 | + |
| 236 | + File serviceKeytab = getServiceKeytab(); // already generated by your MiniKdc setup |
| 237 | + String servicePrincipal = HBaseKerberosUtils.getPrincipalForTesting(); |
| 238 | + if (serviceKeytab == null || servicePrincipal == null) { |
| 239 | + throw new IllegalStateException("MiniKdc did not provide service keytab/principal"); |
| 240 | + } |
| 241 | + |
| 242 | + conf.set("hbase.master.keytab.file", serviceKeytab.getAbsolutePath()); |
| 243 | + conf.set("hbase.regionserver.keytab.file", serviceKeytab.getAbsolutePath()); |
| 244 | + conf.set("hbase.master.kerberos.principal", servicePrincipal); |
| 245 | + conf.set("hbase.regionserver.kerberos.principal", servicePrincipal); |
| 246 | + |
| 247 | + // Coprocessors, proxy user configs, etc. (whatever you already have) |
| 248 | + conf.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, AccessController.class.getName()); |
| 249 | + conf.setStrings(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, AccessController.class.getName()); |
| 250 | + conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, |
| 251 | + AccessController.class.getName(), TokenProvider.class.getName()); |
| 252 | + |
231 | 253 | // Clear the cached singletons so we can inject our own.
|
232 | 254 | InstanceResolver.clearSingletons();
|
233 | 255 | // Make sure the ConnectionInfo doesn't try to pull a default Configuration
|
|
0 commit comments