Search in sources :

Example 1 with AmazonSNS

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));
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) AmazonSNS(com.amazonaws.services.sns.AmazonSNS) Test(org.junit.Test)

Example 2 with AmazonSNS

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);
}
Also used : AmazonSNS(com.amazonaws.services.sns.AmazonSNS) AfterClass(org.junit.AfterClass)

Example 3 with AmazonSNS

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;
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AmazonSNS(com.amazonaws.services.sns.AmazonSNS)

Example 4 with AmazonSNS

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;
}
Also used : AmazonSNSClient(com.amazonaws.services.sns.AmazonSNSClient) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AmazonSNS(com.amazonaws.services.sns.AmazonSNS)

Example 5 with AmazonSNS

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);
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AmazonSNS(com.amazonaws.services.sns.AmazonSNS)

Aggregations

AmazonSNS (com.amazonaws.services.sns.AmazonSNS)13 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)4 PublishRequest (com.amazonaws.services.sns.model.PublishRequest)4 PublishResult (com.amazonaws.services.sns.model.PublishResult)4 Test (org.junit.Test)4 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)3 TupleTag (org.apache.beam.sdk.values.TupleTag)3 AWSCredentials (com.amazonaws.auth.AWSCredentials)2 PCollectionTuple (org.apache.beam.sdk.values.PCollectionTuple)2 AmazonSQSExtendedClient (com.amazon.sqs.javamessaging.AmazonSQSExtendedClient)1 ExtendedClientConfiguration (com.amazon.sqs.javamessaging.ExtendedClientConfiguration)1 ClientConfiguration (com.amazonaws.ClientConfiguration)1 SdkHttpMetadata (com.amazonaws.http.SdkHttpMetadata)1 Regions (com.amazonaws.regions.Regions)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 AmazonSNSClient (com.amazonaws.services.sns.AmazonSNSClient)1 CreateTopicRequest (com.amazonaws.services.sns.model.CreateTopicRequest)1 CreateTopicResult (com.amazonaws.services.sns.model.CreateTopicResult)1 InternalErrorException (com.amazonaws.services.sns.model.InternalErrorException)1 SetSubscriptionAttributesRequest (com.amazonaws.services.sns.model.SetSubscriptionAttributesRequest)1