use of com.amazonaws.auth.AWSStaticCredentialsProvider in project cas by apereo.
the class DynamoDbCloudConfigBootstrapConfiguration method getAmazonDynamoDbClient.
private static AmazonDynamoDB getAmazonDynamoDbClient(final Environment environment) {
final ClientConfiguration cfg = new ClientConfiguration();
try {
final String localAddress = getSetting(environment, "localAddress");
if (StringUtils.isNotBlank(localAddress)) {
cfg.setLocalAddress(InetAddress.getByName(localAddress));
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
final String key = getSetting(environment, "credentialAccessKey");
final String secret = getSetting(environment, "credentialSecretKey");
final AWSCredentials credentials = new BasicAWSCredentials(key, secret);
String region = getSetting(environment, "region");
if (StringUtils.isBlank(region)) {
region = Regions.getCurrentRegion().getName();
}
String regionOverride = getSetting(environment, "regionOverride");
if (StringUtils.isNotBlank(regionOverride)) {
regionOverride = Regions.getCurrentRegion().getName();
}
final String endpoint = getSetting(environment, "endpoint");
final AmazonDynamoDB client = AmazonDynamoDBClient.builder().withCredentials(new AWSStaticCredentialsProvider(credentials)).withClientConfiguration(cfg).withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, regionOverride)).withRegion(region).build();
return client;
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project quickutil by quickutil.
the class AWSS3Util method buildClient.
/**
* 获取客户端实例
*
* @param s3Name-S3Name
* @return
*/
public static AmazonS3 buildClient(String s3Name) {
AmazonS3ClientBuilder s3Builder = AmazonS3ClientBuilder.standard();
s3Builder.setCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(bucketMap.get(s3Name).get("access_key"), bucketMap.get(s3Name).get("secret_key"))));
s3Builder.setEndpointConfiguration(new EndpointConfiguration(bucketMap.get(s3Name).get("endpoint"), bucketMap.get(s3Name).get("region")));
return s3Builder.build();
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project opennms by OpenNMS.
the class DefaultAmazonSQSManager method createSQSClient.
private AmazonSQS createSQSClient() {
final AmazonSQSClientBuilder builder = AmazonSQSClientBuilder.standard().withRegion(sqsConfig.getRegion());
if (sqsConfig.hasStaticCredentials()) {
final BasicAWSCredentials awsCreds = new BasicAWSCredentials(sqsConfig.getAccessKey(), sqsConfig.getSecretKey());
builder.withCredentials(new AWSStaticCredentialsProvider(awsCreds));
}
if (sqsConfig.isUseHttp()) {
final ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.HTTP);
builder.withClientConfiguration(clientConfig);
}
return builder.build();
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project jointware by isdream.
the class EC2Main method main.
/**
* @param args
*/
public static void main(String[] args) {
AWSCredentials ac = new BasicAWSCredentials(ACCESS_KEY_ID, ACCESS_KEY_SECRET);
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(ac);
AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard().withRegion(Regions.AP_NORTHEAST_1).withCredentials(credentialsProvider).build();
System.out.println(ec2.getClass().getName());
// for (com.amazonaws.services.ec2.model.Region region : ec2.describeRegions().getRegions()) {
// System.out.println(region.getRegionName());
// }
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project sic by belluccifranco.
the class AmazonServiceImpl method getSessionCredentials.
private Credentials getSessionCredentials() {
BasicAWSCredentials creds = new BasicAWSCredentials(accessKeyId, accessKeySecret);
AWSSecurityTokenService sts = AWSSecurityTokenServiceClientBuilder.standard().withRegion(this.region).withCredentials(new AWSStaticCredentialsProvider(creds)).build();
GetSessionTokenRequest getSessionTokenRequest = new GetSessionTokenRequest().withDurationSeconds(43200);
sessionCredentials = sts.getSessionToken(getSessionTokenRequest).getCredentials();
return sessionCredentials;
}
Aggregations