diff --git a/src/aws-cpp-sdk-s3-encryption/include/aws/s3-encryption/S3EncryptionClient.h b/src/aws-cpp-sdk-s3-encryption/include/aws/s3-encryption/S3EncryptionClient.h index b0dc652b6be..14b270b627c 100644 --- a/src/aws-cpp-sdk-s3-encryption/include/aws/s3-encryption/S3EncryptionClient.h +++ b/src/aws-cpp-sdk-s3-encryption/include/aws/s3-encryption/S3EncryptionClient.h @@ -66,6 +66,14 @@ namespace Aws S3EncryptionClientBase(const std::shared_ptr& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig, const std::shared_ptr& credentialsProvider, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration()); + /* + * Initialize the S3EncryptionClientBase with encryption materials, crypto configuration, and a s3 client factory. + * The factory will be used to create the underlying S3 Client. + */ + S3EncryptionClientBase(const std::shared_ptr& encryptionMaterials, + const Aws::S3Encryption::CryptoConfiguration& cryptoConfig, + const std::function ()>& s3ClientFactory); + S3EncryptionClientBase(const S3EncryptionClientBase&) = delete; S3EncryptionClientBase& operator=(const S3EncryptionClientBase&) = delete; @@ -180,6 +188,17 @@ namespace Aws Init(cryptoConfig); } + /* + * Initialize the S3 Encryption Client V2 with crypto configuration v2, and a s3 client factory. + * The factory will be used to create the underlying S3 Client. + */ + S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2& cryptoConfig, + const std::function ()>& s3ClientFactory) + : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), s3ClientFactory) + { + Init(cryptoConfig); + } + S3EncryptionClientV2(const S3EncryptionClientV2&) = delete; S3EncryptionClientV2& operator=(const S3EncryptionClientV2&) = delete; diff --git a/src/aws-cpp-sdk-s3-encryption/source/s3-encryption/S3EncryptionClient.cpp b/src/aws-cpp-sdk-s3-encryption/source/s3-encryption/S3EncryptionClient.cpp index 20a17f6ee0c..7fcfe10b3a9 100644 --- a/src/aws-cpp-sdk-s3-encryption/source/s3-encryption/S3EncryptionClient.cpp +++ b/src/aws-cpp-sdk-s3-encryption/source/s3-encryption/S3EncryptionClient.cpp @@ -48,6 +48,14 @@ namespace Aws m_s3Client->AppendToUserAgent("ft/S3CryptoV1n"); } + S3EncryptionClientBase::S3EncryptionClientBase(const std::shared_ptr& encryptionMaterials, + const Aws::S3Encryption::CryptoConfiguration& cryptoConfig, + const std::function ()>& s3ClientFactory) : + m_s3Client(s3ClientFactory()), m_cryptoModuleFactory(), m_encryptionMaterials(encryptionMaterials), m_cryptoConfig(cryptoConfig) + { + m_s3Client->AppendToUserAgent("ft/S3CryptoV1n"); + } + S3EncryptionPutObjectOutcome S3EncryptionClientBase::PutObject(const Aws::S3::Model::PutObjectRequest& request, const Aws::Map& contextMap) const { auto module = m_cryptoModuleFactory.FetchCryptoModule(m_encryptionMaterials, m_cryptoConfig);