try { AmazonS3 s3 = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); String bucketName = getBucketName(); s3.createBucket(bucketName); S3Object object = s3.getObject(bucketName, getKey()); } catch (AmazonServiceException e) { String errorCode = e.getErrorCode(); if (!errorCode.equals("NoSuchKey")) { throw e; } Logger.getLogger(getClass()).debug("No such key!!!", e); }
public CredentialsProviderChain () { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new ProfileCredentialsProvider()); } }
/** * Constructor. */ public DefaultAWSCredentialsProviderChain() { super(new SystemPropertiesCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider()); } }
/** * Create the credentials needed for the application to be able to connect to Aws. Only triggered if the * property cloud.aws.credentials.provided is set to true in the config. * * @param credentialsFilePath The path of the file containing aws credentials * @return AWS credentials object to use to connect to AWS */ @Bean @ConditionalOnProperty(value = "genie.aws.credentials.file") public ClasspathPropertiesFileCredentialsProvider awsCredentialsFromFile( @Value("${genie.aws.credentials.file}") final String credentialsFilePath ) { log.info("Creating file credentials provider bean"); return new ClasspathPropertiesFileCredentialsProvider(credentialsFilePath); }
/** * Constructor. */ public DefaultAWSCredentialsProviderChain() { super(new SystemPropertiesCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider()); } }
/** * Constructor. */ public DefaultAWSCredentialsProviderChain() { super(new SystemPropertiesCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider()); } }
} else if (typeName.equals( ClasspathPropertiesFileCredentialsProvider.class.getSimpleName())) { return new ClasspathPropertiesFileCredentialsProvider(asMap.get(CREDENTIALS_FILE_PATH)); } else if (typeName.equals(DefaultAWSCredentialsProviderChain.class.getSimpleName())) { return new DefaultAWSCredentialsProviderChain();
public StreamScaler(Region region) throws Exception { pctFormat.setMaximumFractionDigits(1); // use the default provider chain plus support for classpath // properties // files ClientConfiguration config = new ClientConfiguration(); StringBuilder userAgent = new StringBuilder(ClientConfiguration.DEFAULT_USER_AGENT); userAgent.append(" "); userAgent.append(this.AWSApplication); userAgent.append("/"); userAgent.append(this.version); config.setUserAgent(userAgent.toString()); kinesisClient = new AmazonKinesisClient(new AWSCredentialsProviderChain( new DefaultAWSCredentialsProviderChain(), new ClasspathPropertiesFileCredentialsProvider()), config); kinesisClient.setRegion(region); String kinesisEndpoint = System.getProperty("kinesisEndpoint"); if (kinesisEndpoint != null) { kinesisClient.setEndpoint(kinesisEndpoint); } if (kinesisClient.getServiceName() == null) { throw new Exception("Unable to reach Kinesis Service"); } }
public CustomCredentialsProviderChain() { super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider()); } }
private static String lastKey = ""; private static String preLastKey = ""; ... do{ preLastKey = lastKey; AmazonS3 s3 = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); String bucketName = "bucketname"; ListObjectsRequest lstRQ = new ListObjectsRequest().withBucketName(bucketName).withPrefix(""); lstRQ.setMarker(lastKey); ObjectListing objectListing = s3.listObjects(lstRQ); // loop and get file on S3 for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { // get oject and do something..... } }while(lastKey != preLastKey);
public CustomCredentialsProviderChain() { super(new ClasspathPropertiesFileCredentialsProvider(), new EC2ContainerCredentialsProviderWrapper(), new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new ProfileCredentialsProvider()); } }
chain.add(new ClasspathPropertiesFileCredentialsProvider("awscredentials.properties")); return null; });
credentialsProvider = new ClasspathPropertiesFileCredentialsProvider(); } else { credentialsProvider = new EnvironmentVariableCredentialsProvider();
/** * 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); }
AmazonS3 s3 = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); String result = "Upload unsuccessfull because "; try {
AmazonS3 s3 = new AmazonS3Client(new ClasspathPropertiesFileCredentialsProvider()); String result = "Upload unsuccessfull because "; try {