use of com.yahoo.athenz.zts.AWSCredentialsProviderImpl in project athenz by yahoo.
the class ZTSAWSCredsClient method main.
public static void main(String[] args) {
// parse our command line to retrieve required input
CommandLine cmd = parseCommandLine(args);
final String domainName = cmd.getOptionValue("domain").toLowerCase();
final String roleName = cmd.getOptionValue("role").toLowerCase();
final String ztsUrl = cmd.getOptionValue("ztsurl");
final String keyPath = cmd.getOptionValue("key");
final String certPath = cmd.getOptionValue("cert");
final String trustStorePath = cmd.getOptionValue("trustStorePath");
final String trustStorePassword = cmd.getOptionValue("trustStorePassword");
try {
KeyRefresher keyRefresher = Utils.generateKeyRefresher(trustStorePath, trustStorePassword, certPath, keyPath);
SSLContext sslContext = Utils.buildSSLContext(keyRefresher.getKeyManagerProxy(), keyRefresher.getTrustManagerProxy());
// obtain temporary credential provider for our domain and role
AWSCredentialsProviderImpl awsCredProvider = new AWSCredentialsProviderImpl(ztsUrl, sslContext, domainName, roleName);
// retrieve and display aws temporary creds. Typically you just pass
// the AWSCredentialsProvider object to any AWS api that requires it.
// for example, when creating an AWS S3 client
// AmazonS3 s3client = AmazonS3ClientBuilder.standard()
// .withCredentials(awsCredProvider).withClientConfiguration(cltConf)
// .withRegion(getRegion()).build();
retrieveAWSTempCreds(awsCredProvider);
// once we're done with our api and we no longer need our
// provider we need to make sure to close it
awsCredProvider.close();
} catch (Exception ex) {
System.out.println("Exception: " + ex.getMessage());
ex.printStackTrace();
System.exit(1);
}
}
Aggregations