Java 类com.amazonaws.services.sns.AmazonSNSClient 实例源码

项目:eplmp    文件:SNSWebhookRunner.java   
@Override
public void run(Webhook webhook, String login, String email, String name, String subject, String content) {

    SNSWebhookApp webhookApp = (SNSWebhookApp) webhook.getWebhookApp();
    String topicArn = webhookApp.getTopicArn();
    String awsAccount = webhookApp.getAwsAccount();
    String awsSecret = webhookApp.getAwsSecret();
    String region = webhookApp.getRegion();
    AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccount, awsSecret));
    snsClient.setRegion(Region.getRegion(Regions.fromName(region)));

    try {
        PublishRequest publishReq = new PublishRequest()
                .withTopicArn(topicArn)
                .withMessage(getMessage(login, email, name, subject, content));
        snsClient.publish(publishReq);

    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Cannot send notification to SNS service", e);
    } finally {
        LOGGER.log(Level.INFO, "Webhook runner terminated");
    }
}
项目:bender    文件:S3SnsNotifier.java   
public static boolean publish(String arn, String msg, AmazonSNSClient snsClient, String s3Key) {
  if (dryRun) {
    logger.warn("would have published " + s3Key + " S3 creation event to SNS");
    return true;
  }

  logger.info("publishing " + s3Key + " S3 creation event to SNS");

  try {
    snsClient.publish(arn, msg, "Amazon S3 Notification");
  } catch (RuntimeException e) {
    logger.error("error publishing", e);
    return false;
  }

  return true;
}
项目:cerberus-lifecycle-cli    文件:CreateCloudFrontSecurityGroupUpdaterLambdaOperation.java   
@Inject
public CreateCloudFrontSecurityGroupUpdaterLambdaOperation(final CloudFormationService cloudFormationService,
                                                           final EnvironmentMetadata environmentMetadata,
                                                           @Named(CF_OBJECT_MAPPER) final ObjectMapper cloudformationObjectMapper,
                                                           AWSLambda awsLambda,
                                                           AmazonS3 amazonS3) {

    this.cloudFormationService = cloudFormationService;
    this.cloudformationObjectMapper = cloudformationObjectMapper;
    this.environmentMetadata = environmentMetadata;
    this.awsLambda = awsLambda;
    this.amazonS3 = amazonS3;

    final Region region = Region.getRegion(Regions.US_EAST_1);
    AmazonCloudFormation amazonCloudFormation = new AmazonCloudFormationClient();
    amazonCloudFormation.setRegion(region);
    amazonSNS = new AmazonSNSClient();
    amazonSNS.setRegion(region);
}
项目:Ignite    文件:SNSMobilePush.java   
private static AmazonSNS getSNS() throws IOException {
    String awsAccessKey = System.getProperty("AWS_ACCESS_KEY_ID"); // "YOUR_AWS_ACCESS_KEY";
    String awsSecretKey = System.getProperty("AWS_SECRET_KEY"); // "YOUR_AWS_SECRET_KEY";

    if (awsAccessKey == null)
        awsAccessKey = AWS_ACCESS_KEY;
    if (awsSecretKey == null)
        awsSecretKey = AWS_SECRET_KEY;

    AWSCredentials credentials = new BasicAWSCredentials(awsAccessKey,
            awsSecretKey);
    AmazonSNS sns = new AmazonSNSClient(credentials);

    sns.setEndpoint("https://sns.us-west-2.amazonaws.com");
    return sns;
}
项目:wildfly-camel    文件:SNSIntegrationTest.java   
public static void assertNoStaleTopic(AmazonSNSClient client, String when) {
    /* Remove the topic created by the the old version of this test. Note that this may break the old tests running
     * in parallel. */
    client.listTopics().getTopics().stream()
            .filter(topic -> topic.getTopicArn().endsWith("MyNewTopic"))
            .forEach(t -> client.deleteTopic(t.getTopicArn()));
    List<String> staleInstances = client.listTopics().getTopics().stream() //
            .map(topic -> topic.getTopicArn().substring(topic.getTopicArn().lastIndexOf(':') + 1)) // extract the
                                                                                                   // topic name
                                                                                                   // from the ARN
            .filter(name -> !name.startsWith(SNSIntegrationTest.class.getSimpleName())
                    || System.currentTimeMillis() - AWSUtils.toEpochMillis(name) > AWSUtils.HOUR) //
            .collect(Collectors.toList());
    Assert.assertEquals(String.format("Found stale SNS topics %s running the test: %s", when, staleInstances), 0,
            staleInstances.size());
}
项目:log4j-aws-appenders    文件:SNSLogWriter.java   
@Override
protected void createAWSClient()
{
    client = tryClientFactory(config.clientFactoryMethod, AmazonSNS.class, true);
    if ((client == null) && (config.clientEndpoint == null))
    {
        client = tryClientFactory("com.amazonaws.services.sns.AmazonSNSClientBuilder.defaultClient", AmazonSNS.class, false);
    }
    if (client == null)
    {
        LogLog.debug(getClass().getSimpleName() + ": creating service client via constructor");
        client = tryConfigureEndpointOrRegion(new AmazonSNSClient(), config.clientEndpoint);
    }
}
项目:oneops    文件:SNSService.java   
/**
 * Sends using the sns publisher
 */
@Override
public boolean postMessage(NotificationMessage nMsg,
                           BasicSubscriber subscriber) {

    SNSSubscriber sub;
    if (subscriber instanceof SNSSubscriber) {
        sub = (SNSSubscriber) subscriber;
    } else {
        throw new ClassCastException("invalid subscriber " + subscriber.getClass().getName());
    }

    SNSMessage msg = buildSNSMessage(nMsg);
    AmazonSNS sns = new AmazonSNSClient(new BasicAWSCredentials(sub.getAwsAccessKey(), sub.getAwsSecretKey()));
    if (sub.getSnsEndpoint() != null) {
        sns.setEndpoint(sub.getSnsEndpoint());
    }

    CreateTopicRequest tRequest = new CreateTopicRequest();
    tRequest.setName(msg.getTopicName());
    CreateTopicResult result = sns.createTopic(tRequest);

    PublishRequest pr = new PublishRequest(result.getTopicArn(), msg.getTxtMessage()).withSubject(msg.getSubject());

    try {
        PublishResult pubresult = sns.publish(pr);
        logger.info("Published msg with id - " + pubresult.getMessageId());
    } catch (AmazonClientException ace) {
        logger.error(ace.getMessage());
        return false;
    }
    return true;
}
项目:bender    文件:SNSS3Handler.java   
@Override
public void onException(Exception e) {
  /*
   * Always close the iterator to prevent connection leaking
   */
  try {
    if (this.recordIterator != null) {
      this.recordIterator.close();
    }
  } catch (IOException e1) {
    logger.error("unable to close record iterator", e);
  }

  if (this.config == null || this.config.getHandlerConfig() == null) {
    return;
  }

  /*
   * Notify SNS topic
   */
  SNSS3HandlerConfig handlerConfig = (SNSS3HandlerConfig) this.config.getHandlerConfig();
  if (handlerConfig.getSnsNotificationArn() != null) {
    AmazonSNSClient snsClient = this.snsClientFactory.newInstance();
    snsClient.publish(handlerConfig.getSnsNotificationArn(),
        this.inputFiles.stream().map(Object::toString).collect(Collectors.joining(",")),
        "SNSS3Handler Failed");
  }
}
项目:bender    文件:SNSS3HandlerTest.java   
@Test
public void testExceptionHandlingd() throws Throwable {
  BaseHandler.CONFIG_FILE = "/com/nextdoor/bender/handler/config_test_sns.json";

  TestContext ctx = new TestContext();
  ctx.setFunctionName("unittest");
  ctx.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test-function:staging");

  /*
   * Invoke handler
   */
  SNSS3Handler fhandler = (SNSS3Handler) getHandler();
  fhandler.init(ctx);

  IpcSenderService ipcSpy = spy(fhandler.getIpcService());
  doThrow(new TransportException("expected")).when(ipcSpy).shutdown();
  fhandler.setIpcService(ipcSpy);

  AmazonSNSClient mockClient = mock(AmazonSNSClient.class);
  AmazonSNSClientFactory mockClientFactory = mock(AmazonSNSClientFactory.class);
  doReturn(mockClient).when(mockClientFactory).newInstance();

  fhandler.snsClientFactory = mockClientFactory;

  SNSEvent event = getTestEvent();

  try {
    fhandler.handler(event, ctx);
  } catch (Exception e) {
  }
  verify(mockClient, times(1)).publish("foo", "basic_input.log", "SNSS3Handler Failed");
}
项目:emodb    文件:ScanUploadModule.java   
@Provides
@Singleton
protected AmazonSNS provideAmazonSNS(Region region, AWSCredentialsProvider credentialsProvider) {
    AmazonSNS amazonSNS = new AmazonSNSClient(credentialsProvider);
    amazonSNS.setRegion(region);
    return amazonSNS;
}
项目:thingsboard    文件:SnsPlugin.java   
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);

}
项目:cerberus-lifecycle-cli    文件:CerberusModule.java   
/**
 * Binds all the Amazon services used.
 */
@Override
protected void configure() {
    final Region region = Region.getRegion(Regions.fromName(regionName));
    bind(AmazonEC2.class).toInstance(createAmazonClientInstance(AmazonEC2Client.class, region));
    bind(AmazonCloudFormation.class).toInstance(createAmazonClientInstance(AmazonCloudFormationClient.class, region));
    bind(AmazonIdentityManagement.class).toInstance(createAmazonClientInstance(AmazonIdentityManagementClient.class, region));
    bind(AWSKMS.class).toInstance(createAmazonClientInstance(AWSKMSClient.class, region));
    bind(AmazonS3.class).toInstance(createAmazonClientInstance(AmazonS3Client.class, region));
    bind(AmazonAutoScaling.class).toInstance(createAmazonClientInstance(AmazonAutoScalingClient.class, region));
    bind(AWSSecurityTokenService.class).toInstance(createAmazonClientInstance(AWSSecurityTokenServiceClient.class, region));
    bind(AWSLambda.class).toInstance(createAmazonClientInstance(AWSLambdaClient.class, region));
    bind(AmazonSNS.class).toInstance(createAmazonClientInstance(AmazonSNSClient.class, region));
}
项目:aws-iprange-update-checker    文件:RangeCheckHandler.java   
public String handleRequest(Context context) throws IOException {
  LambdaLogger logger = context.getLogger();
  logger.log("handleRequest start.");
  ObjectMapper mapper = new ObjectMapper();
  JsonObject json = mapper.readValue(new URL(IP_RANGE_URL), JsonObject.class);

  AmazonS3Client s3 = getS3Client();
  Properties props = getProperties();
  s3.setEndpoint(props.getProperty("s3.endpoint"));

  GetObjectRequest request = new GetObjectRequest(props.getProperty(S3_BUCKETNAME_KEY), CHECKED_FILE_NAME);
  try {
    S3Object beforeObject = s3.getObject(request);
    InputStream is = beforeObject.getObjectContent();
    JsonObject beforeJson = mapper.readValue(is, JsonObject.class);
    Optional<String> diff = beforeJson.getDiff(json);
    if (diff.isPresent()) {
      AmazonSNSClient sns = getSNSClient();
      sns.setRegion(Region.getRegion(Regions.fromName(props.getProperty("sns.region"))));
      PublishRequest publishRequest = new PublishRequest(props.getProperty("sns.topic.arn"), diff.get(), SNS_SUBJECT);
      PublishResult result = sns.publish(publishRequest);
      logger.log("send sns message. messageId = " + result.getMessageId());
    }
  } catch (AmazonS3Exception e) {
    logger.log("before checked-ip-ranges.json does not exist.");
  }
  storeCheckedIpRange(json);
  logger.log("stored checked-ip-ranges.json");
  return "success";
}
项目:aws-iprange-update-checker    文件:RangeCheckHandler.java   
private AmazonSNSClient getSNSClient() {
  Optional<AWSCredentials> credentials = getCredentials();
  if (credentials.isPresent()) {
    return new AmazonSNSClient(credentials.get());
  } else {
    return new AmazonSNSClient(new EnvironmentVariableCredentialsProvider());
  }
}
项目:aws-java-sns-mobile-push-sample    文件:CreateEndpointJob.java   
public CreateEndpointJob() {
    try {
        client = new AmazonSNSClient(
                new PropertiesCredentials(
                        BatchCreatePlatformEndpointSample.class
                                .getClassLoader()
                                .getResourceAsStream(BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE)));
    } catch (Exception e) {
        System.err
                .println("[ERROR] Error opening file <"
                        + BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE + ">"
                        + " " + e.getMessage());
        System.exit(BatchCreatePlatformEndpointSample.CREDENTIAL_RETRIEVAL_FAILURE_ERROR_CODE);
    }
}
项目:detective    文件:AwsServiceImpl.java   
private void factory() {
  ClientConfiguration clientConfig = new ClientConfiguration();
  clientConfig.setProtocol(Protocol.HTTP);

  if (isProxyMode()) {
    log.info("======AWS run in proxy mode." + getProxyHost() + ":" + getProxyPort() + "======");
    System.err.println("======AWS run in proxy mode." + getProxyHost() + ":" + getProxyPort()
        + "======");
    clientConfig.setProxyHost(getProxyHost());
    clientConfig.setProxyPort(getProxyPort());
    if (getProxyUsername() != null && getProxyUsername().length() > 0)
      clientConfig.setProxyUsername(getProxyUsername());
    if (getProxyPassword() != null && getProxyPassword().length() > 0)
      clientConfig.setProxyPassword(getProxyPassword());
  } else {
    log.info("======AWS run in normal mode." + "======");
    System.err.println("======AWS run in normal mode." + "======");
  }

  credentialsProvider = this.createCredentialsProvider();

  s3 = new AmazonS3Client(credentialsProvider, clientConfig);
  s3.setEndpoint(s3Endpoint);

  queue = new AmazonSQSClient(credentialsProvider, clientConfig);
  queue.setEndpoint(sqsEndpoint);

  sns = new AmazonSNSClient(credentialsProvider, clientConfig);
  sns.setEndpoint(snsEndpoint);

  dydbv2 = new AmazonDynamoDBClient(credentialsProvider, clientConfig);
  dydbv2.setEndpoint(dynamodbEndpoint);
}
项目:DenunciaMXBackEnd    文件:SNSMobilePush.java   
public SNSMobilePush(AmazonSNSClient client,Denuncia d)
{
    this.client=client;
    client.setEndpoint("https://sns.us-west-2.amazonaws.com");
    this.snsClientWrapper= new AmazonSNSClientWrapper(client,d);

}
项目:spring-cloud-aws    文件:NotificationArgumentResolverBeanDefinitionParserTest.java   
@Test
public void parseInternal_minimalConfiguration_configuresHandlerMethodArgumentResolverWithAmazonSnsImplicitlyConfigured() throws Exception {
    //Arrange
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-minimal.xml", getClass());

    //Act
    HandlerMethodArgumentResolver argumentResolver = context.getBean(HandlerMethodArgumentResolver.class);

    //Assert
    assertNotNull(argumentResolver);
    assertTrue(context.containsBean(getBeanName(AmazonSNSClient.class.getName())));
}
项目:spring-cloud-aws    文件:NotificationArgumentResolverBeanDefinitionParserTest.java   
@Test
public void parseInternal_customRegion_configuresHandlerMethodArgumentResolverWithAmazonSnsImplicitlyConfiguredAndCustomRegionSet() throws Exception {
    //Arrange
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-customRegion.xml", getClass());

    //Act
    AmazonSNSClient snsClient = context.getBean(AmazonSNSClient.class);

    //Assert
    assertEquals(new URI("https", Region.getRegion(Regions.EU_WEST_1).getServiceEndpoint("sns"), null, null), ReflectionTestUtils.getField(snsClient, "endpoint"));
}
项目:spring-cloud-aws    文件:NotificationArgumentResolverBeanDefinitionParserTest.java   
@Test
public void parseInternal_customRegionProvider_configuresHandlerMethodArgumentResolverWithAmazonSnsImplicitlyConfiguredAndCustomRegionSet() throws Exception {
    //Arrange
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-customRegionProvider.xml", getClass());

    //Act
    AmazonSNSClient snsClient = context.getBean(AmazonSNSClient.class);

    //Assert
    assertEquals(new URI("https", Region.getRegion(Regions.US_WEST_2).getServiceEndpoint("sns"), null, null), ReflectionTestUtils.getField(snsClient, "endpoint"));
}
项目:spring-cloud-aws    文件:NotificationArgumentResolverBeanDefinitionParserTest.java   
@Test
public void parseInternal_customSnsClient_configuresHandlerMethodArgumentResolverWithCustomSnsClient() throws Exception {
    //Arrange
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-customSnsClient.xml", getClass());

    //Act
    AmazonSNSClient snsClient = context.getBean("customSnsClient", AmazonSNSClient.class);

    //Assert
    assertNotNull(snsClient);
    assertFalse(context.containsBean(getBeanName(AmazonSNSClient.class.getName())));
}
项目:spring-cloud-aws    文件:NotificationMessagingTemplateBeanDefinitionParserTest.java   
@Test
public void parseInternal_withMinimalConfig_shouldCreateDefaultTemplate() throws Exception {
    //Arrange
    DefaultListableBeanFactory registry = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);

    //Act
    reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-minimal.xml", getClass()));

    //Assert
    NotificationMessagingTemplate notificationMessagingTemplate = registry.getBean(NotificationMessagingTemplate.class);
    assertSame(registry.getBean(AmazonSNSClient.class), ReflectionTestUtils.getField(notificationMessagingTemplate, "amazonSns"));

    Object cachingDestinationResolverProxy = ReflectionTestUtils.getField(notificationMessagingTemplate, "destinationResolver");
    Object targetDestinationResolver = ReflectionTestUtils.getField(cachingDestinationResolverProxy, "targetDestinationResolver");
    assertEquals(registry.getBean(GlobalBeanDefinitionUtils.RESOURCE_ID_RESOLVER_BEAN_NAME), ReflectionTestUtils.getField(targetDestinationResolver, "resourceIdResolver"));

    assertTrue(CompositeMessageConverter.class.isInstance(notificationMessagingTemplate.getMessageConverter()));
    @SuppressWarnings("unchecked")
    List<MessageConverter> messageConverters = (List<MessageConverter>) ReflectionTestUtils.getField(notificationMessagingTemplate.getMessageConverter(), "converters");
    assertEquals(2, messageConverters.size());
    assertTrue(StringMessageConverter.class.isInstance(messageConverters.get(0)));
    assertTrue(MappingJackson2MessageConverter.class.isInstance(messageConverters.get(1)));

    StringMessageConverter stringMessageConverter = (StringMessageConverter) messageConverters.get(0);
    assertSame(String.class, stringMessageConverter.getSerializedPayloadClass());
    assertEquals(false, ReflectionTestUtils.getField(stringMessageConverter, "strictContentTypeMatch"));

    MappingJackson2MessageConverter jackson2MessageConverter = (MappingJackson2MessageConverter) messageConverters.get(1);
    assertSame(String.class, jackson2MessageConverter.getSerializedPayloadClass());
    assertEquals(false, ReflectionTestUtils.getField(jackson2MessageConverter, "strictContentTypeMatch"));
}
项目:spring-cloud-aws    文件:NotificationMessagingTemplateBeanDefinitionParserTest.java   
@Test
public void parseInternal_withCustomRegion_shouldConfigureDefaultClientWithCustomRegion() throws Exception {
    //Arrange
    DefaultListableBeanFactory registry = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);

    //Act
    reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-custom-region.xml", getClass()));

    //Assert
    AmazonSNSClient amazonSns = registry.getBean(AmazonSNSClient.class);
    assertEquals("https://" + Region.getRegion(Regions.EU_WEST_1).getServiceEndpoint("sns"), ReflectionTestUtils.getField(amazonSns, "endpoint").toString());
}
项目:spring-cloud-aws    文件:NotificationMessagingTemplateBeanDefinitionParserTest.java   
@Test
public void parseInternal_withCustomRegionProvider_shouldConfigureDefaultClientWithCustomRegionReturnedByProvider() throws Exception {
    //Arrange
    DefaultListableBeanFactory registry = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);

    //Act
    reader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-custom-region-provider.xml", getClass()));

    //Assert
    AmazonSNSClient amazonSns = registry.getBean(AmazonSNSClient.class);
    assertEquals("https://" + Region.getRegion(Regions.CN_NORTH_1).getServiceEndpoint("sns"), ReflectionTestUtils.getField(amazonSns, "endpoint").toString());
}
项目:s3-bucket-loader    文件:ControlChannel.java   
public ControlChannel(boolean callerIsMaster,
                      String awsAccessKey, String awsSecretKey, String snsControlTopicName, 
                      String userAccountPrincipalId, 
                      String userARN, 
                      CCPayloadHandler ccPayloadHandler) throws Exception {
    super();

    try {
        this.mySourceIp = InetAddress.getLocalHost().getHostAddress();
    } catch(Exception e) {
        logger.error("Error getting local inet address: " + e.getMessage());
    }

    mySourceIdentifier = determineHostName() + "-" +uuid;
    this.snsControlTopicName = snsControlTopicName;

    if (callerIsMaster) {
        canDestroyTopic = true;
        this.snsControlTopicName += "-" + mySourceIdentifier;
    }

    this.ccPayloadHandler = ccPayloadHandler;

    sqsClient = new AmazonSQSClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey));
    snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey));


    this.connectToTopic(callerIsMaster, 1000, userAccountPrincipalId, userARN);



}
项目:wildfly-camel    文件:SNSUtils.java   
public static AmazonSNSClient createNotificationClient() {
    BasicCredentialsProvider credentials = BasicCredentialsProvider.standard();
    AmazonSNSClient client = !credentials.isValid() ? null : (AmazonSNSClient)
            AmazonSNSClientBuilder.standard()
            .withCredentials(credentials)
            .withRegion("eu-west-1")
            .build();
    return client;
}
项目:usergrid    文件:SNSQueueManagerImpl.java   
/**
 * The Synchronous SNS client is used for creating topics and subscribing queues.
 */
private AmazonSNSClient createSNSClient( final Region region ) {

    final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
    final AmazonSNSClient sns =
        new AmazonSNSClient( ugProvider.getCredentials(), clientConfiguration );

    sns.setRegion( region );

    return sns;
}
项目:aws-snsmobilepush    文件:CreateEndpointJob.java   
public CreateEndpointJob() {

        try {
            client = new AmazonSNSClient(
                    new PropertiesCredentials(
                            BatchCreatePlatformEndpointSample.class
                                    .getResourceAsStream(BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE)));
        } catch (IOException ioe) {
            System.err
                    .print("[ERROR] Error opening file"
                            + BatchCreatePlatformEndpointSample.AWSCREDENTIALSPROPERTIES_FILE
                            + ": " + ioe.getMessage());
            System.exit(BatchCreatePlatformEndpointSample.CREDENTIAL_RETRIEVAL_FAILURE_ERROR_CODE);
        }
    }
项目:aws-snsmobilepush    文件:SNSMobilePush.java   
public static void main(String[] args) throws IOException{
    /*
     * TODO: Be sure to fill in your AWS access credentials in the
     * AwsCredentials.properties file before you try to run this sample.
     * http://aws.amazon.com/security-credentials
     */
    AmazonSNS sns = new AmazonSNSClient(new PropertiesCredentials(
            SNSMobilePush.class
                    .getResourceAsStream("AwsCredentials.properties")));

    sns.setEndpoint("https://sns.us-west-2.amazonaws.com");
    System.out.println("===========================================\n");
    System.out.println("Getting Started with Amazon SNS");
    System.out.println("===========================================\n");
    try {
        SNSMobilePush sample = new SNSMobilePush(sns);
        // TODO: Uncomment the services you wish to use.
        //sample.demoAndroidAppNotification(Platform.GCM);
        //sample.demoKindleAppNotification(Platform.ADM);
        //sample.demoAppleAppNotification(Platform.APNS);
        //sample.demoAppleAppNotification(Platform.APNS_SANDBOX);
    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon SNS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out
                .println("Caught an AmazonClientException, which means the client encountered "
                        + "a serious internal problem while trying to communicate with SNS, such as not "
                        + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}
项目:bender    文件:AmazonSNSClientFactory.java   
public AmazonSNSClient newInstance() {
  return new AmazonSNSClient();
}
项目:aufzugswaechter    文件:AmazonSNSFacilityStateChangedEventEmailSubscriptionService.java   
public AmazonSNSClient getClient() {
    return client;
}
项目:aufzugswaechter    文件:AmazonSNSFacilityStateChangedEventEmailSubscriptionService.java   
public void setClient(AmazonSNSClient client) {
    this.client = client;
}
项目:s3_video    文件:AWSAdapter.java   
public AmazonSNSClient getSnsClient() {
    return snsClient;
}
项目:s3_video    文件:AWSAdapter.java   
public void setSnsClient(AmazonSNSClient snsClient) {
    this.snsClient = snsClient;
}
项目:enhanced-snapshots    文件:AmazonConfigProvider.java   
protected AmazonSNS amazonSNSClient() {
    AmazonSNSClient snsClient = new AmazonSNSClient(amazonCredentialsProvider());
    snsClient.setRegion(getRegion());
    return snsClient;
}
项目:enhanced-snapshots    文件:AmazonConfigProviderDEV.java   
@Override
protected AmazonSNS amazonSNSClient() {
    AmazonSNSClient snsClient = new AmazonSNSClient(awsCredentials());
    snsClient.setRegion(getRegion());
    return snsClient;
}
项目:aws-java-sdk    文件:SNSService.java   
public SNSService() {
    this(new AmazonSNSClient());
}
项目:aws-java-sns-mobile-push-sample    文件:SNSMobilePush.java   
public static void main(String[] args) throws IOException {
    /*
     * TODO: Be sure to fill in your AWS access credentials in the
     * AwsCredentials.properties file before you try to run this sample.
     * http://aws.amazon.com/security-credentials
     */
    AmazonSNS sns = new AmazonSNSClient(new PropertiesCredentials(
            SNSMobilePush.class
                    .getResourceAsStream("AwsCredentials.properties")));

    sns.setEndpoint("https://sns.us-west-2.amazonaws.com");
    System.out.println("===========================================\n");
    System.out.println("Getting Started with Amazon SNS");
    System.out.println("===========================================\n");
    try {
        SNSMobilePush sample = new SNSMobilePush(sns);
        /* TODO: Uncomment the services you wish to use. */
        // sample.demoAndroidAppNotification();
        // sample.demoKindleAppNotification();
        // sample.demoAppleAppNotification();
        // sample.demoAppleSandboxAppNotification();
        // sample.demoBaiduAppNotification();
        // sample.demoWNSAppNotification();
        // sample.demoMPNSAppNotification();
    } catch (AmazonServiceException ase) {
        System.out
                .println("Caught an AmazonServiceException, which means your request made it "
                        + "to Amazon SNS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out
                .println("Caught an AmazonClientException, which means the client encountered "
                        + "a serious internal problem while trying to communicate with SNS, such as not "
                        + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}