|
@@ -24,9 +24,11 @@ import org.apache.hadoop.crypto.key.KeyProvider;
|
|
import org.apache.hadoop.crypto.key.KeyProvider.KeyVersion;
|
|
import org.apache.hadoop.crypto.key.KeyProvider.KeyVersion;
|
|
import org.apache.hadoop.crypto.key.KeyProvider.Options;
|
|
import org.apache.hadoop.crypto.key.KeyProvider.Options;
|
|
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
|
|
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
|
|
|
|
+import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension.CryptoExtension;
|
|
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension.EncryptedKeyVersion;
|
|
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension.EncryptedKeyVersion;
|
|
import org.apache.hadoop.crypto.key.KeyProviderDelegationTokenExtension;
|
|
import org.apache.hadoop.crypto.key.KeyProviderDelegationTokenExtension;
|
|
import org.apache.hadoop.crypto.key.kms.KMSClientProvider;
|
|
import org.apache.hadoop.crypto.key.kms.KMSClientProvider;
|
|
|
|
+import org.apache.hadoop.crypto.key.kms.LoadBalancingKMSClientProvider;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.io.Text;
|
|
import org.apache.hadoop.io.Text;
|
|
import org.apache.hadoop.minikdc.MiniKdc;
|
|
import org.apache.hadoop.minikdc.MiniKdc;
|
|
@@ -99,6 +101,12 @@ public class TestKMS {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected KeyProvider createProvider(URI uri, Configuration conf)
|
|
|
|
+ throws IOException {
|
|
|
|
+ return new LoadBalancingKMSClientProvider(
|
|
|
|
+ new KMSClientProvider[] { new KMSClientProvider(uri, conf) }, conf);
|
|
|
|
+ }
|
|
|
|
+
|
|
protected <T> T runServer(String keystore, String password, File confDir,
|
|
protected <T> T runServer(String keystore, String password, File confDir,
|
|
KMSCallable<T> callable) throws Exception {
|
|
KMSCallable<T> callable) throws Exception {
|
|
return runServer(-1, keystore, password, confDir, callable);
|
|
return runServer(-1, keystore, password, confDir, callable);
|
|
@@ -305,7 +313,7 @@ public class TestKMS {
|
|
final URI uri = createKMSUri(getKMSUrl());
|
|
final URI uri = createKMSUri(getKMSUrl());
|
|
|
|
|
|
if (ssl) {
|
|
if (ssl) {
|
|
- KeyProvider testKp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider testKp = createProvider(uri, conf);
|
|
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
|
|
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
|
|
while (threadGroup.getParent() != null) {
|
|
while (threadGroup.getParent() != null) {
|
|
threadGroup = threadGroup.getParent();
|
|
threadGroup = threadGroup.getParent();
|
|
@@ -335,12 +343,14 @@ public class TestKMS {
|
|
doAs(user, new PrivilegedExceptionAction<Void>() {
|
|
doAs(user, new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- final KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ final KeyProvider kp = createProvider(uri, conf);
|
|
// getKeys() empty
|
|
// getKeys() empty
|
|
Assert.assertTrue(kp.getKeys().isEmpty());
|
|
Assert.assertTrue(kp.getKeys().isEmpty());
|
|
|
|
|
|
Thread.sleep(4000);
|
|
Thread.sleep(4000);
|
|
- Token<?>[] tokens = ((KMSClientProvider)kp).addDelegationTokens("myuser", new Credentials());
|
|
|
|
|
|
+ Token<?>[] tokens =
|
|
|
|
+ ((KeyProviderDelegationTokenExtension.DelegationTokenExtension)kp)
|
|
|
|
+ .addDelegationTokens("myuser", new Credentials());
|
|
Assert.assertEquals(1, tokens.length);
|
|
Assert.assertEquals(1, tokens.length);
|
|
Assert.assertEquals("kms-dt", tokens[0].getKind().toString());
|
|
Assert.assertEquals("kms-dt", tokens[0].getKind().toString());
|
|
return null;
|
|
return null;
|
|
@@ -348,12 +358,14 @@ public class TestKMS {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
// getKeys() empty
|
|
// getKeys() empty
|
|
Assert.assertTrue(kp.getKeys().isEmpty());
|
|
Assert.assertTrue(kp.getKeys().isEmpty());
|
|
|
|
|
|
Thread.sleep(4000);
|
|
Thread.sleep(4000);
|
|
- Token<?>[] tokens = ((KMSClientProvider)kp).addDelegationTokens("myuser", new Credentials());
|
|
|
|
|
|
+ Token<?>[] tokens =
|
|
|
|
+ ((KeyProviderDelegationTokenExtension.DelegationTokenExtension)kp)
|
|
|
|
+ .addDelegationTokens("myuser", new Credentials());
|
|
Assert.assertEquals(1, tokens.length);
|
|
Assert.assertEquals(1, tokens.length);
|
|
Assert.assertEquals("kms-dt", tokens[0].getKind().toString());
|
|
Assert.assertEquals("kms-dt", tokens[0].getKind().toString());
|
|
}
|
|
}
|
|
@@ -404,7 +416,7 @@ public class TestKMS {
|
|
Date started = new Date();
|
|
Date started = new Date();
|
|
Configuration conf = new Configuration();
|
|
Configuration conf = new Configuration();
|
|
URI uri = createKMSUri(getKMSUrl());
|
|
URI uri = createKMSUri(getKMSUrl());
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
|
|
|
|
// getKeys() empty
|
|
// getKeys() empty
|
|
Assert.assertTrue(kp.getKeys().isEmpty());
|
|
Assert.assertTrue(kp.getKeys().isEmpty());
|
|
@@ -687,7 +699,7 @@ public class TestKMS {
|
|
doAs("CREATE", new PrivilegedExceptionAction<Void>() {
|
|
doAs("CREATE", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
Options options = new KeyProvider.Options(conf);
|
|
Options options = new KeyProvider.Options(conf);
|
|
Map<String, String> attributes = options.getAttributes();
|
|
Map<String, String> attributes = options.getAttributes();
|
|
@@ -727,7 +739,7 @@ public class TestKMS {
|
|
doAs("DECRYPT_EEK", new PrivilegedExceptionAction<Void>() {
|
|
doAs("DECRYPT_EEK", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
Options options = new KeyProvider.Options(conf);
|
|
Options options = new KeyProvider.Options(conf);
|
|
Map<String, String> attributes = options.getAttributes();
|
|
Map<String, String> attributes = options.getAttributes();
|
|
@@ -760,7 +772,7 @@ public class TestKMS {
|
|
doAs("ROLLOVER", new PrivilegedExceptionAction<Void>() {
|
|
doAs("ROLLOVER", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
Options options = new KeyProvider.Options(conf);
|
|
Options options = new KeyProvider.Options(conf);
|
|
Map<String, String> attributes = options.getAttributes();
|
|
Map<String, String> attributes = options.getAttributes();
|
|
@@ -804,7 +816,7 @@ public class TestKMS {
|
|
doAs("GET", new PrivilegedExceptionAction<Void>() {
|
|
doAs("GET", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
Options options = new KeyProvider.Options(conf);
|
|
Options options = new KeyProvider.Options(conf);
|
|
Map<String, String> attributes = options.getAttributes();
|
|
Map<String, String> attributes = options.getAttributes();
|
|
@@ -836,7 +848,7 @@ public class TestKMS {
|
|
final EncryptedKeyVersion ekv = doAs("GENERATE_EEK", new PrivilegedExceptionAction<EncryptedKeyVersion>() {
|
|
final EncryptedKeyVersion ekv = doAs("GENERATE_EEK", new PrivilegedExceptionAction<EncryptedKeyVersion>() {
|
|
@Override
|
|
@Override
|
|
public EncryptedKeyVersion run() throws Exception {
|
|
public EncryptedKeyVersion run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
Options options = new KeyProvider.Options(conf);
|
|
Options options = new KeyProvider.Options(conf);
|
|
Map<String, String> attributes = options.getAttributes();
|
|
Map<String, String> attributes = options.getAttributes();
|
|
@@ -861,7 +873,7 @@ public class TestKMS {
|
|
doAs("ROLLOVER", new PrivilegedExceptionAction<Void>() {
|
|
doAs("ROLLOVER", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProviderCryptoExtension kpce =
|
|
KeyProviderCryptoExtension kpce =
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp);
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp);
|
|
@@ -891,7 +903,7 @@ public class TestKMS {
|
|
doAs("GENERATE_EEK", new PrivilegedExceptionAction<Void>() {
|
|
doAs("GENERATE_EEK", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProviderCryptoExtension kpce =
|
|
KeyProviderCryptoExtension kpce =
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp);
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp);
|
|
@@ -964,7 +976,7 @@ public class TestKMS {
|
|
new PrivilegedExceptionAction<KeyProvider>() {
|
|
new PrivilegedExceptionAction<KeyProvider>() {
|
|
@Override
|
|
@Override
|
|
public KeyProvider run() throws Exception {
|
|
public KeyProvider run() throws Exception {
|
|
- KMSClientProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey("k1", new byte[16],
|
|
kp.createKey("k1", new byte[16],
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
return kp;
|
|
return kp;
|
|
@@ -1041,7 +1053,7 @@ public class TestKMS {
|
|
new PrivilegedExceptionAction<Void>() {
|
|
new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KMSClientProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
|
|
|
|
kp.createKey("k0", new byte[16],
|
|
kp.createKey("k0", new byte[16],
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
@@ -1072,7 +1084,7 @@ public class TestKMS {
|
|
new PrivilegedExceptionAction<Void>() {
|
|
new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KMSClientProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey("k3", new byte[16],
|
|
kp.createKey("k3", new byte[16],
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
// Atleast 2 rollovers.. so should induce signer Exception
|
|
// Atleast 2 rollovers.. so should induce signer Exception
|
|
@@ -1132,7 +1144,7 @@ public class TestKMS {
|
|
doAs("client", new PrivilegedExceptionAction<Void>() {
|
|
doAs("client", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
kp.createKey("k", new KeyProvider.Options(conf));
|
|
kp.createKey("k", new KeyProvider.Options(conf));
|
|
Assert.fail();
|
|
Assert.fail();
|
|
@@ -1223,7 +1235,7 @@ public class TestKMS {
|
|
doAs("CREATE", new PrivilegedExceptionAction<Void>() {
|
|
doAs("CREATE", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProvider.KeyVersion kv = kp.createKey("k0",
|
|
KeyProvider.KeyVersion kv = kp.createKey("k0",
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
@@ -1238,7 +1250,7 @@ public class TestKMS {
|
|
doAs("DELETE", new PrivilegedExceptionAction<Void>() {
|
|
doAs("DELETE", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
kp.deleteKey("k0");
|
|
kp.deleteKey("k0");
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
@@ -1251,7 +1263,7 @@ public class TestKMS {
|
|
doAs("SET_KEY_MATERIAL", new PrivilegedExceptionAction<Void>() {
|
|
doAs("SET_KEY_MATERIAL", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProvider.KeyVersion kv = kp.createKey("k1", new byte[16],
|
|
KeyProvider.KeyVersion kv = kp.createKey("k1", new byte[16],
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
@@ -1266,7 +1278,7 @@ public class TestKMS {
|
|
doAs("ROLLOVER", new PrivilegedExceptionAction<Void>() {
|
|
doAs("ROLLOVER", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProvider.KeyVersion kv = kp.rollNewVersion("k1");
|
|
KeyProvider.KeyVersion kv = kp.rollNewVersion("k1");
|
|
Assert.assertNull(kv.getMaterial());
|
|
Assert.assertNull(kv.getMaterial());
|
|
@@ -1280,7 +1292,7 @@ public class TestKMS {
|
|
doAs("SET_KEY_MATERIAL", new PrivilegedExceptionAction<Void>() {
|
|
doAs("SET_KEY_MATERIAL", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProvider.KeyVersion kv =
|
|
KeyProvider.KeyVersion kv =
|
|
kp.rollNewVersion("k1", new byte[16]);
|
|
kp.rollNewVersion("k1", new byte[16]);
|
|
@@ -1296,7 +1308,7 @@ public class TestKMS {
|
|
doAs("GET", new PrivilegedExceptionAction<KeyVersion>() {
|
|
doAs("GET", new PrivilegedExceptionAction<KeyVersion>() {
|
|
@Override
|
|
@Override
|
|
public KeyVersion run() throws Exception {
|
|
public KeyVersion run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
kp.getKeyVersion("k1@0");
|
|
kp.getKeyVersion("k1@0");
|
|
KeyVersion kv = kp.getCurrentKey("k1");
|
|
KeyVersion kv = kp.getCurrentKey("k1");
|
|
@@ -1313,7 +1325,7 @@ public class TestKMS {
|
|
new PrivilegedExceptionAction<EncryptedKeyVersion>() {
|
|
new PrivilegedExceptionAction<EncryptedKeyVersion>() {
|
|
@Override
|
|
@Override
|
|
public EncryptedKeyVersion run() throws Exception {
|
|
public EncryptedKeyVersion run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProviderCryptoExtension kpCE = KeyProviderCryptoExtension.
|
|
KeyProviderCryptoExtension kpCE = KeyProviderCryptoExtension.
|
|
createKeyProviderCryptoExtension(kp);
|
|
createKeyProviderCryptoExtension(kp);
|
|
@@ -1330,7 +1342,7 @@ public class TestKMS {
|
|
doAs("DECRYPT_EEK", new PrivilegedExceptionAction<Void>() {
|
|
doAs("DECRYPT_EEK", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
KeyProviderCryptoExtension kpCE = KeyProviderCryptoExtension.
|
|
KeyProviderCryptoExtension kpCE = KeyProviderCryptoExtension.
|
|
createKeyProviderCryptoExtension(kp);
|
|
createKeyProviderCryptoExtension(kp);
|
|
@@ -1345,7 +1357,7 @@ public class TestKMS {
|
|
doAs("GET_KEYS", new PrivilegedExceptionAction<Void>() {
|
|
doAs("GET_KEYS", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
kp.getKeys();
|
|
kp.getKeys();
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
@@ -1358,7 +1370,7 @@ public class TestKMS {
|
|
doAs("GET_METADATA", new PrivilegedExceptionAction<Void>() {
|
|
doAs("GET_METADATA", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
try {
|
|
try {
|
|
kp.getMetadata("k1");
|
|
kp.getMetadata("k1");
|
|
kp.getKeysMetadata("k1");
|
|
kp.getKeysMetadata("k1");
|
|
@@ -1385,7 +1397,7 @@ public class TestKMS {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProvider.KeyVersion kv = kp.createKey("k2",
|
|
KeyProvider.KeyVersion kv = kp.createKey("k2",
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
Assert.fail();
|
|
Assert.fail();
|
|
@@ -1440,12 +1452,12 @@ public class TestKMS {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
try {
|
|
try {
|
|
- KMSClientProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck0",
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck0",
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
EncryptedKeyVersion eek =
|
|
EncryptedKeyVersion eek =
|
|
- kp.generateEncryptedKey("ck0");
|
|
|
|
- kp.decryptEncryptedKey(eek);
|
|
|
|
|
|
+ ((CryptoExtension)kp).generateEncryptedKey("ck0");
|
|
|
|
+ ((CryptoExtension)kp).decryptEncryptedKey(eek);
|
|
Assert.assertNull(kv.getMaterial());
|
|
Assert.assertNull(kv.getMaterial());
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
Assert.fail(ex.getMessage());
|
|
Assert.fail(ex.getMessage());
|
|
@@ -1458,12 +1470,12 @@ public class TestKMS {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
try {
|
|
try {
|
|
- KMSClientProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck1",
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck1",
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
EncryptedKeyVersion eek =
|
|
EncryptedKeyVersion eek =
|
|
- kp.generateEncryptedKey("ck1");
|
|
|
|
- kp.decryptEncryptedKey(eek);
|
|
|
|
|
|
+ ((CryptoExtension)kp).generateEncryptedKey("ck1");
|
|
|
|
+ ((CryptoExtension)kp).decryptEncryptedKey(eek);
|
|
Assert.fail("admin user must not be allowed to decrypt !!");
|
|
Assert.fail("admin user must not be allowed to decrypt !!");
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
}
|
|
}
|
|
@@ -1475,12 +1487,12 @@ public class TestKMS {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
try {
|
|
try {
|
|
- KMSClientProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck2",
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck2",
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
EncryptedKeyVersion eek =
|
|
EncryptedKeyVersion eek =
|
|
- kp.generateEncryptedKey("ck2");
|
|
|
|
- kp.decryptEncryptedKey(eek);
|
|
|
|
|
|
+ ((CryptoExtension)kp).generateEncryptedKey("ck2");
|
|
|
|
+ ((CryptoExtension)kp).decryptEncryptedKey(eek);
|
|
Assert.fail("admin user must not be allowed to decrypt !!");
|
|
Assert.fail("admin user must not be allowed to decrypt !!");
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
}
|
|
}
|
|
@@ -1525,7 +1537,7 @@ public class TestKMS {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck0",
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck0",
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
Assert.assertNull(kv.getMaterial());
|
|
Assert.assertNull(kv.getMaterial());
|
|
@@ -1540,7 +1552,7 @@ public class TestKMS {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck1",
|
|
KeyProvider.KeyVersion kv = kp.createKey("ck1",
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
Assert.assertNull(kv.getMaterial());
|
|
Assert.assertNull(kv.getMaterial());
|
|
@@ -1583,7 +1595,7 @@ public class TestKMS {
|
|
|
|
|
|
boolean caughtTimeout = false;
|
|
boolean caughtTimeout = false;
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.getKeys();
|
|
kp.getKeys();
|
|
} catch (SocketTimeoutException e) {
|
|
} catch (SocketTimeoutException e) {
|
|
caughtTimeout = true;
|
|
caughtTimeout = true;
|
|
@@ -1593,7 +1605,7 @@ public class TestKMS {
|
|
|
|
|
|
caughtTimeout = false;
|
|
caughtTimeout = false;
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp)
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp)
|
|
.generateEncryptedKey("a");
|
|
.generateEncryptedKey("a");
|
|
} catch (SocketTimeoutException e) {
|
|
} catch (SocketTimeoutException e) {
|
|
@@ -1604,7 +1616,7 @@ public class TestKMS {
|
|
|
|
|
|
caughtTimeout = false;
|
|
caughtTimeout = false;
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp)
|
|
KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp)
|
|
.decryptEncryptedKey(
|
|
.decryptEncryptedKey(
|
|
new KMSClientProvider.KMSEncryptedKeyVersion("a",
|
|
new KMSClientProvider.KMSEncryptedKeyVersion("a",
|
|
@@ -1651,7 +1663,7 @@ public class TestKMS {
|
|
UserGroupInformation.getCurrentUser();
|
|
UserGroupInformation.getCurrentUser();
|
|
|
|
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey(keyA, new KeyProvider.Options(conf));
|
|
kp.createKey(keyA, new KeyProvider.Options(conf));
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
System.out.println(ex.getMessage());
|
|
System.out.println(ex.getMessage());
|
|
@@ -1660,7 +1672,7 @@ public class TestKMS {
|
|
doAs("client", new PrivilegedExceptionAction<Void>() {
|
|
doAs("client", new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
KeyProviderDelegationTokenExtension kpdte =
|
|
KeyProviderDelegationTokenExtension kpdte =
|
|
KeyProviderDelegationTokenExtension.
|
|
KeyProviderDelegationTokenExtension.
|
|
createKeyProviderDelegationTokenExtension(kp);
|
|
createKeyProviderDelegationTokenExtension(kp);
|
|
@@ -1672,7 +1684,7 @@ public class TestKMS {
|
|
nonKerberosUgi.addCredentials(credentials);
|
|
nonKerberosUgi.addCredentials(credentials);
|
|
|
|
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey(keyA, new KeyProvider.Options(conf));
|
|
kp.createKey(keyA, new KeyProvider.Options(conf));
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
System.out.println(ex.getMessage());
|
|
System.out.println(ex.getMessage());
|
|
@@ -1681,7 +1693,7 @@ public class TestKMS {
|
|
nonKerberosUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
nonKerberosUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey(keyD, new KeyProvider.Options(conf));
|
|
kp.createKey(keyD, new KeyProvider.Options(conf));
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -1767,7 +1779,7 @@ public class TestKMS {
|
|
new PrivilegedExceptionAction<KeyProvider>() {
|
|
new PrivilegedExceptionAction<KeyProvider>() {
|
|
@Override
|
|
@Override
|
|
public KeyProvider run() throws Exception {
|
|
public KeyProvider run() throws Exception {
|
|
- KMSClientProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey("k1", new byte[16],
|
|
kp.createKey("k1", new byte[16],
|
|
new KeyProvider.Options(conf));
|
|
new KeyProvider.Options(conf));
|
|
kp.createKey("k2", new byte[16],
|
|
kp.createKey("k2", new byte[16],
|
|
@@ -1844,7 +1856,7 @@ public class TestKMS {
|
|
clientUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
clientUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- final KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ final KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey("kaa", new KeyProvider.Options(conf));
|
|
kp.createKey("kaa", new KeyProvider.Options(conf));
|
|
|
|
|
|
// authorized proxyuser
|
|
// authorized proxyuser
|
|
@@ -1956,7 +1968,7 @@ public class TestKMS {
|
|
fooUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
fooUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
Assert.assertNotNull(kp.createKey("kaa",
|
|
Assert.assertNotNull(kp.createKey("kaa",
|
|
new KeyProvider.Options(conf)));
|
|
new KeyProvider.Options(conf)));
|
|
return null;
|
|
return null;
|
|
@@ -1970,7 +1982,7 @@ public class TestKMS {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
try {
|
|
try {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
kp.createKey("kbb", new KeyProvider.Options(conf));
|
|
kp.createKey("kbb", new KeyProvider.Options(conf));
|
|
Assert.fail();
|
|
Assert.fail();
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
@@ -1986,7 +1998,7 @@ public class TestKMS {
|
|
barUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
barUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
@Override
|
|
public Void run() throws Exception {
|
|
public Void run() throws Exception {
|
|
- KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
|
|
|
+ KeyProvider kp = createProvider(uri, conf);
|
|
Assert.assertNotNull(kp.createKey("kcc",
|
|
Assert.assertNotNull(kp.createKey("kcc",
|
|
new KeyProvider.Options(conf)));
|
|
new KeyProvider.Options(conf)));
|
|
return null;
|
|
return null;
|