Search in sources :

Example 1 with GetBucketEncryptionResult

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();
}
Also used : ServerSideEncryptionRule(com.amazonaws.services.s3.model.ServerSideEncryptionRule) ServerSideEncryptionByDefault(com.amazonaws.services.s3.model.ServerSideEncryptionByDefault) ArrayList(java.util.ArrayList) GetBucketEncryptionResult(com.amazonaws.services.s3.model.GetBucketEncryptionResult) ServerSideEncryptionConfiguration(com.amazonaws.services.s3.model.ServerSideEncryptionConfiguration) SetBucketEncryptionRequest(com.amazonaws.services.s3.model.SetBucketEncryptionRequest)

Aggregations

GetBucketEncryptionResult (com.amazonaws.services.s3.model.GetBucketEncryptionResult)1 ServerSideEncryptionByDefault (com.amazonaws.services.s3.model.ServerSideEncryptionByDefault)1 ServerSideEncryptionConfiguration (com.amazonaws.services.s3.model.ServerSideEncryptionConfiguration)1 ServerSideEncryptionRule (com.amazonaws.services.s3.model.ServerSideEncryptionRule)1 SetBucketEncryptionRequest (com.amazonaws.services.s3.model.SetBucketEncryptionRequest)1 ArrayList (java.util.ArrayList)1