Search in sources :

Example 6 with SSECustomerKey

use of com.amazonaws.services.s3.model.SSECustomerKey in project hadoop by apache.

the class S3AFileSystem method setOptionalCopyObjectRequestParameters.

protected void setOptionalCopyObjectRequestParameters(CopyObjectRequest copyObjectRequest) throws IOException {
    switch(serverSideEncryptionAlgorithm) {
        case SSE_KMS:
            copyObjectRequest.setSSEAwsKeyManagementParams(generateSSEAwsKeyParams());
            break;
        case SSE_C:
            if (StringUtils.isNotBlank(getServerSideEncryptionKey(getConf()))) {
                //at the moment, only supports copy using the same key
                SSECustomerKey customerKey = generateSSECustomerKey();
                copyObjectRequest.setSourceSSECustomerKey(customerKey);
                copyObjectRequest.setDestinationSSECustomerKey(customerKey);
            }
            break;
        default:
    }
}
Also used : SSECustomerKey(com.amazonaws.services.s3.model.SSECustomerKey)

Example 7 with SSECustomerKey

use of com.amazonaws.services.s3.model.SSECustomerKey in project hadoop by apache.

the class S3AInputStream method reopen.

/**
   * Opens up the stream at specified target position and for given length.
   *
   * @param reason reason for reopen
   * @param targetPos target position
   * @param length length requested
   * @throws IOException on any failure to open the object
   */
private synchronized void reopen(String reason, long targetPos, long length) throws IOException {
    if (wrappedStream != null) {
        closeStream("reopen(" + reason + ")", contentRangeFinish, false);
    }
    contentRangeFinish = calculateRequestLimit(inputPolicy, targetPos, length, contentLength, readahead);
    LOG.debug("reopen({}) for {} range[{}-{}], length={}," + " streamPosition={}, nextReadPosition={}", uri, reason, targetPos, contentRangeFinish, length, pos, nextReadPos);
    streamStatistics.streamOpened();
    try {
        GetObjectRequest request = new GetObjectRequest(bucket, key).withRange(targetPos, contentRangeFinish);
        if (S3AEncryptionMethods.SSE_C.equals(serverSideEncryptionAlgorithm) && StringUtils.isNotBlank(serverSideEncryptionKey)) {
            request.setSSECustomerKey(new SSECustomerKey(serverSideEncryptionKey));
        }
        wrappedStream = client.getObject(request).getObjectContent();
        contentRangeStart = targetPos;
        if (wrappedStream == null) {
            throw new IOException("Null IO stream from reopen of (" + reason + ") " + uri);
        }
    } catch (AmazonClientException e) {
        throw translateException("Reopen at position " + targetPos, uri, e);
    }
    this.pos = targetPos;
}
Also used : SSECustomerKey(com.amazonaws.services.s3.model.SSECustomerKey) AmazonClientException(com.amazonaws.AmazonClientException) IOException(java.io.IOException) GetObjectRequest(com.amazonaws.services.s3.model.GetObjectRequest)

Aggregations

SSECustomerKey (com.amazonaws.services.s3.model.SSECustomerKey)3 DBException (com.yahoo.ycsb.DBException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)2 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)2 S3Object (com.amazonaws.services.s3.model.S3Object)2 ByteArrayByteIterator (com.yahoo.ycsb.ByteArrayByteIterator)2 AmazonClientException (com.amazonaws.AmazonClientException)1 ClientConfiguration (com.amazonaws.ClientConfiguration)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 GetObjectMetadataRequest (com.amazonaws.services.s3.model.GetObjectMetadataRequest)1 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)1 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)1 PutObjectResult (com.amazonaws.services.s3.model.PutObjectResult)1 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)1 ByteIterator (com.yahoo.ycsb.ByteIterator)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1