private void enableS3Encryption(PutObjectRequest uploadRequest) { ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); uploadRequest.setMetadata(objectMetadata); } }
@Override protected boolean copyObject(String src, String dst) { LOG.debug("Copying {} to {}", src, dst); // Retry copy for a few times, in case some AWS internal errors happened during copy. int retries = 3; for (int i = 0; i < retries; i++) { try { CopyObjectRequest request = new CopyObjectRequest(mBucketName, src, mBucketName, dst); if (Boolean.parseBoolean( mConf.get(PropertyKey.UNDERFS_S3A_SERVER_SIDE_ENCRYPTION_ENABLED))) { ObjectMetadata meta = new ObjectMetadata(); meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); request.setNewObjectMetadata(meta); } mManager.copy(request).waitForCopyResult(); return true; } catch (AmazonClientException | InterruptedException e) { LOG.error("Failed to copy file {} to {}", src, dst, e); if (i != retries - 1) { LOG.error("Retrying copying file {} to {}", src, dst); } } } LOG.error("Failed to copy file {} to {}, after {} retries", src, dst, retries); return false; }
meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
@Override public PutObjectRequest decorate(PutObjectRequest request) { final ObjectMetadata objectMetadata = request.getMetadata() == null ? new ObjectMetadata() : request.getMetadata().clone(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); return request.withMetadata(objectMetadata); }
@Override public CopyObjectRequest decorate(CopyObjectRequest request) { final ObjectMetadata objectMetadata = request.getNewObjectMetadata() == null ? new ObjectMetadata() : request.getNewObjectMetadata().clone(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); return request.withNewObjectMetadata(objectMetadata); } }
PutObjectRequest putObjectRequest = null; if (sseLocal.equals("true")) { metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); putObjectRequest = new PutObjectRequest(bucket, key, input, metadata);
/** * Initializes multipart upload. */ private void initMultiPartUpload() throws IOException { // Generate the object metadata by setting server side encryption, md5 checksum, // and encoding as octet stream since no assumptions are made about the file type ObjectMetadata meta = new ObjectMetadata(); if (mSseEnabled) { meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } if (mHash != null) { meta.setContentMD5(Base64.encodeAsString(mHash.digest())); } meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM); AmazonClientException lastException; InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(mBucketName, mKey).withObjectMetadata(meta); do { try { mUploadId = mClient.initiateMultipartUpload(initRequest).getUploadId(); return; } catch (AmazonClientException e) { lastException = e; } } while (mRetryPolicy.attempt()); // This point is only reached if the operation failed more // than the allowed retry count throw new IOException("Unable to init multipart upload to " + mKey, lastException); }
case S3: ObjectMetadata metadata = new ObjectMetadata(); metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); request.setMetadata(metadata); break;
/** * Writes given checkpoint data to a given S3 bucket. Data is serialized to * the binary stream and saved to the S3. * * @param data Checkpoint data. * @throws IgniteCheckedException Thrown if an error occurs while marshalling. * @throws AmazonClientException If an error occurs while querying Amazon S3. */ private void write(S3CheckpointData data) throws IgniteCheckedException, AmazonClientException { assert data != null; if (log.isDebugEnabled()) log.debug("Writing data to S3 [bucket=" + bucketName + ", key=" + data.getKey() + ']'); byte[] buf = data.toBytes(); ObjectMetadata meta = new ObjectMetadata(); meta.setContentLength(buf.length); if (!F.isEmpty(sseAlg)) meta.setSSEAlgorithm(sseAlg); s3.putObject(bucketName, data.getKey(), new ByteArrayInputStream(buf), meta); }
objectMetadata.setSSEAlgorithm(serverSideEncryption); attributes.put(S3_SSE_ALGORITHM, serverSideEncryption);
objMetadata.setSSEAlgorithm(sseAlg);
} else { if (uploadMetadata.isUseS3ServerSideEncryption()) { objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
om.setSSEAlgorithm(upload.sseAlgorithm);
@Test public void skipMd5CheckPerResponseTest() { final ObjectMetadata metadata = new ObjectMetadata(); metadata.setSSEAlgorithm(SSEAlgorithm.KMS.toString()); assertFalse(ServiceUtils.skipMd5CheckPerResponse(null)); assertTrue(ServiceUtils.skipMd5CheckPerResponse(metadata)); }
private void setOptionalObjectMetadata(ObjectMetadata metadata) { if (S3AEncryptionMethods.SSE_S3.equals(serverSideEncryptionAlgorithm)) { metadata.setSSEAlgorithm(serverSideEncryptionAlgorithm.getMethod()); } }
File.createTempFile("test", "test2")); final ObjectMetadata metadata = new ObjectMetadata(); metadata.setSSEAlgorithm(SSEAlgorithm.KMS.toString()); putObjectRequest.setMetadata(metadata);
private void applyObjectMetadata(CopyObjectRequest copyObjectRequest) { if (s3s3CopierOptions.isS3ServerSideEncryption()) { ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); copyObjectRequest.setNewObjectMetadata(objectMetadata); } }
private S3UploadDescriptor describeUpload(FileStatus sourceFileStatus, Path targetPath) throws IOException { URI targetUri = targetPath.toUri(); String bucketName = PathUtil.toBucketName(targetUri); String key = PathUtil.toBucketKey(targetUri); Path sourcePath = sourceFileStatus.getPath(); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(sourceFileStatus.getLen()); if (conf.getBoolean(ConfigurationVariable.S3_SERVER_SIDE_ENCRYPTION)) { metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } return new S3UploadDescriptor(sourcePath, bucketName, key, metadata); }
protected String doInitialize(S3BlobStore blobStore, String bucketName, String blobName, boolean serverSideEncryption) { InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest(bucketName, blobName); if (serverSideEncryption) { ObjectMetadata md = new ObjectMetadata(); md.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); request.setObjectMetadata(md); } return blobStore.client().initiateMultipartUpload(request).getUploadId(); }
from.setOngoingRestore(true); from.setRestoreExpirationTime(restoreExpirationTime); from.setSSEAlgorithm("ssealgo"); from.setSSECustomerKeyMd5("sseCustKeyMd5"); from.setSSECustomerAlgorithm("SSECustomerAlgorithm");