/** * The only information needed to create a client are security credentials * consisting of the AWS Access Key ID and Secret Access Key. All other * configuration, such as the service endpoints, are performed * automatically. Client parameters, such as proxies, can be specified in an * optional ClientConfiguration object when constructing a client. * * @see com.amazonaws.auth.BasicAWSCredentials * @see com.amazonaws.auth.PropertiesCredentials * @see com.amazonaws.ClientConfiguration */ private PersistentStore(Region region, long readCapacity, long writeCapacity) throws Exception { /* * This credentials provider implementation loads your AWS credentials * from a properties file at the root of your classpath. */ dynamoDB = new AmazonDynamoDBClient( new ClasspathPropertiesFileCredentialsProvider()); dynamoDB.setRegion(region); try { if (!tablesExist()) { createTables(readCapacity, writeCapacity); } waitForTableToBecomeAvailable(TABLE_NAME); } catch (Exception e) { handleException(e); } }
MyCredentialsProvider() { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), // Removed due to ElasticBeanstalk environment not being setup with a profile dir // new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider()); }
protected AmazonDynamoDBDAO() { dynamoDB = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider()); Region usWest2 = Region.getRegion(Regions.US_WEST_2); String local_db = EnvironmentUtils.getInstance().getLocal_db(); if (local_db != null && local_db.trim().length() > 0) { // LOCAL dynamoDB.setEndpoint(local_db,"local","us-west-2"); } else { // PROD dynamoDB.setRegion(usWest2); } mapper = new DynamoDBMapper(dynamoDB); }
private static void updateApp() { System.out.println("Downloading file (duckdns-dist) duckdns.war ---> /var/tmp/duckdns.war"); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); AmazonS3 conn = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider(), clientConfig); conn.getObject(new GetObjectRequest("duckdns-dist", "duckdns.war"),new File("/var/tmp/duckdns.war")); System.out.println("Done"); }
/** * You can choose the geographical region where Amazon S3 will store the * buckets you create. You might choose a region to optimize latency, * minimize costs, or address regulator requirements. * * @param region */ public AmazonS3ManagerImpl(Region region) { LOG.info("Create an instance of the AmazonS3Client class by providing your " + "AWS Account or IAM user credentials (Access Key ID, Secret Access Key)"); // Create an instance of the AmazonS3Client class by providing your AWS // Account or IAM user credentials (Access Key ID, Secret Access Key) amazonS3Client = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); amazonS3Client.setRegion(region); }
/** * Creates a {@link PropertiesFileConfiguration} from values provided in a classpath properties file. * * @param propertiesFile the classpath properties file to load. */ public PropertiesFileConfiguration(String propertiesFile) { //load properties from configuration properties file Properties prop = loadProperty(propertiesFile); sqsUrl = prop.getProperty(SQS_URL); LibraryUtils.checkArgumentNotNull(sqsUrl, "Cannot find SQS URL in properties file."); String accessKey = prop.getProperty(ACCESS_KEY); String secretKey = prop.getProperty(SECRET_KEY); if (accessKey != null && secretKey != null) { awsCredentialsProvider = new ClasspathPropertiesFileCredentialsProvider(propertiesFile); } s3Region = prop.getProperty(S3_REGION); visibilityTimeout = getIntProperty(prop, VISIBILITY_TIMEOUT); sqsRegion = prop.getProperty(SQS_REGION); threadCount = getIntProperty(prop, THREAD_COUNT); threadTerminationDelaySeconds = getIntProperty(prop, THREAD_TERMINATION_DELAY_SECONDS); maxEventsPerEmit = getIntProperty(prop, MAX_EVENTS_PER_EMIT); enableRawEventInfo = getBooleanProperty(prop, ENABLE_RAW_EVENT_INFO); deleteMessageUponFailure = getBooleanProperty(prop, DELETE_MESSAGE_UPON_FAILURE); }
public FandomDAO() { client = new AmazonDynamoDBClient( new ClasspathPropertiesFileCredentialsProvider()); mapper = new DynamoDBMapper(client); Fandom test = mapper.load(Fandom.class, "fandoms"); if (test == null) { test = new Fandom(); test.setId("fandoms"); mapper.save(test); } }
public CraftDAO(){ client = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider()); mapper = new DynamoDBMapper(client); Craft test = mapper.load(Craft.class, "crafts"); if(test == null){ test = new Craft(); test.setId("crafts"); mapper.save(test); } }
@Override public void copyFiles(File directory, List<String> keys, boolean preserveDirectories) { try { List<File> files = new LinkedList<File>(); AmazonS3 client = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); for (String key : keys) { GetObjectRequest request = new GetObjectRequest("geodashboarddata", key); S3Object object = client.getObject(request); InputStream istream = object.getObjectContent(); try { String targetPath = this.getTargetPath(preserveDirectories, key); File file = new File(directory, targetPath); FileUtils.copyInputStreamToFile(istream, file); files.add(file); } finally { // Process the objectData stream. istream.close(); } } } catch (IOException e) { throw new ProgrammingErrorException(e); } }
private List<String> listFiles(String prefix) { List<String> files = new LinkedList<String>(); try { AmazonS3 s3Client = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); ListObjectsRequest request = new ListObjectsRequest(); request = request.withBucketName("geodashboarddata"); request = request.withPrefix(prefix); ObjectListing listing; do { listing = s3Client.listObjects(request); List<S3ObjectSummary> summaries = listing.getObjectSummaries(); for (S3ObjectSummary summary : summaries) { String key = summary.getKey(); if (key.endsWith(".xml.gz")) { files.add(key); } } request.setMarker(listing.getNextMarker()); } while (listing != null && listing.isTruncated()); } catch (Exception e) { logger.error("Unable to retrieve files", e); } return files; }
public CustomCredentialsProviderChain() { super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new ProfileCredentialsProvider()); }
@Bean AWSCredentialsProvider awsCredentials() { return new ClasspathPropertiesFileCredentialsProvider( "aws-credentials.properties" ); }
private static void init() { speechCloud = new IvonaSpeechCloudClient( new ClasspathPropertiesFileCredentialsProvider("resources/IvonaCredentials.properties")); speechCloud.setEndpoint("https://tts.eu-west-1.ivonacloud.com"); }
public CustomCredentialsProviderChain() { super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider()); }
public CustomCredentialsProviderChain() { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider()); }
public UserDAO() { client = new AmazonDynamoDBClient( new ClasspathPropertiesFileCredentialsProvider()); mapper = new DynamoDBMapper(client); }
public CommentDAO() { client = new AmazonDynamoDBClient( new ClasspathPropertiesFileCredentialsProvider()); mapper = new DynamoDBMapper(client); }
public PostDAO() { client = new AmazonDynamoDBClient( new ClasspathPropertiesFileCredentialsProvider()); mapper = new DynamoDBMapper(client); }
/** * The only information needed to create a client are security credentials * consisting of the AWS Access Key ID and Secret Access Key. All other * configuration, such as the service endpoints, are performed * automatically. Client parameters, such as proxies, can be specified in an * optional ClientConfiguration object when constructing a client. * * @see com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider * @see com.amazonaws.regions.Region */ public DynamoDBServiceImpl(Region region) { LOG.info("Initialize Amazon DynamoDB environment...!!!"); dynamoDBClient = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider()); dynamoDBClient.setRegion(region); }
/** * Returns an {@link AWSCredentialsProvider} with the permissions necessary to accomplish all specified * tasks. At the minimum it will require read permissions for Amazon Kinesis. Additional read permissions * and write permissions may be required based on the Pipeline used. * * @return */ public AWSCredentialsProvider getAWSCredentialsProvider() { return new ClasspathPropertiesFileCredentialsProvider("SumologicConnector.properties"); }