AWS SDK for C++

AWS SDK for C++ Version 1.11.719

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 */
85 //= ../specification/s3-encryption/client.md#required-api-operations
86 //= type=implication
87 //# - PutObject MUST be implemented by the S3EC.
88 //# - PutObject MUST encrypt its input data before it is uploaded to S3.
90
91 /*
92 * Function to get an object decrypted from S3.
93 *
94 * Range gets using this method are deprecated. Please see
95 * <https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html> for more information
96 */
97 //= ../specification/s3-encryption/client.md#required-api-operations
98 //= type=implication
99 //# - GetObject MUST be implemented by the S3EC.
100 //# - GetObject MUST decrypt data received from the S3 server and return it as plaintext.
102
103 /*
104 * Function to get an object decrypted from S3. Fails if stored Materials Description does not exactly match supplied contextMap
105 *
106 * Range gets using this method are deprecated. Please see
107 * <https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html> for more information
108 */
110
111 inline bool MultipartUploadSupported() const { return false; }
112
113 protected:
118 /*
119 * GetObject with optional contextMap.
120 * Fail if contextMap is supplied and does not exactly match stored Materials Description
121 */
123
124 /*
125 * Function to get the instruction file object of a encrypted object from S3. This instruction file object will be used to assist decryption.
126 */
128
131 std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials> m_encryptionMaterials;
134 };
135
139 class
140 AWS_DEPRECATED("This class is in the maintenance mode, no new updates will be released, use S3EncryptionClientV3. Please see https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html for more information.")
141 AWS_S3ENCRYPTION_API S3EncryptionClient : public S3EncryptionClientBase
142 {
143 public:
144 /*
145 * Initialize the S3 Encryption Client with encryption materials, crypto configuration, and a client configuration. If no client configuration is supplied,
146 * the default client configuration will be used.
147 */
148 S3EncryptionClient(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
150 : S3EncryptionClientBase(encryptionMaterials, cryptoConfig, clientConfiguration)
151 {}
152
153 /*
154 * Initialize the S3 Encryption Client with encryption materials, crypto configuration, AWS credentials and a client configuration. If no client configuration is supplied,
155 * the default client configuration will be used.
156 */
157 S3EncryptionClient(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
159 : S3EncryptionClientBase(encryptionMaterials, cryptoConfig, credentials, clientConfiguration)
160 {}
161
162 /*
163 * Initialize the S3 Encryption Client with encryption materials, crypto configuration, AWS credentials provider and a client configuration. If no client configuration is supplied,
164 * the default client configuration will be used.
165 */
166 S3EncryptionClient(const std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials>& encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration& cryptoConfig,
167 const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration())
168 : S3EncryptionClientBase(encryptionMaterials, cryptoConfig, credentialsProvider, clientConfiguration)
169 {}
170
171 /*
172 * Function to put an object encrypted to S3.
173 */
175 };
176
184 class
185 AWS_DEPRECATED("This class is in the maintenance mode, no new updates will be released, use S3EncryptionClientV3. Please see https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html for more information.")
186 AWS_S3ENCRYPTION_API S3EncryptionClientV2 : public S3EncryptionClientBase
187 {
188 public:
189 /*
190 * Initialize the S3 Encryption Client V2 with crypto configuration v2, and a client configuration. If no client configuration is supplied,
191 * the default client configuration will be used.
192 */
195 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), clientConfig)
196 {
197 Init(cryptoConfig);
198 }
199
200
201 /*
202 * Initialize the S3 Encryption Client V2 with crypto configuration v2, AWS credentials and a client configuration. If no client configuration is supplied,
203 * the default client configuration will be used.
204 */
207 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), credentials, clientConfig)
208 {
209 Init(cryptoConfig);
210 }
211
212 /*
213 * Initialize the S3 Encryption Client V2 with crypto configuration v2, AWS credentials provider and a client configuration. If no client configuration is supplied,
214 * the default client configuration will be used.
215 */
216 S3EncryptionClientV2(const Aws::S3Encryption::CryptoConfigurationV2& cryptoConfig, const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider,
218 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), credentialsProvider, clientConfig)
219 {
220 Init(cryptoConfig);
221 }
222
223 /*
224 * Initialize the S3 Encryption Client V2 with crypto configuration v2, and a s3 client factory.
225 * The factory will be used to create the underlying S3 Client.
226 */
228 const std::function<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory)
229 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), s3ClientFactory)
230 {
231 Init(cryptoConfig);
232 }
233
236
237 private:
238 void Init(const Aws::S3Encryption::CryptoConfigurationV2& cryptoConfig);
239 };
240
241 class AWS_S3ENCRYPTION_API S3EncryptionClientV3 : public S3EncryptionClientBase
242 {
243 public:
244 /*
245 * Initialize the S3 Encryption Client V3 with crypto configuration v3, and a client configuration. If no client configuration is supplied,
246 * the default client configuration will be used.
247 */
248 //= ../specification/s3-encryption/client.md#cryptographic-materials
249 //= type=implication
250 //# The S3EC MAY accept key material directly.
251
252 //= ../specification/s3-encryption/client.md#inherited-sdk-configuration
253 //= type=implication
254 //# The S3EC MAY support directly configuring the wrapped SDK clients through its initialization.
255 //# For example, the S3EC MAY accept a credentials provider instance during its initialization.
256 //# If the S3EC accepts SDK client configuration, the configuration MUST be applied to all wrapped S3 clients.
257 // There's only one client, so it's safe to say "all"
260 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), clientConfig)
261 {
262 Init(cryptoConfig);
263 }
264
265
266 /*
267 * Initialize the S3 Encryption Client V3 with crypto configuration v3, AWS credentials and a client configuration. If no client configuration is supplied,
268 * the default client configuration will be used.
269 */
272 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), credentials, clientConfig)
273 {
274 Init(cryptoConfig);
275 }
276
277 /*
278 * Initialize the S3 Encryption Client V3 with crypto configuration v3, AWS credentials provider and a client configuration. If no client configuration is supplied,
279 * the default client configuration will be used.
280 */
281 S3EncryptionClientV3(const Aws::S3Encryption::CryptoConfigurationV3& cryptoConfig, const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider,
283 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), credentialsProvider, clientConfig)
284 {
285 Init(cryptoConfig);
286 }
287
288 /*
289 * Initialize the S3 Encryption Client V3 with crypto configuration v3, and a s3 client factory.
290 * The factory will be used to create the underlying S3 Client.
291 */
292 //= ../specification/s3-encryption/client.md#wrapped-s3-client-s
293 //= type=implication
294 //# The S3EC MUST support the option to provide an SDK S3 client instance during its initialization.
295 //# The S3EC MUST NOT support use of S3EC as the provided S3 client during its initialization; it MUST throw an exception in this case.
296 // The S3EncryptionClientV3 is not an S3Client, so this can't happen.
298 const std::function<Aws::UniquePtr<Aws::S3::S3Client> ()>& s3ClientFactory)
299 : S3EncryptionClientBase(cryptoConfig.GetEncryptionMaterials(), CryptoConfiguration(), s3ClientFactory)
300 {
301 Init(cryptoConfig);
302 }
303
306
307 private:
308 void Init(const Aws::S3Encryption::CryptoConfigurationV3& cryptoConfig);
309 };
310 }
311}
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
S3EncryptionGetObjectOutcome GetObjectInner(const Aws::S3::Model::GetObjectRequest &request, const Aws::Map< Aws::String, Aws::String > *contextMap) const
bool ValidateStorageMethod(StorageMethod s)
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
bool ValidateCommitmentPolicy(CommitmentPolicy s)
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
bool ValidateSecurityProfile(SecurityProfile s)
S3EncryptionClientBase(const std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > &encryptionMaterials, const Aws::S3Encryption::CryptoConfiguration &cryptoConfig, const Aws::Client::ClientConfiguration &clientConfiguration=Aws::Client::ClientConfiguration())
S3EncryptionGetObjectOutcome GetObject(const Aws::S3::Model::GetObjectRequest &request, const Aws::Map< Aws::String, Aws::String > &contextMap) const
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())
S3EncryptionClientV3(const Aws::S3Encryption::CryptoConfigurationV3 &cryptoConfig, const Aws::Auth::AWSCredentials &credentials, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
S3EncryptionClientV3 & operator=(const S3EncryptionClientV3 &)=delete
S3EncryptionClientV3(const S3EncryptionClientV3 &)=delete
S3EncryptionClientV3(const Aws::S3Encryption::CryptoConfigurationV3 &cryptoConfig, const std::function< Aws::UniquePtr< Aws::S3::S3Client >()> &s3ClientFactory)
S3EncryptionClientV3(const Aws::S3Encryption::CryptoConfigurationV3 &cryptoConfig, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
S3EncryptionClientV3(const Aws::S3Encryption::CryptoConfigurationV3 &cryptoConfig, const std::shared_ptr< Aws::Auth::AWSCredentialsProvider > &credentialsProvider, 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::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
std::unique_ptr< T, D > UniquePtr
S3EncryptionErrors(const Aws::S3::S3Errors &error)
S3EncryptionErrors(const Aws::Utils::Crypto::CryptoErrors &error)
Aws::Utils::Crypto::CryptoErrors cryptoError