use of com.amazonaws.services.s3.model.InstructionFileId.DOT in project jackrabbit by apache.
the class Utils method openService.
/**
* Create AmazonS3Client from properties.
*
* @param prop properties to configure @link {@link AmazonS3Client}
* @return {@link AmazonS3Client}
*/
public static AmazonS3Client openService(final Properties prop) {
String accessKey = prop.getProperty(S3Constants.ACCESS_KEY);
String secretKey = prop.getProperty(S3Constants.SECRET_KEY);
AmazonS3Client s3service = null;
if (StringUtils.isNullOrEmpty(accessKey) || StringUtils.isNullOrEmpty(secretKey)) {
LOG.info("Configuring Amazon Client from environment");
s3service = new AmazonS3Client(getClientConfiguration(prop));
} else {
LOG.info("Configuring Amazon Client from property file.");
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
s3service = new AmazonS3Client(credentials, getClientConfiguration(prop));
}
String region = prop.getProperty(S3Constants.S3_REGION);
String endpoint = null;
String propEndPoint = prop.getProperty(S3Constants.S3_END_POINT);
if ((propEndPoint != null) && !"".equals(propEndPoint)) {
endpoint = propEndPoint;
} else {
if (StringUtils.isNullOrEmpty(region)) {
com.amazonaws.regions.Region s3Region = Regions.getCurrentRegion();
if (s3Region != null) {
region = s3Region.getName();
} else {
throw new AmazonClientException("parameter [" + S3Constants.S3_REGION + "] not configured and cannot be derived from environment");
}
}
if (DEFAULT_AWS_BUCKET_REGION.equals(region)) {
endpoint = S3 + DOT + AWSDOTCOM;
} else if (Region.EU_Ireland.toString().equals(region)) {
endpoint = "s3-eu-west-1" + DOT + AWSDOTCOM;
} else {
endpoint = S3 + DASH + region + DOT + AWSDOTCOM;
}
}
/*
* setting endpoint to remove latency of redirection. If endpoint is
* not set, invocation first goes us standard region, which
* redirects it to correct location.
*/
s3service.setEndpoint(endpoint);
LOG.info("S3 service endpoint [{}] ", endpoint);
s3service.setS3ClientOptions(getS3ClientOptions(prop));
return s3service;
}
use of com.amazonaws.services.s3.model.InstructionFileId.DOT in project jackrabbit-oak by apache.
the class Utils method openService.
/**
* Create AmazonS3Client from properties.
*
* @param prop properties to configure @link {@link AmazonS3Client}
* @return {@link AmazonS3Client}
*/
public static AmazonS3Client openService(final Properties prop) {
String accessKey = prop.getProperty(S3Constants.ACCESS_KEY);
String secretKey = prop.getProperty(S3Constants.SECRET_KEY);
AmazonS3Client s3service = null;
if (StringUtils.isNullOrEmpty(accessKey) || StringUtils.isNullOrEmpty(secretKey)) {
LOG.info("Configuring Amazon Client from environment");
s3service = new AmazonS3Client(getClientConfiguration(prop));
} else {
LOG.info("Configuring Amazon Client from property file.");
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
s3service = new AmazonS3Client(credentials, getClientConfiguration(prop));
}
String region = prop.getProperty(S3Constants.S3_REGION);
String endpoint = null;
String propEndPoint = prop.getProperty(S3Constants.S3_END_POINT);
if ((propEndPoint != null) & !"".equals(propEndPoint)) {
endpoint = propEndPoint;
} else {
if (StringUtils.isNullOrEmpty(region)) {
com.amazonaws.regions.Region s3Region = Regions.getCurrentRegion();
if (s3Region != null) {
region = s3Region.getName();
} else {
throw new AmazonClientException("parameter [" + S3Constants.S3_REGION + "] not configured and cannot be derived from environment");
}
}
if (DEFAULT_AWS_BUCKET_REGION.equals(region)) {
endpoint = S3 + DOT + AWSDOTCOM;
} else {
endpoint = S3 + DOT + region + DOT + AWSDOTCOM;
}
}
/*
* setting endpoint to remove latency of redirection. If endpoint is
* not set, invocation first goes us standard region, which
* redirects it to correct location.
*/
s3service.setEndpoint(endpoint);
LOG.info("S3 service endpoint [{}] ", endpoint);
return s3service;
}
use of com.amazonaws.services.s3.model.InstructionFileId.DOT in project aws-sdk-android by aws-amplify.
the class S3CryptoModuleBase method putObjectUsingInstructionFile.
/**
* Puts an encrypted object into S3, and puts an instruction file into S3.
* Encryption info is stored in the instruction file.
*
* @param putObjectRequest
* The request object containing all the parameters to upload a
* new object to Amazon S3.
* @return A {@link PutObjectResult} object containing the information
* returned by Amazon S3 for the new, created object.
*/
private PutObjectResult putObjectUsingInstructionFile(PutObjectRequest putObjectRequest) {
final File fileOrig = putObjectRequest.getFile();
final InputStream isOrig = putObjectRequest.getInputStream();
final PutObjectRequest putInstFileRequest = putObjectRequest.clone().withFile(null).withInputStream(null);
putInstFileRequest.setKey(putInstFileRequest.getKey() + DOT + DEFAULT_INSTRUCTION_FILE_SUFFIX);
// Create instruction
final ContentCryptoMaterial cekMaterial = createContentCryptoMaterial(putObjectRequest);
// Wraps the object data with a cipher input stream; note the metadata
// is mutated as a side effect.
final PutObjectRequest req = wrapWithCipher(putObjectRequest, cekMaterial);
// Put the encrypted object into S3
final PutObjectResult result;
try {
result = s3.putObject(req);
} finally {
cleanupDataSource(putObjectRequest, fileOrig, isOrig, req.getInputStream(), log);
}
// Put the instruction file into S3
s3.putObject(updateInstructionPutRequest(putInstFileRequest, cekMaterial));
// Return the result of the encrypted object PUT.
return result;
}
Aggregations