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