use of com.amazonaws.auth.AWSStaticCredentialsProvider in project beam by apache.
the class KinesisIOReadTest method testReadWithBasicCredentials.
@Test
public void testReadWithBasicCredentials() {
Regions region = Regions.US_EAST_1;
Read<KinesisRecord> read = KinesisIO.read().withAWSClientsProvider(ACCESS_KEY_ID, SECRET_ACCESS_KEY, region);
assertEquals(read.getAWSClientsProvider(), new BasicKinesisProvider(new AWSStaticCredentialsProvider(new BasicAWSCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)), region, null, true));
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project beam by apache.
the class AwsSerializableUtilsTest method testStaticSessionCredentialsProviderSerialization.
@Test
public void testStaticSessionCredentialsProviderSerialization() {
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(new BasicSessionCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY, SESSION_TOKEN));
String serializedCredentials = serialize(credentialsProvider);
checkStaticSessionCredentials(deserialize(serializedCredentials));
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project beam by apache.
the class AwsModuleTest method testAWSStaticCredentialsProviderSerializationDeserialization.
@Test
public void testAWSStaticCredentialsProviderSerializationDeserialization() throws Exception {
String awsKeyId = "key-id";
String awsSecretKey = "secret-key";
AWSStaticCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials(awsKeyId, awsSecretKey));
String serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider);
AWSCredentialsProvider deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class);
assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
assertEquals(credentialsProvider.getCredentials().getAWSAccessKeyId(), deserializedCredentialsProvider.getCredentials().getAWSAccessKeyId());
assertEquals(credentialsProvider.getCredentials().getAWSSecretKey(), deserializedCredentialsProvider.getCredentials().getAWSSecretKey());
String sessionToken = "session-token";
BasicSessionCredentials sessionCredentials = new BasicSessionCredentials(awsKeyId, awsSecretKey, sessionToken);
credentialsProvider = new AWSStaticCredentialsProvider(sessionCredentials);
serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider);
deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class);
BasicSessionCredentials deserializedCredentials = (BasicSessionCredentials) deserializedCredentialsProvider.getCredentials();
assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
assertEquals(deserializedCredentials.getAWSAccessKeyId(), awsKeyId);
assertEquals(deserializedCredentials.getAWSSecretKey(), awsSecretKey);
assertEquals(deserializedCredentials.getSessionToken(), sessionToken);
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project beam by apache.
the class EmbeddedSqsServer method before.
@Override
protected void before() {
sqsRestServer = SQSRestServerBuilder.withDynamicPort().start();
int port = sqsRestServer.waitUntilStarted().localAddress().getPort();
String endpoint = String.format("http://localhost:%d", port);
String region = "elasticmq";
String accessKey = "x";
String secretKey = "x";
client = AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))).withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region)).build();
final CreateQueueResult queue = client.createQueue("test");
queueUrl = queue.getQueueUrl();
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project hazelcast by hazelcast.
the class AwsConfig method buildClient.
public AmazonKinesisAsync buildClient() {
AmazonKinesisAsyncClientBuilder builder = AmazonKinesisAsyncClientBuilder.standard();
if (endpoint == null) {
if (region != null) {
builder.setRegion(region);
}
} else {
builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region));
}
builder.withCredentials(accessKey == null ? new DefaultAWSCredentialsProviderChain() : new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)));
builder.withClientConfiguration(new ClientConfiguration());
return builder.build();
}
Aggregations