use of com.amazonaws.auth.AWSStaticCredentialsProvider in project pipeline-aws-plugin by jenkinsci.
the class AWSClientFactory method handleStaticCredentials.
private static AWSCredentialsProvider handleStaticCredentials(EnvVars vars) {
String accessKey = vars.get(AWS_ACCESS_KEY_ID);
String secretAccessKey = vars.get(AWS_SECRET_ACCESS_KEY);
if (accessKey != null && secretAccessKey != null) {
String sessionToken = vars.get(AWS_SESSION_TOKEN);
if (sessionToken != null) {
return new AWSStaticCredentialsProvider(new BasicSessionCredentials(accessKey, secretAccessKey, sessionToken));
}
return new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretAccessKey));
}
return null;
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project pipeline-aws-plugin by jenkinsci.
the class SerializableAWSCredentialsProviderTest method serializeBasicSessionCredentials.
@Test
public void serializeBasicSessionCredentials() throws Exception {
BasicSessionCredentials awsCreds = new BasicSessionCredentials(ACCESS_KEY_ID, SECRET_KEY_ID, SESSION_TOKEN);
AWSCredentialsProvider provider = new AWSStaticCredentialsProvider(awsCreds);
SerializableAWSCredentialsProvider serializedProvider = new SerializableAWSCredentialsProvider(provider);
BasicSessionCredentials serializedCredentials = (BasicSessionCredentials) serializedProvider.getCredentials();
Assert.assertEquals(ACCESS_KEY_ID, serializedCredentials.getAWSAccessKeyId());
Assert.assertEquals(SECRET_KEY_ID, serializedCredentials.getAWSSecretKey());
Assert.assertEquals(SESSION_TOKEN, serializedCredentials.getSessionToken());
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project pipeline-aws-plugin by jenkinsci.
the class SerializableAWSCredentialsProviderTest method serializeBasicAWSCredentials.
@Test
public void serializeBasicAWSCredentials() throws Exception {
BasicAWSCredentials awsCreds = new BasicAWSCredentials(ACCESS_KEY_ID, SECRET_KEY_ID);
AWSCredentialsProvider provider = new AWSStaticCredentialsProvider(awsCreds);
SerializableAWSCredentialsProvider serializedProvider = new SerializableAWSCredentialsProvider(provider);
Assert.assertEquals(ACCESS_KEY_ID, serializedProvider.getCredentials().getAWSAccessKeyId());
Assert.assertEquals(SECRET_KEY_ID, serializedProvider.getCredentials().getAWSSecretKey());
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project OsmAnd-tools by osmandapp.
the class StorageService method getStorageProviderById.
private StorageType getStorageProviderById(String id) {
id = id.trim();
StorageType st = storageProviders.get(id);
if (st != null) {
return st;
}
if (id.equals(LOCAL_STORAGE)) {
st = new StorageType();
st.local = true;
} else {
String prefix = "storage.datasource." + id + ".";
String endpointUrl = env.getProperty(prefix + "endpoint");
checkNotNull(endpointUrl, "endpoint", id);
String region = env.getProperty(prefix + "region");
checkNotNull(region, "endpoint", id);
String bucket = env.getProperty(prefix + "bucket");
checkNotNull(region, "bucket", id);
String accessKey = env.getProperty(prefix + "accesskey");
String secretKey = env.getProperty(prefix + "secretkey");
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration(endpointUrl, region));
if (!Algorithms.isEmpty(accessKey)) {
builder = builder.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)));
}
AmazonS3 s3 = builder.build();
st = new StorageType();
st.bucket = bucket;
st.s3Conn = s3;
}
storageProviders.put(id, st);
return st;
}
Aggregations