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);
}
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");
}
Aggregations