use of com.amazonaws.services.sns.AmazonSNS in project herd by FINRAOS.
the class AwsClientFactoryTest method testGetAmazonSNSClientCacheHitMiss.
@Test
public void testGetAmazonSNSClientCacheHitMiss() {
// Create an AWS parameters DTO that contains proxy information.
AwsParamsDto awsParamsDto = new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT);
// Get an Amazon SNS client.
AmazonSNS amazonSNS = awsClientFactory.getAmazonSNSClient(awsParamsDto);
// Confirm a cache hit.
assertEquals(amazonSNS, awsClientFactory.getAmazonSNSClient(new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT)));
// Confirm a cache miss due to http proxy information.
assertNotEquals(amazonSNS, awsClientFactory.getAmazonSNSClient(new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST_2, HTTP_PROXY_PORT_2)));
// Clear the cache.
cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear();
// Confirm a cache miss due to cleared cache.
assertNotEquals(amazonSNS, awsClientFactory.getAmazonSNSClient(awsParamsDto));
}
use of com.amazonaws.services.sns.AmazonSNS in project tutorials by eugenp.
the class SpringCloudSNSIntegrationTest method cleanupAwsResources.
@AfterClass
public static void cleanupAwsResources() {
AmazonSNS amazonSNS = SpringCloudAwsTestUtil.amazonSNS();
amazonSNS.deleteTopic(topicArn);
}
use of com.amazonaws.services.sns.AmazonSNS in project oxAuth by GluuFederation.
the class PushSnsService method createSnsClient.
public AmazonSNS createSnsClient(String accessKey, String secretKey, String region) {
String decryptedAccessKey = encryptionService.decrypt(accessKey, true);
String decryptedSecretKey = encryptionService.decrypt(secretKey, true);
BasicAWSCredentials credentials = new BasicAWSCredentials(decryptedAccessKey, decryptedSecretKey);
AmazonSNS snsClient = AmazonSNSClientBuilder.standard().withRegion(Regions.fromName(region)).withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
return snsClient;
}
use of com.amazonaws.services.sns.AmazonSNS 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.services.sns.AmazonSNS in project thingsboard by thingsboard.
the class SnsPlugin method init.
private void init() {
AWSCredentials awsCredentials = new BasicAWSCredentials(configuration.getAccessKeyId(), configuration.getSecretAccessKey());
AWSStaticCredentialsProvider credProvider = new AWSStaticCredentialsProvider(awsCredentials);
AmazonSNS sns = AmazonSNSClient.builder().withCredentials(credProvider).withRegion(configuration.getRegion()).build();
this.snsMessageHandler = new SnsMessageHandler(sns);
}
Aggregations