List of usage examples for com.amazonaws.services.s3.model ObjectMetadata AES_256_SERVER_SIDE_ENCRYPTION
String AES_256_SERVER_SIDE_ENCRYPTION
To view the source code for com.amazonaws.services.s3.model ObjectMetadata AES_256_SERVER_SIDE_ENCRYPTION.
Click Source Link
From source file:ohnosequences.ivy.S3Repository.java
License:Apache License
@Override protected void put(File source, String destination, boolean overwrite) { //System.out.print("parent> "); String bucket = S3Utils.getBucket(destination); String key = S3Utils.getKey(destination); // System.out.println("publishing: bucket=" + bucket + " key=" + key); PutObjectRequest request = new PutObjectRequest(bucket, key, source); request = request.withCannedAcl(acl); if (serverSideEncryption) { ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); request.setMetadata(objectMetadata); }//w w w . j a v a 2 s . c o m if (!getS3Client().doesBucketExist(bucket)) { if (!createBucket(bucket, region)) { throw new Error("couldn't create bucket"); } } if (!this.overwrite && !getS3Client().listObjects(bucket, key).getObjectSummaries().isEmpty()) { throw new Error(destination + " exists but overwriting is disabled"); } getS3Client().putObject(request); }
From source file:org.apache.beam.sdk.io.aws.s3.S3TestUtils.java
License:Apache License
static S3Options s3OptionsWithSSEAlgorithm() { S3Options options = s3Options(); options.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); return options; }
From source file:org.apache.jackrabbit.oak.blob.cloud.aws.s3.S3RequestDecorator.java
License:Apache License
/** * Set encryption in {@link PutObjectRequest} *//*from w w w .jav a2 s . c o m*/ public PutObjectRequest decorate(PutObjectRequest request) { switch (getDataEncryption()) { case SSE_S3: ObjectMetadata metadata = request.getMetadata() == null ? new ObjectMetadata() : request.getMetadata(); metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); request.setMetadata(metadata); break; case NONE: break; } return request; }
From source file:org.apache.jackrabbit.oak.blob.cloud.aws.s3.S3RequestDecorator.java
License:Apache License
/** * Set encryption in {@link CopyObjectRequest} *///from w ww.j a v a 2 s . com public CopyObjectRequest decorate(CopyObjectRequest request) { switch (getDataEncryption()) { case SSE_S3: ObjectMetadata metadata = request.getNewObjectMetadata() == null ? new ObjectMetadata() : request.getNewObjectMetadata(); metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); request.setNewObjectMetadata(metadata); break; case NONE: break; } return request; }
From source file:org.apache.nifi.processors.aws.s3.AbstractS3IT.java
License:Apache License
protected void putTestFileEncrypted(String key, File file) throws AmazonS3Exception, FileNotFoundException { ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); PutObjectRequest putRequest = new PutObjectRequest(BUCKET_NAME, key, new FileInputStream(file), objectMetadata);// w ww. j av a2s . c o m client.putObject(putRequest); }
From source file:org.apache.nifi.processors.aws.s3.encryption.ServerSideS3EncryptionStrategy.java
License:Apache License
@Override public void configurePutObjectRequest(PutObjectRequest request, ObjectMetadata objectMetadata, String keyValue) {/*from ww w.j a va 2 s. c om*/ objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); }
From source file:org.apache.nifi.processors.aws.s3.encryption.service.StandardS3ServerSideEncryptionService.java
License:Apache License
@OnEnabled public void onConfigured(final ConfigurationContext context) throws InitializationException { encryptionMethod = context.getProperty(ENCRYPTION_METHOD).getValue(); algorithm = context.getProperty(ALGORITHM).getValue(); kmsKeyId = context.getProperty(KMS_KEY_ID).getValue(); customerKey = context.getProperty(CUSTOMER_KEY).getValue(); customerKeyMD5 = context.getProperty(CUSTOMER_KEY_MD5).getValue(); customerAlgorithm = context.getProperty(CUSTOMER_ALGORITHM).getValue(); if (algorithm == null) algorithm = ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION; }
From source file:org.apache.nifi.processors.aws.s3.encryption.service.StandardS3ServerSideEncryptionService.java
License:Apache License
public void encrypt(PutObjectRequest putObjectRequest) { if (encryptionMethod == null) return;//from w ww . j a v a2s . c om if (encryptionMethod.equals(METHOD_SSE_S3)) { getLogger().info("Encrypting single part object using SSE-S3"); putObjectRequest.getMetadata() .setSSEAlgorithm(algorithm == null ? ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION : algorithm); } if (encryptionMethod.equals(METHOD_SSE_KMS)) { getLogger().info("Encrypting single part object using SSE-KMS"); putObjectRequest.setSSEAwsKeyManagementParams( kmsKeyId == null ? new SSEAwsKeyManagementParams() : new SSEAwsKeyManagementParams(kmsKeyId)); } if (encryptionMethod.equals(METHOD_SSE_C)) { getLogger().info("Encrypting single part object using SSE-C"); if (StringUtils.isNotBlank(customerKey)) { putObjectRequest.setSSECustomerKey(new SSECustomerKey(customerKey)); } String sseCustomerAlgorithm = customerAlgorithm == null ? ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION : customerAlgorithm; putObjectRequest.getMetadata().setSSECustomerAlgorithm(sseCustomerAlgorithm); if (StringUtils.isNotBlank(customerKeyMD5)) { putObjectRequest.getMetadata().setSSECustomerKeyMd5(customerKeyMD5); } } }
From source file:org.apache.nifi.processors.aws.s3.encryption.service.StandardS3ServerSideEncryptionService.java
License:Apache License
public void encrypt(InitiateMultipartUploadRequest initiateMultipartUploadRequest) { if (encryptionMethod == null) return;//from ww w . j a va 2s.c o m if (encryptionMethod.equals(METHOD_SSE_S3)) { getLogger().info("Encrypting multipart object using SSE-S3"); initiateMultipartUploadRequest.getObjectMetadata() .setSSEAlgorithm(algorithm == null ? ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION : algorithm); } if (encryptionMethod.equals(METHOD_SSE_KMS)) { getLogger().info("Encrypting multipart object using SSE-KMS"); initiateMultipartUploadRequest.setSSEAwsKeyManagementParams( kmsKeyId == null ? new SSEAwsKeyManagementParams() : new SSEAwsKeyManagementParams(kmsKeyId)); } if (encryptionMethod.equals(METHOD_SSE_C)) { getLogger().info("Encrypting multipart object using SSE-C"); if (StringUtils.isNotBlank(customerKey)) { initiateMultipartUploadRequest.setSSECustomerKey(new SSECustomerKey(customerKey)); } String sseCustomerAlgorithm = customerAlgorithm == null ? ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION : customerAlgorithm; initiateMultipartUploadRequest.getObjectMetadata().setSSECustomerAlgorithm(sseCustomerAlgorithm); if (StringUtils.isNotBlank(customerKeyMD5)) { initiateMultipartUploadRequest.getObjectMetadata().setSSECustomerKeyMd5(customerKeyMD5); } } }
From source file:org.apache.zeppelin.notebook.repo.OldS3NotebookRepo.java
License:Apache License
@Override public void save(Note note, AuthenticationInfo subject) throws IOException { String json = note.toJson();//ww w .jav a 2 s . com String key = user + "/" + "notebook" + "/" + note.getId() + "/" + "note.json"; File file = File.createTempFile("note", "json"); try { Writer writer = new OutputStreamWriter(new FileOutputStream(file)); writer.write(json); writer.close(); PutObjectRequest putRequest = new PutObjectRequest(bucketName, key, file); if (useServerSideEncryption) { // Request server-side encryption. ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); putRequest.setMetadata(objectMetadata); } s3client.putObject(putRequest); } catch (AmazonClientException ace) { throw new IOException("Unable to store note in S3: " + ace, ace); } finally { FileUtils.deleteQuietly(file); } }