Search in sources :

Example 31 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project exhibitor by soabase.

the class S3ClientImpl method changeCredentials.

@Override
public void changeCredentials(S3Credential credential, S3ClientConfig clientConfig) {
    RefCountedClient newRefCountedClient = (credential != null) ? new RefCountedClient(createClient(null, new BasicAWSCredentials(credential.getAccessKeyId(), credential.getSecretAccessKey()), clientConfig)) : new RefCountedClient(createClient(null, null, clientConfig));
    RefCountedClient oldRefCountedClient = client.getAndSet(newRefCountedClient);
    if (oldRefCountedClient != null) {
        oldRefCountedClient.markForDelete();
    }
}
Also used : BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 32 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project chassis by Kixeye.

the class DefaultCloudWatchFactory method getCloudWatchClient.

@Override
public AmazonCloudWatchClient getCloudWatchClient() {
    AmazonCloudWatchClient client;
    if (StringUtils.isBlank(accessKeyId) || StringUtils.isBlank(secretKey)) {
        LOGGER.debug("Constructing AmazonCloudWatchClient using DefaultAWSCredentialsProviderChain for region {}.", region);
        client = new AmazonCloudWatchClient(new DefaultAWSCredentialsProviderChain());
    } else {
        LOGGER.debug("Constructing AmazonCloudWatchClient from given credentials for region {}.", region);
        client = new AmazonCloudWatchClient(new BasicAWSCredentials(accessKeyId, secretKey));
    }
    client.setRegion(region);
    return client;
}
Also used : DefaultAWSCredentialsProviderChain(com.amazonaws.auth.DefaultAWSCredentialsProviderChain) AmazonCloudWatchClient(com.amazonaws.services.cloudwatch.AmazonCloudWatchClient) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 33 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project camel by apache.

the class SnsEndpoint method createSNSClient.

/**
     * Provide the possibility to override this method for an mock implementation
     *
     * @return AmazonSNSClient
     */
AmazonSNS createSNSClient() {
    AmazonSNS client = null;
    ClientConfiguration clientConfiguration = null;
    boolean isClientConfigFound = false;
    if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
        clientConfiguration = new ClientConfiguration();
        clientConfiguration.setProxyHost(configuration.getProxyHost());
        clientConfiguration.setProxyPort(configuration.getProxyPort());
        isClientConfigFound = true;
    }
    if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
        if (isClientConfigFound) {
            client = new AmazonSNSClient(credentials, clientConfiguration);
        } else {
            client = new AmazonSNSClient(credentials);
        }
    } else {
        if (isClientConfigFound) {
            client = new AmazonSNSClient();
        } else {
            client = new AmazonSNSClient(clientConfiguration);
        }
    }
    return client;
}
Also used : AmazonSNSClient(com.amazonaws.services.sns.AmazonSNSClient) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AmazonSNS(com.amazonaws.services.sns.AmazonSNS)

Example 34 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project presto by prestodb.

the class PrestoS3FileSystem method getAwsCredentials.

private static Optional<AWSCredentials> getAwsCredentials(URI uri, Configuration conf) {
    String accessKey = conf.get(S3_ACCESS_KEY);
    String secretKey = conf.get(S3_SECRET_KEY);
    String userInfo = uri.getUserInfo();
    if (userInfo != null) {
        int index = userInfo.indexOf(':');
        if (index < 0) {
            accessKey = userInfo;
        } else {
            accessKey = userInfo.substring(0, index);
            secretKey = userInfo.substring(index + 1);
        }
    }
    if (isNullOrEmpty(accessKey) || isNullOrEmpty(secretKey)) {
        return Optional.empty();
    }
    return Optional.of(new BasicAWSCredentials(accessKey, secretKey));
}
Also used : BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 35 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project cloudstack by apache.

the class S3Utils method getTransferManager.

public static TransferManager getTransferManager(final ClientOptions clientOptions) {
    if (TRANSFERMANAGER_ACCESSKEY_MAP.containsKey(clientOptions.getAccessKey())) {
        return TRANSFERMANAGER_ACCESSKEY_MAP.get(clientOptions.getAccessKey());
    }
    final AWSCredentials basicAWSCredentials = new BasicAWSCredentials(clientOptions.getAccessKey(), clientOptions.getSecretKey());
    final ClientConfiguration configuration = new ClientConfiguration();
    if (clientOptions.isHttps() != null) {
        configuration.setProtocol(clientOptions.isHttps() ? HTTPS : HTTP);
    }
    if (clientOptions.getConnectionTimeout() != null) {
        configuration.setConnectionTimeout(clientOptions.getConnectionTimeout());
    }
    if (clientOptions.getMaxErrorRetry() != null) {
        configuration.setMaxErrorRetry(clientOptions.getMaxErrorRetry());
    }
    if (clientOptions.getSocketTimeout() != null) {
        configuration.setSocketTimeout(clientOptions.getSocketTimeout());
    }
    if (clientOptions.getUseTCPKeepAlive() != null) {
        configuration.setUseTcpKeepAlive(clientOptions.getUseTCPKeepAlive());
    }
    if (clientOptions.getConnectionTtl() != null) {
        configuration.setConnectionTTL(clientOptions.getConnectionTtl());
    }
    if (clientOptions.getSigner() != null) {
        configuration.setSignerOverride(clientOptions.getSigner());
    }
    LOGGER.debug(format("Creating S3 client with configuration: [protocol: %1$s, signer: %2$s, connectionTimeOut: %3$s, maxErrorRetry: %4$s, socketTimeout: %5$s, useTCPKeepAlive: %6$s, connectionTtl: %7$s]", configuration.getProtocol(), configuration.getSignerOverride(), configuration.getConnectionTimeout(), configuration.getMaxErrorRetry(), configuration.getSocketTimeout(), clientOptions.getUseTCPKeepAlive(), clientOptions.getConnectionTtl()));
    final AmazonS3Client client = new AmazonS3Client(basicAWSCredentials, configuration);
    if (isNotBlank(clientOptions.getEndPoint())) {
        LOGGER.debug(format("Setting the end point for S3 client with access key %1$s to %2$s.", clientOptions.getAccessKey(), clientOptions.getEndPoint()));
        client.setEndpoint(clientOptions.getEndPoint());
    }
    TRANSFERMANAGER_ACCESSKEY_MAP.put(clientOptions.getAccessKey(), new TransferManager(client));
    return TRANSFERMANAGER_ACCESSKEY_MAP.get(clientOptions.getAccessKey());
}
Also used : TransferManager(com.amazonaws.services.s3.transfer.TransferManager) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration)

Aggregations

BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)51 AWSCredentials (com.amazonaws.auth.AWSCredentials)26 ClientConfiguration (com.amazonaws.ClientConfiguration)17 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)15 AmazonClientException (com.amazonaws.AmazonClientException)6 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)5 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)4 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)3 DefaultAWSCredentialsProviderChain (com.amazonaws.auth.DefaultAWSCredentialsProviderChain)3 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)3 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)3 File (java.io.File)3 IOException (java.io.IOException)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2 EnvironmentVariableCredentialsProvider (com.amazonaws.auth.EnvironmentVariableCredentialsProvider)2 SystemPropertiesCredentialsProvider (com.amazonaws.auth.SystemPropertiesCredentialsProvider)2 StaticCredentialsProvider (com.amazonaws.internal.StaticCredentialsProvider)2 Region (com.amazonaws.regions.Region)2 AmazonCloudWatchClient (com.amazonaws.services.cloudwatch.AmazonCloudWatchClient)2 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)2