AwsPrivateKeyStore implements PrivateKeyStore { @Override public PrivateKey getPrivateKey(String service, String serverHostName, StringBuilder privateKeyId) { String bucketName; String keyName; String keyIdName; if (ZMS_SERVICE.equals(service)) { bucketName = System.getProperty(ATHENZ_PROP_ZMS_BUCKET_NAME); keyName = System.getProperty(ATHENZ_PROP_ZMS_KEY_NAME, ATHENZ_DEFAULT_KEY_NAME); keyIdName = System.getProperty(ATHENZ_PROP_ZMS_KEY_ID_NAME, ATHENZ_DEFAULT_KEY_ID_NAME); } else if (ZTS_SERVICE.equals(service)) { bucketName = System.getProperty(ATHENZ_PROP_ZTS_BUCKET_NAME); keyName = System.getProperty(ATHENZ_PROP_ZTS_KEY_NAME, ATHENZ_DEFAULT_KEY_NAME); keyIdName = System.getProperty(ATHENZ_PROP_ZTS_KEY_ID_NAME, ATHENZ_DEFAULT_KEY_ID_NAME); } else { LOG.error("Unknown service specified: {}", service); return null; } if (bucketName == null) { LOG.error("No bucket name specified with system property"); return null; } PrivateKey pkey = Crypto.loadPrivateKey(getDecryptedData(bucketName, keyName)); privateKeyId.append(getDecryptedData(bucketName, keyIdName)); return pkey; } AwsPrivateKeyStore();  AwsPrivateKeyStore(final AmazonS3 s3, final AWSKMS kms); @Override PrivateKey getPrivateKey(String service, String serverHostName,
            StringBuilder privateKeyId); @Override String getApplicationSecret(final String appName, final String keyName);  }
@Test public void testGetPrivateKey() { System.setProperty("athenz.aws.s3.region", "us-east-1"); System.setProperty("athenz.aws.store_kms_region", "us-east-1"); AwsPrivateKeyStoreFactory awsPrivateKeyStoreFactory = new AwsPrivateKeyStoreFactory(); assertTrue(awsPrivateKeyStoreFactory.create() instanceof AwsPrivateKeyStore); AwsPrivateKeyStore awsPrivateKeyStore = new AwsPrivateKeyStore(); awsPrivateKeyStore = new AwsPrivateKeyStore(); StringBuilder privateKeyId = new StringBuilder("testPrivateKeyId"); awsPrivateKeyStore.getPrivateKey("zms", "testServerHostName", privateKeyId); awsPrivateKeyStore.getPrivateKey("testService", "testserverHostname", privateKeyId); System.clearProperty("athenz.aws.s3.region"); System.clearProperty(ATHENZ_AWS_KMS_REGION); }