List of usage examples for com.amazonaws.auth AWSCredentialsProviderChain getCredentials
@Override
public AWSCredentials getCredentials()
From source file:org.transitime.maintenance.AwsGlacier.java
License:Open Source License
/********************** Member Functions **************************/ public AwsGlacier(String region) { // Get credentials from credentials file, environment variable, or // Java property. // See http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html AWSCredentialsProviderChain credentialsProvider = new DefaultAWSCredentialsProviderChain(); credentials = credentialsProvider.getCredentials(); logger.debug("Read in credentials AWSAccessKeyId={} AWSSecretKey={}...", credentials.getAWSAccessKeyId(), credentials.getAWSSecretKey().substring(0, 4)); // Create the glacier client and set to specified region. glacierClient = new AmazonGlacierClient(credentials); glacierClient.setEndpoint("https://glacier." + region + ".amazonaws.com"); // Set up params needed for retrieving vault inventory sqsClient = new AmazonSQSClient(credentials); sqsClient.setEndpoint("https://sqs." + region + ".amazonaws.com"); snsClient = new AmazonSNSClient(credentials); snsClient.setEndpoint("https://sns." + region + ".amazonaws.com"); // Create the ArchiveTransferManager used for uploading and // downloading files. Need to use ArchiveTransferManager constructor // that allows one to specify sqsClient & snsClient so that they have // the proper region. If use ArchiveTransferManager without specifying // sqs and sns clients then default ones are constructed, but these // use the default Virginia region, which is wrong. atm = new ArchiveTransferManager(glacierClient, sqsClient, snsClient); }
From source file:org.transitime.maintenance.AwsGlacierInventoryRetriever.java
License:Open Source License
/********************** Member Functions **************************/ public AwsGlacierInventoryRetriever(String region) { // Get credentials from credentials file, environment variable, or // Java property. // See http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html AWSCredentialsProviderChain credentialsProvider = new DefaultAWSCredentialsProviderChain(); AWSCredentials credentials = credentialsProvider.getCredentials(); logger.debug("Read in credentials AWSAccessKeyId={} AWSSecretKey={}...", credentials.getAWSAccessKeyId(), credentials.getAWSSecretKey().substring(0, 4)); // Create the glacier client and set to specified region. glacierClient = new AmazonGlacierClient(credentials); glacierClient.setEndpoint("https://glacier." + region + ".amazonaws.com"); // Set up params needed for retrieving vault inventory sqsClient = new AmazonSQSClient(credentials); sqsClient.setEndpoint("https://sqs." + region + ".amazonaws.com"); snsClient = new AmazonSNSClient(credentials); snsClient.setEndpoint("https://sns." + region + ".amazonaws.com"); setupSQS();// w w w . j a va2 s . co m setupSNS(); }