Search in sources :

Example 1 with AnonymousAWSCredentials

use of com.amazonaws.auth.AnonymousAWSCredentials in project hadoop by apache.

the class AWSCredentialProviderList method getCredentials.

/**
   * Iterate through the list of providers, to find one with credentials.
   * If {@link #reuseLastProvider} is true, then it is re-used.
   * @return a set of credentials (possibly anonymous), for authenticating.
   */
@Override
public AWSCredentials getCredentials() {
    checkNotEmpty();
    if (reuseLastProvider && lastProvider != null) {
        return lastProvider.getCredentials();
    }
    AmazonClientException lastException = null;
    for (AWSCredentialsProvider provider : providers) {
        try {
            AWSCredentials credentials = provider.getCredentials();
            if ((credentials.getAWSAccessKeyId() != null && credentials.getAWSSecretKey() != null) || (credentials instanceof AnonymousAWSCredentials)) {
                lastProvider = provider;
                LOG.debug("Using credentials from {}", provider);
                return credentials;
            }
        } catch (AmazonClientException e) {
            lastException = e;
            LOG.debug("No credentials provided by {}: {}", provider, e.toString(), e);
        }
    }
    // no providers had any credentials. Rethrow the last exception
    // or create a new one.
    String message = "No AWS Credentials provided by " + listProviderNames();
    if (lastException != null) {
        message += ": " + lastException;
    }
    throw new AmazonClientException(message, lastException);
}
Also used : AmazonClientException(com.amazonaws.AmazonClientException) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider)

Example 2 with AnonymousAWSCredentials

use of com.amazonaws.auth.AnonymousAWSCredentials in project archaius by Netflix.

the class S3ConfigurationSourceTest method setup.

@Before
public void setup() throws Exception {
    fakeS3 = createHttpServer();
    client = new AmazonS3Client(new StaticCredentialsProvider(new AnonymousAWSCredentials()));
    client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
    client.setEndpoint("http://localhost:8069");
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) StaticCredentialsProvider(com.amazonaws.internal.StaticCredentialsProvider) S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) Before(org.junit.Before)

Aggregations

AnonymousAWSCredentials (com.amazonaws.auth.AnonymousAWSCredentials)2 AmazonClientException (com.amazonaws.AmazonClientException)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 StaticCredentialsProvider (com.amazonaws.internal.StaticCredentialsProvider)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 S3ClientOptions (com.amazonaws.services.s3.S3ClientOptions)1 Before (org.junit.Before)1