Example usage for com.amazonaws.auth AWSCredentials getAWSAccessKeyId

List of usage examples for com.amazonaws.auth AWSCredentials getAWSAccessKeyId

Introduction

In this page you can find the example usage for com.amazonaws.auth AWSCredentials getAWSAccessKeyId.

Prototype

public String getAWSAccessKeyId();

Source Link

Document

Returns the AWS access key ID for this credentials object.

Usage

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 va 2s  . c o  m
    setupSNS();
}

From source file:wwutil.jsoda.Jsoda.java

License:Mozilla Public License

/** Set a cache service for the Jsoda object.  All objects accessed via the Jsoda object will be cached according to their CachePolicy. */
public Jsoda(AWSCredentials cred, MemCacheable memCacheable) throws Exception {
    if (cred == null || cred.getAWSAccessKeyId() == null || cred.getAWSSecretKey() == null)
        throw new IllegalArgumentException("AWS credentials are needed.");

    this.credentials = cred;
    this.objCacheMgr = new ObjCacheMgr(this, memCacheable);
    this.sdbMgr = new SimpleDBService(this, cred);
    this.ddbMgr = new DynamoDBService(this, cred);
    this.s3Client = new AmazonS3Client(cred);
    this.preStore1Registry = BuiltinFunc.clonePreStore1Registry();
    this.preStore2Registry = BuiltinFunc.clonePreStore2Registry();
    this.validationRegistry = BuiltinFunc.cloneValidationRegistry();
    this.postLoadRegistry = BuiltinFunc.clonePostLoadRegistry();
}

From source file:zipkin.autoconfigure.storage.elasticsearch.aws.ZipkinElasticsearchAwsStorageAutoConfiguration.java

License:Apache License

/** By default, get credentials from the {@link DefaultAWSCredentialsProviderChain} */
@Bean//from  ww  w  .ja  va 2  s. co m
@ConditionalOnMissingBean
AWSCredentials.Provider credentials() {
    return new AWSCredentials.Provider() {
        AWSCredentialsProvider delegate = new DefaultAWSCredentialsProviderChain();

        @Override
        public AWSCredentials get() {
            com.amazonaws.auth.AWSCredentials result = delegate.getCredentials();
            String sessionToken = result instanceof AWSSessionCredentials
                    ? ((AWSSessionCredentials) result).getSessionToken()
                    : null;
            return new AWSCredentials(result.getAWSAccessKeyId(), result.getAWSSecretKey(), sessionToken);
        }
    };
}