Skip to content

Commit e9e0a91

Browse files
committed
Add constructor with s3Client factory to s3-encryption
1 parent a3934d0 commit e9e0a91

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/aws-cpp-sdk-s3-encryption/include/aws/s3-encryption/S3EncryptionClient.h

+19
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ namespace Aws
6666
S3EncryptionClientBase(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
6767
const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
6868

69+
/*
70+
* Initialize the S3EncryptionClientBase with encryption materials, crypto configuration, and a s3 client factory.
71+
* The factory will be used to create the underlying S3 Client.
72+
*/
73+
S3EncryptionClientBase(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials,
74+
const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
75+
const std::function<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory);
76+
6977
S3EncryptionClientBase(const S3EncryptionClientBase&) = delete;
7078
S3EncryptionClientBase& operator=(const S3EncryptionClientBase&) = delete;
7179

@@ -180,6 +188,17 @@ namespace Aws
180188
Init(cryptoConfig);
181189
}
182190

191+
/*
192+
* Initialize the S3 Encryption Client V2 with crypto configuration v2, and a s3 client factory.
193+
* The factory will be used to create the underlying S3 Client.
194+
*/
195+
S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2& cryptoConfig,
196+
const std::function<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory)
197+
: S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), s3ClientFactory)
198+
{
199+
Init(cryptoConfig);
200+
}
201+
183202
S3EncryptionClientV2(const S3EncryptionClientV2&) = delete;
184203
S3EncryptionClientV2& operator=(const S3EncryptionClientV2&) = delete;
185204

src/aws-cpp-sdk-s3-encryption/source/s3-encryption/S3EncryptionClient.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ namespace Aws
4848
m_s3Client->AppendToUserAgent("ft/S3CryptoV1n");
4949
}
5050

51+
S3EncryptionClientBase::S3EncryptionClientBase(const std::shared_ptr<EncryptionMaterials>& encryptionMaterials,
52+
const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
53+
const std::function<Aws::UniquePtr<S3::S3Client> ()>& s3ClientFactory) :
54+
m_s3Client(s3ClientFactory()), m_cryptoModuleFactory(), m_encryptionMaterials(encryptionMaterials), m_cryptoConfig(cryptoConfig)
55+
{
56+
m_s3Client->AppendToUserAgent("ft/S3CryptoV1n");
57+
}
58+
5159
S3EncryptionPutObjectOutcome S3EncryptionClientBase::PutObject(const Aws::S3::Model::PutObjectRequest& request, const Aws::Map<Aws::String, Aws::String>& contextMap) const
5260
{
5361
auto module = m_cryptoModuleFactory.FetchCryptoModule(m_encryptionMaterials, m_cryptoConfig);

0 commit comments

Comments
 (0)