Skip to content

Add constructor with s3Client factory to s3-encryption #3392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ namespace Aws
S3EncryptionClientBase(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& 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<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials,
const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
const std::function<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory);

S3EncryptionClientBase(const S3EncryptionClientBase&) = delete;
S3EncryptionClientBase& operator=(const S3EncryptionClientBase&) = delete;

Expand Down Expand Up @@ -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<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory)
: S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), s3ClientFactory)
{
Init(cryptoConfig);
}

S3EncryptionClientV2(const S3EncryptionClientV2&) = delete;
S3EncryptionClientV2& operator=(const S3EncryptionClientV2&) = delete;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ namespace Aws
m_s3Client->AppendToUserAgent("ft/S3CryptoV1n");
}

S3EncryptionClientBase::S3EncryptionClientBase(const std::shared_ptr<EncryptionMaterials>& encryptionMaterials,
const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
const std::function<Aws::UniquePtr<S3::S3Client> ()>& 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<Aws::String, Aws::String>& contextMap) const
{
auto module = m_cryptoModuleFactory.FetchCryptoModule(m_encryptionMaterials, m_cryptoConfig);
Expand Down
Loading