use of com.amazonaws.services.s3.model.GetBucketEncryptionResult in project entrada by SIDN.
the class AmazonInitializer method enableEncryption.
private boolean enableEncryption() {
if (!encrypt) {
return true;
}
ServerSideEncryptionRule serverSideEncryptionRule = new ServerSideEncryptionRule();
ServerSideEncryptionByDefault serverSideEncryptionByDefault = new ServerSideEncryptionByDefault();
serverSideEncryptionByDefault.setSSEAlgorithm(SSEAlgorithm.AES256.getAlgorithm());
serverSideEncryptionRule.setApplyServerSideEncryptionByDefault(serverSideEncryptionByDefault);
SetBucketEncryptionRequest setBucketEncryptionRequest = new SetBucketEncryptionRequest();
setBucketEncryptionRequest.setBucketName(bucket);
ServerSideEncryptionConfiguration serverSideEncryptionConfiguration = new ServerSideEncryptionConfiguration();
ArrayList<ServerSideEncryptionRule> serverSideEncryptionRules = new ArrayList<>();
serverSideEncryptionRules.add(serverSideEncryptionRule);
serverSideEncryptionConfiguration.setRules(serverSideEncryptionRules);
setBucketEncryptionRequest.setServerSideEncryptionConfiguration(serverSideEncryptionConfiguration);
amazonS3.setBucketEncryption(setBucketEncryptionRequest);
GetBucketEncryptionResult result = amazonS3.getBucketEncryption(bucket);
return !result.getServerSideEncryptionConfiguration().getRules().isEmpty();
}
Aggregations