|
@@ -617,13 +617,15 @@ public class TestKMS {
|
|
|
for (KMSACLs.Type type : KMSACLs.Type.values()) {
|
|
|
conf.set(type.getAclConfigKey(), type.toString());
|
|
|
}
|
|
|
- conf.set(KMSACLs.Type.CREATE.getAclConfigKey(),"CREATE,ROLLOVER,GET,SET_KEY_MATERIAL,GENERATE_EEK");
|
|
|
- conf.set(KMSACLs.Type.ROLLOVER.getAclConfigKey(),"CREATE,ROLLOVER,GET,SET_KEY_MATERIAL,GENERATE_EEK");
|
|
|
+ conf.set(KMSACLs.Type.CREATE.getAclConfigKey(),"CREATE,ROLLOVER,GET,SET_KEY_MATERIAL,GENERATE_EEK,DECRYPT_EEK");
|
|
|
+ conf.set(KMSACLs.Type.ROLLOVER.getAclConfigKey(),"CREATE,ROLLOVER,GET,SET_KEY_MATERIAL,GENERATE_EEK,DECRYPT_EEK");
|
|
|
conf.set(KMSACLs.Type.GENERATE_EEK.getAclConfigKey(),"CREATE,ROLLOVER,GET,SET_KEY_MATERIAL,GENERATE_EEK");
|
|
|
conf.set(KMSACLs.Type.DECRYPT_EEK.getAclConfigKey(),"CREATE,ROLLOVER,GET,SET_KEY_MATERIAL,GENERATE_EEK");
|
|
|
|
|
|
-
|
|
|
conf.set(KeyAuthorizationKeyProvider.KEY_ACL + "test_key.MANAGEMENT", "CREATE");
|
|
|
+ conf.set(KeyAuthorizationKeyProvider.KEY_ACL + "some_key.MANAGEMENT", "ROLLOVER");
|
|
|
+ conf.set(KMSConfiguration.WHITELIST_KEY_ACL_PREFIX + "MANAGEMENT", "DECRYPT_EEK");
|
|
|
+
|
|
|
conf.set(KeyAuthorizationKeyProvider.KEY_ACL + "all_access.ALL", "GENERATE_EEK");
|
|
|
conf.set(KeyAuthorizationKeyProvider.KEY_ACL + "all_access.DECRYPT_EEK", "ROLLOVER");
|
|
|
conf.set(KMSConfiguration.DEFAULT_KEY_ACL_PREFIX + "MANAGEMENT", "ROLLOVER");
|
|
@@ -676,6 +678,41 @@ public class TestKMS {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // Test whitelist key access..
|
|
|
+ // DECRYPT_EEK is whitelisted for MANAGEMENT operations only
|
|
|
+ doAs("DECRYPT_EEK", new PrivilegedExceptionAction<Void>() {
|
|
|
+ @Override
|
|
|
+ public Void run() throws Exception {
|
|
|
+ KeyProvider kp = new KMSClientProvider(uri, conf);
|
|
|
+ try {
|
|
|
+ Options options = new KeyProvider.Options(conf);
|
|
|
+ Map<String, String> attributes = options.getAttributes();
|
|
|
+ HashMap<String,String> newAttribs = new HashMap<String, String>(attributes);
|
|
|
+ newAttribs.put("key.acl.name", "some_key");
|
|
|
+ options.setAttributes(newAttribs);
|
|
|
+ KeyProvider.KeyVersion kv = kp.createKey("kk0", options);
|
|
|
+ Assert.assertNull(kv.getMaterial());
|
|
|
+ KeyVersion rollVersion = kp.rollNewVersion("kk0");
|
|
|
+ Assert.assertNull(rollVersion.getMaterial());
|
|
|
+ KeyProviderCryptoExtension kpce =
|
|
|
+ KeyProviderCryptoExtension.createKeyProviderCryptoExtension(kp);
|
|
|
+ try {
|
|
|
+ kpce.generateEncryptedKey("kk0");
|
|
|
+ Assert.fail("User [DECRYPT_EEK] should not be allowed to generate_eek on kk0");
|
|
|
+ } catch (Exception e) {
|
|
|
+ // Ignore
|
|
|
+ }
|
|
|
+ newAttribs = new HashMap<String, String>(attributes);
|
|
|
+ newAttribs.put("key.acl.name", "all_access");
|
|
|
+ options.setAttributes(newAttribs);
|
|
|
+ kp.createKey("kkx", options);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ Assert.fail(ex.getMessage());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
doAs("ROLLOVER", new PrivilegedExceptionAction<Void>() {
|
|
|
@Override
|
|
|
public Void run() throws Exception {
|