List of usage examples for com.amazonaws.services.simpleemail AmazonSimpleEmailServiceClient AmazonSimpleEmailServiceClient
AmazonSimpleEmailServiceClient(AwsSyncClientParams clientParams)
From source file:com.trsvax.tapestry.aws.core.services.AWSCoreModule.java
License:Apache License
public static void bind(ServiceBinder binder) { //binder.bind(AWSMailTransport.class,AWSMailTransportImpl.class); binder.bind(AmazonS3.class, new ServiceBuilder<AmazonS3>() { public AmazonS3 buildService(ServiceResources serviceResources) { return new AmazonS3Client(serviceResources.getService(AWSCredentials.class)); }//www. j a v a 2 s . co m }); binder.bind(AmazonDynamoDB.class, new ServiceBuilder<AmazonDynamoDB>() { public AmazonDynamoDB buildService(ServiceResources serviceResources) { return new AmazonDynamoDBClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonEC2.class, new ServiceBuilder<AmazonEC2>() { public AmazonEC2 buildService(ServiceResources serviceResources) { return new AmazonEC2Client(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonSimpleDB.class, new ServiceBuilder<AmazonSimpleDB>() { public AmazonSimpleDB buildService(ServiceResources serviceResources) { return new AmazonSimpleDBClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonSQS.class, new ServiceBuilder<AmazonSQS>() { public AmazonSQS buildService(ServiceResources serviceResources) { return new AmazonSQSClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonSNS.class, new ServiceBuilder<AmazonSNS>() { public AmazonSNS buildService(ServiceResources serviceResources) { return new AmazonSNSClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonRDS.class, new ServiceBuilder<AmazonRDS>() { public AmazonRDS buildService(ServiceResources serviceResources) { return new AmazonRDSClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonElasticMapReduce.class, new ServiceBuilder<AmazonElasticMapReduce>() { public AmazonElasticMapReduce buildService(ServiceResources serviceResources) { return new AmazonElasticMapReduceClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonSimpleEmailService.class, new ServiceBuilder<AmazonSimpleEmailService>() { public AmazonSimpleEmailService buildService(ServiceResources serviceResources) { return new AmazonSimpleEmailServiceClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonElasticLoadBalancing.class, new ServiceBuilder<AmazonElasticLoadBalancing>() { public AmazonElasticLoadBalancing buildService(ServiceResources serviceResources) { return new AmazonElasticLoadBalancingClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonCloudWatch.class, new ServiceBuilder<AmazonCloudWatch>() { public AmazonCloudWatch buildService(ServiceResources serviceResources) { return new AmazonCloudWatchClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonAutoScaling.class, new ServiceBuilder<AmazonAutoScaling>() { public AmazonAutoScaling buildService(ServiceResources serviceResources) { return new AmazonAutoScalingClient(serviceResources.getService(AWSCredentials.class)); } }); binder.bind(AmazonIdentityManagement.class, new ServiceBuilder<AmazonIdentityManagement>() { public AmazonIdentityManagement buildService(ServiceResources serviceResources) { return new AmazonIdentityManagementClient(serviceResources.getService(AWSCredentials.class)); } }); }
From source file:fr.xebia.cloud.amazon.aws.iam.AmazonAwsIamAccountCreator.java
License:Apache License
public AmazonAwsIamAccountCreator(Environment environment) { this.environment = Preconditions.checkNotNull(environment); try {/* w w w . ja va 2 s . c o m*/ keyPairGenerator = KeyPairGenerator.getInstance("RSA", BOUNCY_CASTLE_PROVIDER_NAME); keyPairGenerator.initialize(1024, new SecureRandom()); String credentialsFileName = "AwsCredentials-" + environment.getIdentifier() + ".properties"; InputStream credentialsAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream(credentialsFileName); Preconditions.checkNotNull(credentialsAsStream, "File '/" + credentialsFileName + "' NOT found in the classpath"); AWSCredentials awsCredentials = new PropertiesCredentials(credentialsAsStream); iam = new AmazonIdentityManagementClient(awsCredentials); ses = new AmazonSimpleEmailServiceClient(awsCredentials); ec2 = new AmazonEC2Client(awsCredentials); ec2.setEndpoint("ec2.eu-west-1.amazonaws.com"); InputStream smtpPropertiesAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("smtp.properties"); Preconditions.checkNotNull(smtpPropertiesAsStream, "File '/smtp.properties' NOT found in the classpath"); final Properties smtpProperties = new Properties(); smtpProperties.load(smtpPropertiesAsStream); mailSession = Session.getInstance(smtpProperties, null); mailTransport = mailSession.getTransport(); if (smtpProperties.containsKey("mail.username")) { mailTransport.connect(smtpProperties.getProperty("mail.username"), smtpProperties.getProperty("mail.password")); } else { mailTransport.connect(); } try { mailFrom = new InternetAddress(smtpProperties.getProperty("mail.from")); } catch (Exception e) { throw new MessagingException("Exception parsing 'mail.from' from 'smtp.properties'", e); } } catch (Exception e) { throw Throwables.propagate(e); } }
From source file:fr.xebia.cloud.amazon.aws.tools.AmazonAwsToolsSender.java
License:Apache License
public AmazonAwsToolsSender() { try {/*from w w w. ja v a2s . c o m*/ InputStream credentialsAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("AwsCredentials.properties"); Preconditions.checkNotNull(credentialsAsStream, "File '/AwsCredentials.properties' NOT found in the classpath"); AWSCredentials awsCredentials = new PropertiesCredentials(credentialsAsStream); iam = new AmazonIdentityManagementClient(awsCredentials); ses = new AmazonSimpleEmailServiceClient(awsCredentials); ec2 = new AmazonEC2Client(awsCredentials); ec2.setEndpoint("ec2.eu-west-1.amazonaws.com"); InputStream smtpPropertiesAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("smtp.properties"); Preconditions.checkNotNull(smtpPropertiesAsStream, "File '/smtp.properties' NOT found in the classpath"); final Properties smtpProperties = new Properties(); smtpProperties.load(smtpPropertiesAsStream); mailSession = Session.getInstance(smtpProperties, null); mailTransport = mailSession.getTransport(); if (smtpProperties.containsKey("mail.username")) { mailTransport.connect(smtpProperties.getProperty("mail.username"), smtpProperties.getProperty("mail.password")); } else { mailTransport.connect(); } try { mailFrom = new InternetAddress(smtpProperties.getProperty("mail.from")); } catch (Exception e) { throw new MessagingException("Exception parsing 'mail.from' from 'smtp.properties'", e); } } catch (Exception e) { throw Throwables.propagate(e); } }
From source file:fr.xebia.demo.amazon.aws.AmazonAwsIamAccountCreator.java
License:Apache License
public AmazonAwsIamAccountCreator() throws IOException { InputStream credentialsAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("AwsCredentials.properties"); Preconditions.checkNotNull(credentialsAsStream, "File 'AwsCredentials.properties' NOT found in the classpath"); AWSCredentials awsCredentials = new PropertiesCredentials(credentialsAsStream); iam = new AmazonIdentityManagementClient(awsCredentials); ses = new AmazonSimpleEmailServiceClient(awsCredentials); }
From source file:fr.xebia.demo.amazon.aws.AmazonAwsIamAccountCreatorV2.java
License:Apache License
public AmazonAwsIamAccountCreatorV2() { try {//w ww . j a va2s . c om InputStream credentialsAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("AwsCredentials.properties"); Preconditions.checkNotNull(credentialsAsStream, "File 'AwsCredentials.properties' NOT found in the classpath"); AWSCredentials awsCredentials = new PropertiesCredentials(credentialsAsStream); iam = new AmazonIdentityManagementClient(awsCredentials); ses = new AmazonSimpleEmailServiceClient(awsCredentials); ec2 = new AmazonEC2Client(awsCredentials); ec2.setEndpoint("ec2.eu-west-1.amazonaws.com"); keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC"); keyPairGenerator.initialize(1024, new SecureRandom()); } catch (Exception e) { throw Throwables.propagate(e); } }
From source file:fr.xebia.demo.amazon.aws.AmazonAwsSesEmailVerifier.java
License:Apache License
public static void main(String[] args) throws Exception { InputStream credentialsAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("AwsCredentials.properties"); Preconditions.checkNotNull(credentialsAsStream, "File 'AwsCredentials.properties' NOT found in the classpath"); AWSCredentials awsCredentials = new PropertiesCredentials(credentialsAsStream); AmazonSimpleEmailService ses = new AmazonSimpleEmailServiceClient(awsCredentials); URL emailsToVerifyURL = Thread.currentThread().getContextClassLoader().getResource("emails-to-verify.txt"); List<String> emailsToVerify = Resources.readLines(emailsToVerifyURL, Charsets.ISO_8859_1); for (String emailToVerify : emailsToVerify) { System.out.println(emailToVerify); Thread.sleep(10 * 1000);//from w ww. ja va 2 s . c o m ses.verifyEmailAddress(new VerifyEmailAddressRequest().withEmailAddress(emailToVerify)); } }
From source file:it.polimi.modaclouds.cpimlibrary.mailservice.AmazonMailManager.java
License:Apache License
public AmazonMailManager(CloudMetadata metadata) { this.username = metadata.getUsernameMail(); this.credentials = null; try {// ww w .ja va 2 s . c om credentials = new PropertiesCredentials( getClass().getClassLoader().getResourceAsStream("AwsCredentials.properties")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.ses = new AmazonSimpleEmailServiceClient(this.credentials); verifyEmailAddress(this.username); }
From source file:net.smartcosmos.plugin.service.aws.email.AwsEmailService.java
License:Apache License
@Override public void sendEmail(String to, String subject, String plainMessage, String htmlMessage) { String from = context.getConfiguration().getAdminEmailAddress(); SendEmailRequest request = new SendEmailRequest().withSource(from); List<String> toAddresses = new ArrayList<String>(); toAddresses.add(to);//from w ww . ja v a2 s . com Destination destination = new Destination().withToAddresses(toAddresses); request.setDestination(destination); Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); Content textContent = new Content().withData(plainMessage); Content htmlContent = new Content().withData(htmlMessage); Body body = new Body().withHtml(htmlContent).withText(textContent); msg.setBody(body); request.setMessage(msg); AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); try { client.sendEmail(request); LOG.info("Registration confirmation sent to email " + to); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.smartcosmos.plugin.service.aws.email.AwsEmailService.java
License:Apache License
@Override public boolean isHealthy() { try {//from ww w .j av a2 s . c o m AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); client.getSendQuota(); return true; } catch (Exception e) { return false; } }
From source file:org.apache.camel.component.aws.ses.SesEndpoint.java
License:Apache License
private AmazonSimpleEmailService createSESClient() { AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey()); AmazonSimpleEmailService client = new AmazonSimpleEmailServiceClient(credentials); if (configuration.getAmazonSESEndpoint() != null) { client.setEndpoint(configuration.getAmazonSESEndpoint()); }/*from w w w . j av a 2 s .c om*/ configuration.setAmazonSESClient(client); return client; }