AWS SDK for C++

AWS SDK for C++ Version 1.11.606

Loading...
Searching...
No Matches
S3EncryptionClient.h
1
5#pragma once
6
7#include <aws/s3-encryption/s3Encryption_EXPORTS.h>
8#include <aws/s3/S3Client.h>
9#include <aws/s3-encryption/modules/CryptoModuleFactory.h>
10#include <aws/core/client/AWSError.h>
11
12namespace Aws
13{
14 namespace S3Encryption
15 {
16 struct AWS_S3ENCRYPTION_API S3EncryptionErrors
17 {
18 S3EncryptionErrors() = default;
19 S3EncryptionErrors(const Aws::Utils::Crypto::CryptoErrors& error) :cryptoError(error), m_isS3Error(false) {}
20 S3EncryptionErrors(const Aws::S3::S3Errors& error) :s3Error(error), m_isS3Error(true) {}
21
22 inline bool IsS3Error() const { return m_isS3Error; }
23 inline bool IsCryptoError() const { return !m_isS3Error; }
24
25 union {
28 };
29 private:
30 bool m_isS3Error;
31 };
32
33 template<typename ERROR_TYPE>
35 {
37 s3EncryptionError.SetResponseCode(error.GetResponseCode());
38 s3EncryptionError.SetResponseHeaders(error.GetResponseHeaders());
39 return s3EncryptionError;
40 }
41
44
45 class AWS_S3ENCRYPTION_API S3EncryptionClientBase
46 {
47 public:
48 /*
49 * Initialize the S3EncryptionClientBase with encryption materials, crypto configuration, and a client configuration. If no client configuration is supplied,
50 * the default client configuration will be used.
51 */
52 S3EncryptionClientBase(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
54
55 /*
56 * Initialize the S3EncryptionClientBase with encryption materials, crypto configuration, AWS credentials and a client configuration. If no client configuration is supplied,
57 * the default client configuration will be used.
58 */
59 S3EncryptionClientBase(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
61
62 /*
63 * Initialize the S3EncryptionClientBase with encryption materials, crypto configuration, AWS credentials provider and a client configuration. If no client configuration is supplied,
64 * the default client configuration will be used.
65 */
66 S3EncryptionClientBase(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
67 const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
68
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,
75 const std::function<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory);
76
79
80 /*
81 * Function to put an object encrypted to S3.
82 * For KMSWithContext encryption materials, you can provide a context map as the KMS context for encrypting the CEK.
83 * For other encryption materials, this context map must be an empty map.
84 */
86
87 /*
88 * Function to get an object decrypted from S3.
89 *
90 * Range gets using this method are deprecated. Please see
91 * <https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html> for more information
92 */
94
95 inline bool MultipartUploadSupported() const { return false; }
96
97 protected:
98 /*
99 * Function to get the instruction file object of a encrypted object from S3. This instruction file object will be used to assist decryption.
100 */
102
105 std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials> m_encryptionMaterials;
107 };
108
112 class
113 AWS_DEPRECATED("This class is in the maintenance mode, no new updates will be released, use S3EncryptionClientV2. Please see https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html for more information.")
114 AWS_S3ENCRYPTION_API S3EncryptionClient : public S3EncryptionClientBase
115 {
116 public:
117 /*
118 * Initialize the S3 Encryption Client with encryption materials, crypto configuration, and a client configuration. If no client configuration is supplied,
119 * the default client configuration will be used.
120 */
121 S3EncryptionClient(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
123 : S3EncryptionClientBase(encryptionMaterials, cryptoConfig, clientConfiguration)
124 {}
125
126 /*
127 * Initialize the S3 Encryption Client with encryption materials, crypto configuration, AWS credentials and a client configuration. If no client configuration is supplied,
128 * the default client configuration will be used.
129 */
130 S3EncryptionClient(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
132 : S3EncryptionClientBase(encryptionMaterials, cryptoConfig, credentials, clientConfiguration)
133 {}
134
135 /*
136 * Initialize the S3 Encryption Client with encryption materials, crypto configuration, AWS credentials provider and a client configuration. If no client configuration is supplied,
137 * the default client configuration will be used.
138 */
139 S3EncryptionClient(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
140 const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration())
141 : S3EncryptionClientBase(encryptionMaterials, cryptoConfig, credentialsProvider, clientConfiguration)
142 {}
143
144 /*
145 * Function to put an object encrypted to S3.
146 */
148 };
149
154 class AWS_S3ENCRYPTION_API S3EncryptionClientV2 : public S3EncryptionClientBase
155 {
156 public:
157 /*
158 * Initialize the S3 Encryption Client V2 with crypto configuration v2, and a client configuration. If no client configuration is supplied,
159 * the default client configuration will be used.
160 */
163 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), clientConfig)
164 {
165 Init(cryptoConfig);
166 }
167
168
169 /*
170 * Initialize the S3 Encryption Client V2 with crypto configuration v2, AWS credentials and a client configuration. If no client configuration is supplied,
171 * the default client configuration will be used.
172 */
175 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), credentials, clientConfig)
176 {
177 Init(cryptoConfig);
178 }
179
180 /*
181 * Initialize the S3 Encryption Client V2 with crypto configuration v2, AWS credentials provider and a client configuration. If no client configuration is supplied,
182 * the default client configuration will be used.
183 */
184 S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2& cryptoConfig, const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider,
186 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), credentialsProvider, clientConfig)
187 {
188 Init(cryptoConfig);
189 }
190
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 */
196 const std::function<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory)
197 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), s3ClientFactory)
198 {
199 Init(cryptoConfig);
200 }
201
204
205 private:
206 void Init(const Aws::S3Encryption::CryptoConfigurationV2& cryptoConfig);
207 };
208 }
209}
const Aws::Http::HeaderValueCollection & GetResponseHeaders() const
const Aws::String & GetMessage() const
bool ShouldRetry() const
void SetResponseHeaders(const Aws::Http::HeaderValueCollection &headers)
const Aws::String & GetExceptionName() const
void SetResponseCode(Aws::Http::HttpResponseCode responseCode)
Aws::Http::HttpResponseCode GetResponseCode() const
const ERROR_TYPE GetErrorType() const
S3EncryptionClientBase(const std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > &encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration &cryptoConfig, const std::function< Aws::UniquePtr< Aws::S3::S3Client >()> &s3ClientFactory)
std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > m_encryptionMaterials
Aws::S3Encryption::Modules::CryptoModuleFactory m_cryptoModuleFactory
S3EncryptionClientBase(const S3EncryptionClientBase &)=delete
S3EncryptionPutObjectOutcome PutObject(const Aws::S3::Model::PutObjectRequest &request, const Aws::Map< Aws::String, Aws::String > &contextMap) const
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())
Aws::S3::Model::GetObjectOutcome GetInstructionFileObject(const Aws::S3::Model::GetObjectRequest &originalGetRequest) const
S3EncryptionGetObjectOutcome GetObject(const Aws::S3::Model::GetObjectRequest &request) const
Aws::UniquePtr< Aws::S3::S3Client > m_s3Client
Aws::S3Encryption::CryptoConfiguration m_cryptoConfig
S3EncryptionClientBase(const std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > &encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration &cryptoConfig, const Aws::Auth::AWSCredentials &credentials, const Aws::Client::ClientConfiguration &clientConfiguration=Aws::Client::ClientConfiguration())
S3EncryptionClientBase & operator=(const S3EncryptionClientBase &)=delete
S3EncryptionClientBase(const std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > &encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration &cryptoConfig, const Aws::Client::ClientConfiguration &clientConfiguration=Aws::Client::ClientConfiguration())
S3EncryptionPutObjectOutcome PutObject(const Aws::S3::Model::PutObjectRequest &request) const
S3EncryptionClient(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())
S3EncryptionClient(const std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > &encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration &cryptoConfig, const Aws::Client::ClientConfiguration &clientConfiguration=Aws::Client::ClientConfiguration())
S3EncryptionClient(const std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > &encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration &cryptoConfig, const Aws::Auth::AWSCredentials &credentials, const Aws::Client::ClientConfiguration &clientConfiguration=Aws::Client::ClientConfiguration())
S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2 &cryptoConfig, const std::function< Aws::UniquePtr< Aws::S3::S3Client >()> &s3ClientFactory)
S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2 &cryptoConfig, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
S3EncryptionClientV2(const S3EncryptionClientV2 &)=delete
S3EncryptionClientV2 & operator=(const S3EncryptionClientV2 &)=delete
S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2 &cryptoConfig, const std::shared_ptr< Aws::Auth::AWSCredentialsProvider > &credentialsProvider, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2 &cryptoConfig, const Aws::Auth::AWSCredentials &credentials, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
Aws::Client::AWSError< S3EncryptionErrors > BuildS3EncryptionError(const Aws::Client::AWSError< ERROR_TYPE > &error)
Aws::Utils::Outcome< Aws::S3::Model::PutObjectResult, Aws::Client::AWSError< S3EncryptionErrors > > S3EncryptionPutObjectOutcome
Aws::Utils::Outcome< Aws::S3::Model::GetObjectResult, Aws::Client::AWSError< S3EncryptionErrors > > S3EncryptionGetObjectOutcome
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
std::unique_ptr< T, D > UniquePtr
S3EncryptionErrors(const Aws::S3::S3Errors &error)
S3EncryptionErrors(const Aws::Utils::Crypto::CryptoErrors &error)
Aws::Utils::Crypto::CryptoErrors cryptoError