Example usage for com.amazonaws.auth AnonymousAWSCredentials AnonymousAWSCredentials

List of usage examples for com.amazonaws.auth AnonymousAWSCredentials AnonymousAWSCredentials

Introduction

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

Prototype

AnonymousAWSCredentials

Source Link

Usage

From source file:org.apache.nifi.processors.aws.AbstractAWSProcessor.java

License:Apache License

protected AWSCredentials getCredentials(final ProcessContext context) {
    final String accessKey = context.getProperty(ACCESS_KEY).evaluateAttributeExpressions().getValue();
    final String secretKey = context.getProperty(SECRET_KEY).evaluateAttributeExpressions().getValue();

    final String credentialsFile = context.getProperty(CREDENTIALS_FILE).getValue();

    if (credentialsFile != null) {
        try {//from w ww  .  j a v a 2  s  .co m
            return new PropertiesCredentials(new File(credentialsFile));
        } catch (final IOException ioe) {
            throw new ProcessException("Could not read Credentials File", ioe);
        }
    }

    if (accessKey != null && secretKey != null) {
        return new BasicAWSCredentials(accessKey, secretKey);
    }

    return new AnonymousAWSCredentials();

}

From source file:org.apache.nifi.processors.aws.credentials.provider.factory.strategies.AnonymousCredentialsStrategy.java

License:Apache License

@Override
public AWSCredentialsProvider getCredentialsProvider(Map<PropertyDescriptor, String> properties) {
    AnonymousAWSCredentials creds = new AnonymousAWSCredentials();
    return new StaticCredentialsProvider(creds);
}

From source file:org.geowebcache.s3.S3BlobStoreInfo.java

License:Open Source License

private AWSCredentialsProvider getCredentialsProvider() {
    if (null != awsSecretKey && null != awsAccessKey) {
        return new AWSCredentialsProvider() {

            @Override//  www  . j  a v a2s.c o  m
            public AWSCredentials getCredentials() {
                if ("".equals(awsAccessKey) && "".equals(awsSecretKey)) {
                    return new AnonymousAWSCredentials();
                }
                return new BasicAWSCredentials(awsAccessKey, awsSecretKey);
            }

            @Override
            public void refresh() {
            }
        };
    }
    return new DefaultAWSCredentialsProviderChain();
}

From source file:org.swiftshire.nifi.processors.kinesis.consumer.AbstractKinesisConsumerProcessor.java

License:Apache License

/**
 * Returns the AWS access keys we're configured to use. If none are configured, we use the standard
 * anonymous credentials by default. We currently support properties defined in Nifi or we can load
 * them from a separate properties file.
 * <p/>//w w w.  j a  v  a2s.  c  o  m
 * We may want to consider other types of {@link AWSCredentials credentials} in the future.
 *
 * @param context
 * @return The AWS credentials to use when accessing the cloud
 */
protected AWSCredentials getCredentials(final ProcessContext context) {
    final String accessKey = context.getProperty(ACCESS_KEY).evaluateAttributeExpressions().getValue();
    final String secretKey = context.getProperty(SECRET_KEY).evaluateAttributeExpressions().getValue();

    final String credentialsFile = context.getProperty(CREDENTIALS_FILE).getValue();

    if (credentialsFile != null) {
        try {
            return new PropertiesCredentials(new File(credentialsFile));
        } catch (final IOException ex) {
            throw new ProcessException("Could not read Credentials File", ex);
        }
    }

    if (accessKey != null && secretKey != null) {
        return new BasicAWSCredentials(accessKey, secretKey);
    }

    return new AnonymousAWSCredentials();
}