List of usage examples for com.amazonaws.auth PropertiesCredentials PropertiesCredentials
public PropertiesCredentials(InputStream inputStream) throws IOException
From source file:br.unb.cic.bionimbuz.elasticity.legacy.Ec2Commands.java
License:Open Source License
public static void setup() throws IOException, IllegalArgumentException { PropertiesCredentials credentials = new PropertiesCredentials( Ec2Commands.class.getResourceAsStream("AwsCredentials.properties")); EC2 = new AmazonEC2Client(credentials); EC2.setEndpoint("ec2.sa-east-1.amazonaws.com"); }
From source file:br.unb.cic.bionimbuz.services.elasticity.Ec2Commands.java
License:Open Source License
public static void setup() throws IOException, IllegalArgumentException { PropertiesCredentials credentials = new PropertiesCredentials( Ec2Commands.class.getResourceAsStream("/AwsCredentials.properties")); EC2 = new AmazonEC2Client(credentials); EC2.setEndpoint("ec2.us-west-2.amazonaws.com"); }
From source file:ch.qos.logback.more.appenders.DynamoDBLogbackAppender.java
License:Apache License
private boolean initializeAppender() { try {//from www. j av a 2 s. c o m PropertiesCredentials credentials = new PropertiesCredentials( getClass().getClassLoader().getResourceAsStream(dynamodbCredentialFilePath)); AmazonDynamoDBClient dynamoClient = new AmazonDynamoDBClient(credentials); dynamoClient.setEndpoint(dynamodbEndpoint); appender = new DynamoDBDaemonAppender(outputTableName, instanceName, getLastId(outputTableName, instanceName, dynamoClient), dynamoClient, layout, maxQueueSize); return true; } catch (Exception e) { System.err.println("Could not initialize " + DynamoDBLogbackAppender.class.getCanonicalName() + " ( will try to initialize again later ): " + e); return false; } }
From source file:Cloud.Tweets.SimpleQueueServiceSample.java
License:Open Source License
public AmazonSQS createSQSs() { System.out.println("helloooooooooooo"); AWSCredentials credentials;/* w ww . j av a 2s .c o m*/ try { credentials = new PropertiesCredentials( SimpleQueueServiceSample.class.getResourceAsStream("AwsCredentials.Properties")); System.out.println("hello"); //credentials = new ProfileCredentialsProvider("~/.aws/AwsCredentials.Properties").getCredentials(); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (/Users/daniel/.aws/credentials), and is in valid format.", e); } AmazonSQS sqs = new AmazonSQSClient(credentials); System.out.println(sqs.toString()); Region usWest2 = Region.getRegion(Regions.US_WEST_2); sqs.setRegion(usWest2); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SQS"); System.out.println("===========================================\n"); // Create a queue System.out.println("Creating a new SQS queue called MyQueue.\n"); CreateQueueRequest createQueueRequest = new CreateQueueRequest("MyQueue"); myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl(); // List queues System.out.println("Listing all queues in your account.\n"); for (String queueUrl : sqs.listQueues().getQueueUrls()) { System.out.println(" QueueUrl: " + queueUrl); } System.out.println(); return sqs; }
From source file:com.aipo.aws.AWSContext.java
License:Open Source License
private void setUp(String resourcePath, ServletContext context) { Properties properties = new Properties(); try {// ww w. j a va 2 s . c o m InputStream resourceAsStream = new FileInputStream(resourcePath); final String key = AEBEnvironmentProperties.AWS_ACCESS_KEY_ID; final String secret = AEBEnvironmentProperties.AWS_SECRET_KEY; if (key != null && key.length() > 0 && secret != null && secret.length() > 0) { awsCredentials = new AWSCredentials() { @Override public String getAWSAccessKeyId() { return key; } @Override public String getAWSSecretKey() { return secret; } }; } else { awsCredentials = new PropertiesCredentials(resourceAsStream); } resourceAsStream = new FileInputStream(resourcePath); try { properties.load(resourceAsStream); } finally { try { resourceAsStream.close(); } catch (Exception e) { } } } catch (Exception e) { System.out.println("'" + resourcePath + "' doesn't load."); } sdbEndpoint = properties.getProperty("sdbEndpoint"); s3Endpoint = properties.getProperty("s3Endpoint"); rdsEndpoint = properties.getProperty("rdsEndpoint"); sqsEndpoint = properties.getProperty("sqsEndpoint"); snsEndpoint = properties.getProperty("snsEndpoint"); sesEndpoint = properties.getProperty("sesEndpoint"); cloudWatchEndpoint = properties.getProperty("cloudWatchEndpoint"); prefix = properties.getProperty("prefix"); }
From source file:com.amazon.aws.myyoutube.videoUtil.GetRDSInstance.java
License:Open Source License
public static void main(String[] args) throws Exception { credentials = new PropertiesCredentials( GetRDSInstance.class.getResourceAsStream("AwsCredentials.properties")); try {// ww w .ja va 2 s. c o m rds = new AmazonRDSClient(credentials); /********************************************* * RDS DB *********************************************/ System.out.println("Creating a database instance"); CreateDBSecurityGroupRequest d = new CreateDBSecurityGroupRequest() .withDBSecurityGroupName("javaSecurityGroup1") .withDBSecurityGroupDescription("DB security group1"); rds.createDBSecurityGroup(d); AuthorizeDBSecurityGroupIngressRequest auth = new AuthorizeDBSecurityGroupIngressRequest() .withDBSecurityGroupName("javaSecurityGroup1") // .withEC2SecurityGroupName("javaSecurityGroup") .withCIDRIP("0.0.0.0/0"); // .withCIDRIP("216.165.95.69/32"); DBSecurityGroup dbsecuritygroup = rds.authorizeDBSecurityGroupIngress(auth); String[] dBSecurityGroups = { dbsecuritygroup.getDBSecurityGroupName() }; CreateDBInstanceRequest createDBInstanceRequest = new CreateDBInstanceRequest().withEngine("MySQL") .withLicenseModel("general-public-license").withEngineVersion("5.6.13") .withDBInstanceClass("db.t1.micro").withMultiAZ(false).withAutoMinorVersionUpgrade(true) .withAllocatedStorage(5).withDBInstanceIdentifier("mydbinstance1").withMasterUsername("awsuser") .withMasterUserPassword("mypassword").withDBName("dbname1").withPort(3306) .withAvailabilityZone(null).withDBSecurityGroups(dBSecurityGroups); ArrayList<String> arrDbSecur = new ArrayList<String>(); arrDbSecur.add("javaSecurityGroup1"); createDBInstanceRequest.setDBSecurityGroups(arrDbSecur); DBInstance dbInstance = rds.createDBInstance(createDBInstanceRequest); Thread.sleep(600000); DescribeDBInstancesRequest instRequest = new DescribeDBInstancesRequest() .withDBInstanceIdentifier("mydbinstance1"); DescribeDBInstancesResult instres = rds.describeDBInstances(instRequest); Endpoint e = instres.getDBInstances().get(0).getEndpoint(); System.out.println("ENd point " + e.getAddress() + " " + e.getPort()); System.out.println("Database Created"); System.out.println("Creating a table"); //connection java.sql.Connection con = null; Statement st = null; // Format "jdbc:mysql://" + hostname + ":" + port + "/" + dbName + "?user=" + userName + "&password=" + password; String url = "jdbc:mysql://" + e.getAddress() + ":" + e.getPort() + "/dbname1?user=awsuser&password=mypassword"; // "jdbc:mysql://master:password@"+e+"/dbname"; System.out.println("Url is " + url); String user = "awsuser"; String password = "mypassword"; con = DriverManager.getConnection(url, user, password); System.out.println("Connection created"); java.sql.Statement stat = con.createStatement(); String query = "CREATE TABLE Items ( item_id VARCHAR(200), type INTEGER, quantity INTEGER, user VARCHAR(100), price FLOAT(5,2) );"; stat.execute(query); String query1 = "CREATE TABLE WishList ( user VARCHAR(200), wishlistId VARCHAR(100) );"; stat.execute(query1); } catch (AmazonServiceException ase) { System.out.println("Caught Exception: " + ase.getMessage()); System.out.println("Response Status Code: " + ase.getStatusCode()); System.out.println("Error Code: " + ase.getErrorCode()); System.out.println("Request ID: " + ase.getRequestId()); } }
From source file:com.aws.sns.service.notifications.sns.SNSMobilePush.java
License:Open Source License
public static void main(String[] args) throws IOException { /*//from w ww . ja v a 2s . c o m * 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. */ String registrationId = "APA91bEzO4gs7gqC0PPaw1RKzlDY5cEmRwGzV4k5DPzc_uxp8aLyNVGS3Wx7G6O3lj9v17aqUBtoTyg3JZvbsOVt81mdUDTDDiXoiWLJt9PtcWUUNKYyJsiaq1OlPnSNRx2djcfPS7Pp"; sample.demoAndroidAppNotification(registrationId, "Test Message", "payload action", "Moonfrog"); // sample.demoKindleAppNotification(); // sample.demoAppleAppNotification("c522823644bf4e799d94adc7bc4c1f1dd57066a38cc72b7d37cf48129379c13b", "APNS Welcome !!!", "apns", "Moonfrog"); // 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()); } }
From source file:com.bye.project.S3TransferProgressSample.java
License:Open Source License
public static void main(String[] args) throws Exception { /*/* ww w .j ava 2s .c o m*/ * This credentials provider implementation loads your AWS credentials * from a properties file at the root of your classpath. * * TransferManager manages a pool of threads, so we create a * single instance and share it throughout our application. */ AmazonS3 s3 = new AmazonS3Client(credentials = new PropertiesCredentials( S3TransferProgressSample.class.getResourceAsStream("AwsCredentials.properties"))); Region usWest2 = Region.getRegion(Regions.US_WEST_2); s3.setRegion(usWest2); tx = new TransferManager(s3); bucketName = "s3-upload-sdk-sample-" + credentials.getAWSAccessKeyId().toLowerCase(); new S3TransferProgressSample(); }
From source file:com.carrotgarden.log4j.aws.sns.Appender.java
License:BSD License
/** instantiate amazon client */ protected boolean ensureAmazonClient() { try {/*from w w w .ja v a 2s.c o m*/ final File file = new File(getCredentials()); final AWSCredentials creds = new PropertiesCredentials(file); amazonClient = new AmazonSNSAsyncClient(creds, service); return true; } catch (final Exception e) { LogLog.error("sns: amazon client init failure", e); return false; } }
From source file:com.climate.oada.dao.impl.DynamodbDAO.java
License:Open Source License
/** * Init method to intialize AWS credentials. * * @throws Exception in case of error.// w w w . ja v a 2s. co m */ public void init() throws Exception { AWSCredentials credentials = new PropertiesCredentials( AmazonDynamoDB.class.getResourceAsStream("AwsCredentials.properties")); dynamoDB = new AmazonDynamoDBClient(credentials); }