diff options
author | dakovalkov <dakovalkov@yandex-team.com> | 2023-12-03 13:33:55 +0300 |
---|---|---|
committer | dakovalkov <dakovalkov@yandex-team.com> | 2023-12-03 14:04:39 +0300 |
commit | 2a718325637e5302334b6d0a6430f63168f8dbb3 (patch) | |
tree | 64be81080b7df9ec1d86d053a0c394ae53fcf1fe /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include | |
parent | e0d94a470142d95c3007e9c5d80380994940664a (diff) | |
download | ydb-2a718325637e5302334b6d0a6430f63168f8dbb3.tar.gz |
Update contrib/libs/aws-sdk-cpp to 1.11.37
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include')
97 files changed, 4803 insertions, 1117 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceRequest.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceRequest.h index 1fc7c0e7e0..3578307022 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceRequest.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceRequest.h @@ -7,13 +7,16 @@ #include <aws/core/Core_EXPORTS.h> -#include <aws/core/utils/memory/stl/AWSString.h> -#include <aws/core/utils/UnreferencedParam.h> -#include <aws/core/http/HttpTypes.h> +#include <aws/core/client/RequestCompression.h> +#include <aws/core/auth/AWSAuthSigner.h> +#include <aws/core/client/CoreErrors.h> +#include <aws/core/endpoint/EndpointParameter.h> #include <aws/core/http/HttpRequest.h> +#include <aws/core/http/HttpTypes.h> +#include <aws/core/utils/UnreferencedParam.h> #include <aws/core/utils/memory/stl/AWSStreamFwd.h> +#include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/stream/ResponseStream.h> -#include <aws/core/auth/AWSAuthSigner.h> namespace Aws { @@ -51,12 +54,21 @@ namespace Aws */ virtual Aws::Http::HeaderValueCollection GetHeaders() const = 0; /** + * Get the additional user-set custom headers for the request + */ + virtual const Aws::Http::HeaderValueCollection& GetAdditionalCustomHeaders() const; + /** + * Set an additional custom header value under a key. This value will overwrite any previously set or regular header. + */ + virtual void SetAdditionalCustomHeaderValue(const Aws::String& headerName, const Aws::String& headerValue); + + /** * Do nothing virtual, override this to add query strings to the request */ virtual void AddQueryStringParameters(Aws::Http::URI& uri) const { AWS_UNREFERENCED_PARAM(uri); } /** - * Put the request to a url for later presigning. This will push the body to the url and + * Put the request to a url for later presigning. This will push the body to the url and * then adds the existing query string parameters as normal. */ virtual void PutToPresignedUrl(Aws::Http::URI& uri) const { DumpBodyToUrl(uri); AddQueryStringParameters(uri); } @@ -76,6 +88,15 @@ namespace Aws virtual bool SignBody() const { return true; } /** + * Defaults to false, if a derived class returns true it indicates that the body has an embedded error. + */ + virtual bool HasEmbeddedError(Aws::IOStream& body, const Aws::Http::HeaderValueCollection& header) const { + (void) body; + (void) header; + return false; + } + + /** * Defaults to false, if this is set to true, it supports chunked transfer encoding. */ virtual bool IsChunked() const { return false; } @@ -150,15 +171,28 @@ namespace Aws */ inline virtual bool ShouldComputeContentMd5() const { return false; } + inline virtual bool ShouldValidateResponseChecksum() const { return false; } + + inline virtual Aws::Vector<Aws::String> GetResponseChecksumAlgorithmNames() const { return {}; } + + inline virtual Aws::String GetChecksumAlgorithmName() const { return {}; } + virtual const char* GetServiceRequestName() const = 0; + using EndpointParameters = Aws::Vector<Aws::Endpoint::EndpointParameter>; + virtual EndpointParameters GetEndpointContextParams() const; + + virtual Aws::Client::CompressionAlgorithm + GetSelectedCompressionAlgorithm(Aws::Client::RequestCompressionConfig) const { return Aws::Client::CompressionAlgorithm::NONE; } + protected: /** - * Default does nothing. Override this to convert what would otherwise be the payload of the + * Default does nothing. Override this to convert what would otherwise be the payload of the * request to a query string format. */ virtual void DumpBodyToUrl(Aws::Http::URI& uri) const { AWS_UNREFERENCED_PARAM(uri); } + Aws::Http::HeaderValueCollection m_additionalCustomHeaders; private: Aws::IOStreamFactory m_responseStreamFactory; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceResult.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceResult.h index cde25d80f6..37538accb7 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceResult.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/AmazonWebServiceResult.h @@ -57,7 +57,7 @@ namespace Aws /** * Get the payload from the response and take ownership of it. */ - inline PAYLOAD_TYPE TakeOwnershipOfPayload() { return std::move(m_payload); } + inline PAYLOAD_TYPE&& TakeOwnershipOfPayload() { return std::move(m_payload); } /** * Get the headers from the response */ diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Aws.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Aws.h index 7c2d7af53f..03f965a3e6 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Aws.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Aws.h @@ -6,11 +6,14 @@ #include <aws/core/utils/logging/LogLevel.h> #include <aws/core/utils/logging/LogSystemInterface.h> +#include <aws/core/utils/logging/CRTLogSystem.h> #include <aws/core/utils/memory/MemorySystemInterface.h> #include <aws/core/utils/crypto/Factories.h> #include <aws/core/http/HttpClientFactory.h> #include <aws/core/monitoring/MonitoringManager.h> #include <aws/core/Core_EXPORTS.h> +#include <aws/crt/io/Bootstrap.h> +#include <aws/crt/io/TlsOptions.h> namespace Aws { @@ -35,10 +38,16 @@ namespace Aws const char* defaultLogPrefix; /** - * Defaults to empty, if logLevel has been set and this field is empty, then the default log interface will be used. + * Defaults to empty, if logLevel has been set and this field is empty, then the default log system will be used. * otherwise, we will call this closure to create a logger */ std::function<std::shared_ptr<Aws::Utils::Logging::LogSystemInterface>()> logger_create_fn; + + /** + * Defaults to empty, if logLevel has been set and this field is empty, then the default CRT log system will be used. + * The default CRT log system will redirect all logs from common runtime libraries (CRT) to C++ SDK with the same log level and formatting. + */ + std::function<std::shared_ptr<Aws::Utils::Logging::CRTLogSystemInterface>()> crt_logger_create_fn; }; /** @@ -58,11 +67,20 @@ namespace Aws }; /** + * SDK wide options for I/O: client bootstrap and TLS connection options + */ + struct IoOptions + { + std::function<std::shared_ptr<Aws::Crt::Io::ClientBootstrap>()> clientBootstrap_create_fn; + std::function<std::shared_ptr<Aws::Crt::Io::TlsConnectionOptions>()> tlsConnectionOptions_create_fn; + }; + + /** * SDK wide options for http */ struct HttpOptions { - HttpOptions() : initAndCleanupCurl(true), installSigPipeHandler(false) + HttpOptions() : initAndCleanupCurl(true), installSigPipeHandler(false), compliantRfc3986Encoding(false) { } /** @@ -82,6 +100,10 @@ namespace Aws * NOTE: CURLOPT_NOSIGNAL is already being set. */ bool installSigPipeHandler; + /** + * Disable legacy URL encoding that leaves `$&,:@=` unescaped for legacy purposes. + */ + bool compliantRfc3986Encoding; }; /** @@ -194,6 +216,10 @@ namespace Aws struct SDKOptions { /** + * SDK wide options for I/O: client bootstrap and TLS connection options + */ + IoOptions ioOptions; + /** * SDK wide options for logging */ LoggingOptions loggingOptions; @@ -260,7 +286,10 @@ namespace Aws /** * Shutdown SDK wide state for the SDK. This method must be called when you are finished using the SDK. - * Do not call any other SDK methods after calling ShutdownAPI. + * Notes: + * 1) Please call this from the same thread from which InitAPI() has been called (use a dedicated thread + * if necessary). This avoids problems in initializing the dependent Common RunTime C libraries. + * 2) Do not call any other SDK methods after calling ShutdownAPI. */ AWS_CORE_API void ShutdownAPI(const SDKOptions& options); } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Core_EXPORTS.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Core_EXPORTS.h index 12e9dfc9be..1d3e312a60 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Core_EXPORTS.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Core_EXPORTS.h @@ -21,8 +21,14 @@ #else // USE_IMPORT_EXPORT #define AWS_CORE_API #endif // USE_IMPORT_EXPORT + #define AWS_CORE_LOCAL #else // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) #define AWS_CORE_API + #if __GNUC__ >= 4 + #define AWS_CORE_LOCAL __attribute__((visibility("hidden"))) + #else + #define AWS_CORE_LOCAL + #endif #endif // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) #ifdef _MSC_VER diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Globals.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Globals.h index cebe4891b7..08dfafce09 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Globals.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Globals.h @@ -9,6 +9,54 @@ namespace Aws { + namespace Crt + { + class ApiHandle; + + namespace Io + { + class ClientBootstrap; + class TlsConnectionOptions; + + } + } + + /** + * Like we need to call InitAPI() to initialize aws-sdk-cpp, we need ApiHandle to initialize aws-crt-cpp, which is a wrapper of a collection of common runtime libraries. + * We will wrap the memory management system and pass it to common runtime libraries via ApiHandle. + */ + AWS_CORE_API Aws::Crt::ApiHandle* GetApiHandle(); + + /** + * Set the default ClientBootStrap for AWS common runtime libraries in the global scope. + */ + AWS_CORE_API void SetDefaultClientBootstrap(const std::shared_ptr<Aws::Crt::Io::ClientBootstrap>& clientBootstrap); + + /** + * Get the default ClientBootStrap for AWS common runtime libraries in the global scope. + */ + AWS_CORE_API Aws::Crt::Io::ClientBootstrap* GetDefaultClientBootstrap(); + + /** + * Set the default TlsConnectionOptions for AWS common runtime libraries in the global scope. + */ + AWS_CORE_API void SetDefaultTlsConnectionOptions(const std::shared_ptr<Aws::Crt::Io::TlsConnectionOptions>& tlsConnectionOptions); + + /** + * Get the default TlsConnectionOptions for AWS common runtime libraries in the global scope. + */ + AWS_CORE_API Aws::Crt::Io::TlsConnectionOptions* GetDefaultTlsConnectionOptions(); + + /** + * Initialize ApiHandle in aws-crt-cpp. + */ + void InitializeCrt(); + + /** + * Clean up ApiHandle in aws-crt-cpp. + */ + void CleanupCrt(); + namespace Utils { class EnumParseOverflowContainer; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Region.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Region.h index a728c829ed..9bfeba1ad3 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Region.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/Region.h @@ -20,33 +20,42 @@ namespace Aws // You can specify this region to corresponding environment variable, config file item and in your code. // For services without global region, the request will be directed to us-east-1 static const char AWS_GLOBAL[] = "aws-global"; - static const char US_EAST_1[] = "us-east-1"; - static const char US_EAST_2[] = "us-east-2"; - static const char US_WEST_1[] = "us-west-1"; - static const char US_WEST_2[] = "us-west-2"; - static const char AF_SOUTH_1[] = "af-south-1"; - static const char EU_WEST_1[] = "eu-west-1"; - static const char EU_WEST_2[] = "eu-west-2"; - static const char EU_WEST_3[] = "eu-west-3"; - static const char EU_CENTRAL_1[] = "eu-central-1"; - static const char EU_NORTH_1[] = "eu-north-1"; - static const char AP_EAST_1[] = "ap-east-1"; - static const char AP_SOUTH_1[] = "ap-south-1"; - static const char AP_SOUTHEAST_1[] = "ap-southeast-1"; - static const char AP_SOUTHEAST_2[] = "ap-southeast-2"; - static const char AP_NORTHEAST_1[] = "ap-northeast-1"; - static const char AP_NORTHEAST_2[] = "ap-northeast-2"; - static const char AP_NORTHEAST_3[] = "ap-northeast-3"; - static const char SA_EAST_1[] = "sa-east-1"; - static const char CA_CENTRAL_1[] = "ca-central-1"; - static const char CN_NORTH_1[] = "cn-north-1"; - static const char CN_NORTHWEST_1[] = "cn-northwest-1"; - static const char ME_SOUTH_1[] = "me-south-1"; - static const char US_GOV_WEST_1[] = "us-gov-west-1"; - static const char US_GOV_EAST_1[] = "us-gov-east-1"; + static const char US_EAST_1[] = "us-east-1"; // US East (N. Virginia) + static const char US_EAST_2[] = "us-east-2"; // US East (Ohio) + static const char US_WEST_1[] = "us-west-1"; // US West (N. California) + static const char US_WEST_2[] = "us-west-2"; // US West (Oregon) + static const char EU_WEST_1[] = "eu-west-1"; // EU (Ireland) + static const char EU_WEST_2[] = "eu-west-2"; // EU (London) + static const char EU_WEST_3[] = "eu-west-3"; // EU (Paris) + static const char EU_CENTRAL_1[] = "eu-central-1"; // "EU (Frankfurt) + static const char EU_NORTH_1[] = "eu-north-1"; // EU (Stockholm) + static const char EU_SOUTH_1[] = "eu-south-1"; // EU (Milan) + static const char AP_EAST_1[] = "ap-east-1"; // Asia Pacific (Hong Kong) + static const char AP_SOUTH_1[] = "ap-south-1"; // Asia Pacific (Mumbai) + static const char AP_SOUTHEAST_1[] = "ap-southeast-1"; // Asia Pacific (Singapore) + static const char AP_SOUTHEAST_2[] = "ap-southeast-2"; // Asia Pacific (Sydney) + static const char AP_SOUTHEAST_3[] = "ap-southeast-3"; // Asia Pacific (Jakarta) + static const char AP_NORTHEAST_1[] = "ap-northeast-1"; // Asia Pacific (Tokyo) + static const char AP_NORTHEAST_2[] = "ap-northeast-2"; // Asia Pacific (Seoul) + static const char AP_NORTHEAST_3[] = "ap-northeast-3"; // Asia Pacific (Osaka) + static const char SA_EAST_1[] = "sa-east-1"; // South America (Sao Paulo + static const char CN_NORTH_1[] = "cn-north-1"; // China (Beijing) + static const char CN_NORTHWEST_1[] = "cn-northwest-1"; // China (Ningxia) + static const char CA_CENTRAL_1[] = "ca-central-1"; // Canada (Central) + static const char ME_SOUTH_1[] = "me-south-1"; // Middle East (Bahrain) + static const char ME_CENTRAL_1[] = "me-central-1"; // Middle East (UEA) + static const char AF_SOUTH_1[] = "af-south-1"; // Africa (Cape Town) + static const char US_GOV_WEST_1[] = "us-gov-west-1"; // AWS GovCloud (US-West) + static const char US_GOV_EAST_1[] = "us-gov-east-1"; // AWS GovCloud (US-East) + static const char US_ISO_EAST_1[] = "us-iso-east-1"; // US ISO East + static const char US_ISOB_EAST_1[] = "us-isob-east-1"; // US ISOB East (Ohio) + static const char US_ISO_WEST_1[] = "us-iso-west-1"; // US ISO West // If a pseudo region, for example, aws-global or us-east-1-fips is provided, it should be converted to the region name used for signing. Aws::String AWS_CORE_API ComputeSignerRegion(const Aws::String& region); + + // A FIPs region starts with "fips-" or ends with "-fips". + bool AWS_CORE_API IsFipsRegion(const Aws::String& region); } } // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/VersionConfig.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/VersionConfig.h index fd965734a6..0dedf23c9a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/VersionConfig.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/VersionConfig.h @@ -2,5 +2,9 @@ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ +#pragma once -#define AWS_SDK_VERSION_STRING "1.8.186" +#define AWS_SDK_VERSION_STRING "1.11.37" +#define AWS_SDK_VERSION_MAJOR 1 +#define AWS_SDK_VERSION_MINOR 11 +#define AWS_SDK_VERSION_PATCH 37 diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h index 8061ee1e25..0c4a26dbd3 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSigner.h @@ -5,421 +5,11 @@ #pragma once -#include <aws/core/Core_EXPORTS.h> +#include <aws/core/auth/signer/AWSAuthSignerBase.h> +#include <aws/core/auth/signer/AWSAuthSignerCommon.h> -#include <aws/core/Region.h> -#include <aws/core/utils/memory/AWSMemory.h> -#include <aws/core/utils/memory/stl/AWSSet.h> -#include <aws/core/utils/DateTime.h> -#include <aws/core/utils/Array.h> -#include <aws/core/utils/threading/ReaderWriterLock.h> -#include <aws/core/utils/crypto/Sha256.h> -#include <aws/core/utils/crypto/Sha256HMAC.h> - -#include <memory> -#include <atomic> -#include <chrono> - -namespace Aws -{ - namespace Http - { - class HttpClientFactory; - class HttpRequest; - } // namespace Http - - namespace Utils - { - namespace Event - { - class Message; - } - } // namespace Utils - - namespace Auth - { - class AWSCredentials; - class AWSCredentialsProvider; - AWS_CORE_API extern const char SIGV4_SIGNER[]; - AWS_CORE_API extern const char EVENTSTREAM_SIGV4_SIGNER[]; - AWS_CORE_API extern const char SIGNATURE[]; - AWS_CORE_API extern const char NULL_SIGNER[]; - } // namespace Auth - - namespace Client - { - struct ClientConfiguration; - - /** - * Auth Signer interface. Takes a generic AWS request and applies crypto tamper resistent signatures on the request. - */ - class AWS_CORE_API AWSAuthSigner - { - public: - AWSAuthSigner() : m_clockSkew() { m_clockSkew.store(std::chrono::milliseconds(0L)); } - virtual ~AWSAuthSigner() = default; - - /** - * Signs the request itself (usually by adding a signature header) based on info in the request and uri. - */ - virtual bool SignRequest(Aws::Http::HttpRequest& request) const = 0; - - /** - * Signs the request itself (usually by adding a signature header) based on info in the request and uri. - * If signBody is false and https is being used then the body of the payload will not be signed. - * The default virtual function, just calls SignRequest. - */ - virtual bool SignRequest(Aws::Http::HttpRequest& request, bool signBody) const - { - AWS_UNREFERENCED_PARAM(signBody); - return SignRequest(request); - } - - /** - * Signs the request itself (usually by adding a signature header) based on info in the request and uri. - * If signBody is false and https is being used then the body of the payload will not be signed. - * The default virtual function, just calls SignRequest. - * Using m_region by default if parameter region is nullptr. - */ - virtual bool SignRequest(Aws::Http::HttpRequest& request, const char* region, bool signBody) const - { - AWS_UNREFERENCED_PARAM(signBody); - AWS_UNREFERENCED_PARAM(region); - return SignRequest(request); - } - - /** - * Signs the request itself (usually by adding a signature header) based on info in the request and uri. - * If signBody is false and https is being used then the body of the payload will not be signed. - * The default virtual function, just calls SignRequest. - * Using m_region by default if parameter region is nullptr. - * Using m_serviceName by default if parameter serviceName is nullptr. - */ - virtual bool SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool signBody) const - { - AWS_UNREFERENCED_PARAM(signBody); - AWS_UNREFERENCED_PARAM(region); - AWS_UNREFERENCED_PARAM(serviceName); - return SignRequest(request); - } - - /** - * Signs a single event message in an event stream. - * The input message buffer is copied and signed. The message's input buffer will be deallocated and a new - * buffer will be assigned. The new buffer encodes the original message with its headers as the payload of - * the new message. The signature of the original message will be added as a header to the new message. - * - * A Hex encoded signature of the previous event (or of the HTTP request headers in case of the first event) - * is provided as the 'priorSignature' parameter. 'priorSignature' will contain the value of the new - * signature after this call returns successfully. - * - * The function returns true if the message is successfully signed. - */ - virtual bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const { return false; } - - /** - * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. - * The URI can then be used in a normal HTTP call until expiration. - */ - virtual bool PresignRequest(Aws::Http::HttpRequest& request, long long expirationInSeconds) const = 0; - - /** - * Generates a signed Uri using the injected signer. for the supplied uri and http method and region. expirationInSeconds defaults - * to 0 which is the default 7 days. - * Using m_region by default if parameter region is nullptr. - */ - virtual bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, long long expirationInSeconds = 0) const = 0; - - /** - * Generates a signed Uri using the injected signer. for the supplied uri and http method, region, and service name. expirationInSeconds defaults - * to 0 which is the default 7 days. - * Using m_region by default if parameter region is nullptr. - * Using m_serviceName by default if parameter serviceName is nullptr. - */ - virtual bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, long long expirationInSeconds = 0) const = 0; - - /** - * Return the signer's name - */ - virtual const char* GetName() const = 0; - - /** - * This handles detection of clock skew between clients and the server and adjusts the clock so that the next request will not - * fail on the timestamp check. - */ - virtual void SetClockSkew(const std::chrono::milliseconds& clockSkew) { m_clockSkew = clockSkew; } - - /** - * Gets the timestamp being used by the signer. This may include a clock skew if a clock skew has been detected. - */ - virtual Aws::Utils::DateTime GetSigningTimestamp() const { return Aws::Utils::DateTime::Now() + GetClockSkewOffset(); } - - protected: - virtual std::chrono::milliseconds GetClockSkewOffset() const { return m_clockSkew.load(); } - - std::atomic<std::chrono::milliseconds> m_clockSkew; - }; - - /** - * AWS Auth v4 Signer implementation of the AWSAuthSigner interface. More information on AWS Auth v4 Can be found here: - * http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html - */ - class AWS_CORE_API AWSAuthV4Signer : public AWSAuthSigner - { - - public: - /** - * Even though different payload signing polices, HTTP will force payload signing to be on. - */ - enum class PayloadSigningPolicy - { - /** - * Sign the request based on the value returned by AmazonWebServiceRequest::SignBody() - */ - RequestDependent, - /** - * Always sign the body of the request. - */ - Always, - /** - * Never sign the body of the request - */ - Never - }; - /** - * credentialsProvider, source of AWS Credentials to sign requests with - * serviceName, canonical service name to sign with - * region, region string to use in signature - * signPayloads, if Always, the payload will have a sha256 computed on the body of the request. If this is set - * to Never, the sha256 will not be computed on the body. This is only useful for Amazon S3 over Https. If - * Https is not used then this flag will be ignored. If set to RequestDependent, compute or not is based on - * the value from AmazonWebServiceRequest::SignBody() - */ - AWSAuthV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& credentialsProvider, - const char* serviceName, const Aws::String& region, PayloadSigningPolicy signingPolicy = PayloadSigningPolicy::RequestDependent, - bool urlEscapePath = true); - - virtual ~AWSAuthV4Signer(); - - /** - * AWSAuthV4signer's implementation of virtual function from base class - * Return Auth Signer's name, here the value is specified in Aws::Auth::DEFAULT_AUTHV4_SIGNER. - */ - const char* GetName() const override { return Aws::Auth::SIGV4_SIGNER; } - - /** - * Signs the request itself based on info in the request and uri. - * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. - */ - bool SignRequest(Aws::Http::HttpRequest& request) const override - { - return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), true/*signBody*/); - } - - /** - * Signs the request itself based on info in the request and uri. - * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. If signBody is false - * and https is being used then the body of the payload will not be signed. - */ - bool SignRequest(Aws::Http::HttpRequest& request, bool signBody) const override - { - return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), signBody); - } - - /** - * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. If signBody is false - * and https is being used then the body of the payload will not be signed. - * Using m_region by default if parameter region is nullptr. - */ - bool SignRequest(Aws::Http::HttpRequest& request, const char* region, bool signBody) const override - { - return SignRequest(request, region, m_serviceName.c_str(), signBody); - } - - /** - * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. If signBody is false - * and https is being used then the body of the payload will not be signed. - * Using m_region by default if parameter region is nullptr. - */ - bool SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool signBody) const override; - - /** - * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. - * the region the signer was initialized with will be used for the signature. - * The URI can then be used in a normal HTTP call until expiration. - * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. - * expirationInSeconds defaults to 0 which provides a URI good for 7 days. - */ - bool PresignRequest(Aws::Http::HttpRequest& request, long long expirationInSeconds = 0) const override; - - /** - * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. - * The URI can then be used in a normal HTTP call until expiration. - * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. - * expirationInSeconds defaults to 0 which provides a URI good for 7 days. - * Using m_region by default if parameter region is nullptr. - */ - bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, long long expirationInSeconds = 0) const override; - - /** - * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. - * The URI can then be used in a normal HTTP call until expiration. - * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. - * expirationInSeconds defaults to 0 which provides a URI good for 7 days. - * Using m_region by default if parameter region is nullptr. - * Using m_serviceName by default if parameter serviceName is nullptr. - */ - bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, long long expirationInSeconds = 0) const override; - - Aws::String GetServiceName() const { return m_serviceName; } - Aws::String GetRegion() const { return m_region; } - Aws::String GenerateSignature(const Aws::Auth::AWSCredentials& credentials, - const Aws::String& stringToSign, const Aws::String& simpleDate) const; - bool ShouldSignHeader(const Aws::String& header) const; - - protected: - bool m_includeSha256HashHeader; - - private: - - Aws::String GenerateSignature(const Aws::Auth::AWSCredentials& credentials, - const Aws::String& stringToSign, const Aws::String& simpleDate, const Aws::String& region, - const Aws::String& serviceName) const; - - Aws::String GenerateSignature(const Aws::String& stringToSign, const Aws::Utils::ByteBuffer& key) const; - bool ServiceRequireUnsignedPayload(const Aws::String& serviceName) const; - Aws::String ComputePayloadHash(Aws::Http::HttpRequest&) const; - Aws::String GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, - const Aws::String& canonicalRequestHash, const Aws::String& region, - const Aws::String& serviceName) const; - Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, const Aws::String& simpleDate) const; - Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, - const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; - - - std::shared_ptr<Auth::AWSCredentialsProvider> m_credentialsProvider; - const Aws::String m_serviceName; - const Aws::String m_region; - Aws::UniquePtr<Aws::Utils::Crypto::Sha256> m_hash; - Aws::UniquePtr<Aws::Utils::Crypto::Sha256HMAC> m_HMAC; - - Aws::Set<Aws::String> m_unsignedHeaders; - - //these next four fields are ONLY for caching purposes and do not change - //the logical state of the signer. They are marked mutable so the - //interface can remain const. - mutable Aws::Utils::ByteBuffer m_partialSignature; - mutable Aws::String m_currentDateStr; - mutable Aws::String m_currentSecretKey; - mutable Utils::Threading::ReaderWriterLock m_partialSignatureLock; - PayloadSigningPolicy m_payloadSigningPolicy; - bool m_urlEscapePath; - }; - - class AWS_CORE_API AWSAuthEventStreamV4Signer : public AWSAuthSigner - { - public: - AWSAuthEventStreamV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& credentialsProvider, - const char* serviceName, const Aws::String& region); - - const char* GetName() const override { return Aws::Auth::EVENTSTREAM_SIGV4_SIGNER; } - - bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& priorSignature) const override; - - bool SignRequest(Aws::Http::HttpRequest& request) const override - { - return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), true); - } - - bool SignRequest(Aws::Http::HttpRequest& request, bool signBody) const override - { - return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), signBody); - } - - bool SignRequest(Aws::Http::HttpRequest& request, const char* region, bool signBody) const override - { - return SignRequest(request, region, m_serviceName.c_str(), signBody); - } - - bool SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool signBody) const override; - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, long long) const override { return false; } - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, const char*, long long) const override { return false; } - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, const char*, const char*, long long) const override { return false; } - - bool ShouldSignHeader(const Aws::String& header) const; - private: - Utils::ByteBuffer GenerateSignature(const Aws::Auth::AWSCredentials& credentials, - const Aws::String& stringToSign, const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; - Utils::ByteBuffer GenerateSignature(const Aws::String& stringToSign, const Aws::Utils::ByteBuffer& key) const; - Aws::String GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, - const Aws::String& canonicalRequestHash, const Aws::String& region, - const Aws::String& serviceName) const; - Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, const Aws::String& simpleDate) const; - Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, - const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; - const Aws::String m_serviceName; - const Aws::String m_region; - mutable Aws::Utils::Crypto::Sha256 m_hash; - mutable Aws::Utils::Crypto::Sha256HMAC m_HMAC; - mutable Utils::Threading::ReaderWriterLock m_derivedKeyLock; - mutable Aws::Utils::ByteBuffer m_derivedKey; - mutable Aws::String m_currentDateStr; - mutable Aws::String m_currentSecretKey; - Aws::Vector<Aws::String> m_unsignedHeaders; - std::shared_ptr<Auth::AWSCredentialsProvider> m_credentialsProvider; - }; - - - /** - * A no-op implementation of the AWSAuthSigner interface - */ - class AWS_CORE_API AWSNullSigner : public AWSAuthSigner - { - public: - /** - * AWSNullSigner's implementation of virtual function from base class - * Here the returned value is specified in Aws::Auth::NULL_SIGNER. - */ - const char* GetName() const override { return Aws::Auth::NULL_SIGNER; } - - /** - * Do nothing - */ - bool SignRequest(Aws::Http::HttpRequest&) const override { return true; } - - /** - * Do nothing - */ - bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const override { return true; } - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, long long) const override { return false; } - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, const char*, long long) const override { return false; } - - /** - * Do nothing - */ - bool PresignRequest(Aws::Http::HttpRequest&, const char*, const char*, long long) const override { return false; } - }; - - } // namespace Client -} // namespace Aws +#include <aws/core/auth/signer/AWSAuthV4Signer.h> +#include <aws/core/auth/signer/AWSAuthEventStreamV4Signer.h> +#include <aws/core/auth/signer/AWSNullSigner.h> +// This is a header that represents old legacy all-in-one header to maintain backward compatibility diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSignerProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSignerProvider.h index 305c58cd9d..b27d079284 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSignerProvider.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSAuthSignerProvider.h @@ -6,48 +6,7 @@ #pragma once -#include <aws/core/Core_EXPORTS.h> -#include <aws/core/utils/memory/stl/AWSString.h> -#include <aws/core/utils/memory/stl/AWSVector.h> -#include <memory> +#include <aws/core/auth/signer-provider/AWSAuthSignerProviderBase.h> +#include <aws/core/auth/signer-provider/DefaultAuthSignerProvider.h> - -namespace Aws -{ - namespace Client - { - class AWSAuthSigner; - } - namespace Auth - { - class AWSCredentialsProvider; - - class AWS_CORE_API AWSAuthSignerProvider - { - public: - virtual std::shared_ptr<Aws::Client::AWSAuthSigner> GetSigner(const Aws::String& signerName) const = 0; - virtual void AddSigner(std::shared_ptr<Aws::Client::AWSAuthSigner>& signer) = 0; - virtual ~AWSAuthSignerProvider() = default; - }; - - class AWS_CORE_API DefaultAuthSignerProvider : public AWSAuthSignerProvider - { - public: - /** - * Creates a Signature-V4 signer provider that supports the different implementations of Signature-V4 - * used for standard and event-stream requests. - * - * @param credentialsProvider A provider to retrieve the access/secret key used to derive the signing - * @param serviceName The canonical name of the AWS service to be used in the signature - * @param region The AWS region in which the requests will be made. - */ - DefaultAuthSignerProvider(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider, - const Aws::String& serviceName, const Aws::String& region); - explicit DefaultAuthSignerProvider(const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer); - void AddSigner(std::shared_ptr<Aws::Client::AWSAuthSigner>& signer) override; - std::shared_ptr<Aws::Client::AWSAuthSigner> GetSigner(const Aws::String& signerName) const override; - private: - Aws::Vector<std::shared_ptr<Aws::Client::AWSAuthSigner>> m_signers; - }; - } -} +// This is a header that represents old legacy all-in-one header to maintain backward compatibility diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSBearerToken.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSBearerToken.h new file mode 100644 index 0000000000..9565dd3802 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSBearerToken.h @@ -0,0 +1,113 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/DateTime.h> + +namespace Aws +{ + namespace Auth + { + /** + * Simple data object around aws credentials + */ + class AWS_CORE_API AWSBearerToken + { + public: + /** + * Initializes an empty token. + * Empty token is not expired by default. + * Token expires only if an expiration date is explicitly set. + */ + AWSBearerToken() : m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)()) + { + } + + /** + * Initializes object with token. + * Expiration date is set to "never expire". + */ + AWSBearerToken(const Aws::String& token) : + m_token(token), + m_expiration((std::chrono::time_point<std::chrono::system_clock>::max)()) + { + } + + /** + * Initializes object with token and expiration date. + */ + AWSBearerToken(const Aws::String& token, Aws::Utils::DateTime expiration) : + m_token(token), + m_expiration(expiration) + { + } + + /** + * If token has not been initialized or been initialized to empty value. + * Expiration date does not affect the result of this function. + */ + inline bool IsEmpty() const { return m_token.empty(); } + + inline bool IsExpired() const { return m_expiration <= Aws::Utils::DateTime::Now(); } + + inline bool IsExpiredOrEmpty() const { return IsEmpty() || IsExpired(); } + + /** + * Gets the underlying token + */ + inline const Aws::String& GetToken() const + { + return m_token; + } + + /** + * Gets the expiration date of the token + */ + inline Aws::Utils::DateTime GetExpiration() const + { + return m_expiration; + } + + /** + * Sets the underlying token. Copies from the parameter token + */ + inline void SetToken(const Aws::String& token) + { + m_token = token; + } + + /** + * Sets the underlying token. Moves from the parameter token + */ + inline void SetToken(Aws::String&& token) + { + m_token = std::move(token); + } + + /** + * Sets the expiration date of the credential + */ + inline void SetExpiration(const Aws::Utils::DateTime& expiration) + { + m_expiration = expiration; + } + + /** + * Sets the expiration date of the credential + */ + inline void SetExpiration(Aws::Utils::DateTime&& expiration) + { + m_expiration = std::move(expiration); + } + + private: + Aws::String m_token; + Aws::Utils::DateTime m_expiration; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h index 1c14b955fc..0152d3e5a7 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentials.h @@ -68,7 +68,7 @@ namespace Aws } /** - * If credentials haven't been initialized or been initialized to emtpy values. + * If credentials haven't been initialized or been initialized to empty values. * Expiration date does not affect the result of this function. */ inline bool IsEmpty() const { return m_accessKeyId.empty() && m_secretKey.empty(); } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h index a3a46964e8..e8fec174ab 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h @@ -217,6 +217,7 @@ namespace Aws void Reload() override; private: + bool ExpiresSoon() const; void RefreshIfExpired(); std::shared_ptr<Aws::Config::AWSProfileConfigLoader> m_ec2MetadataConfigLoader; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProviderChain.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProviderChain.h index dae8cf5a42..ffcd57dde4 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProviderChain.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProviderChain.h @@ -32,7 +32,7 @@ namespace Aws /** * Gets all providers stored in this chain. */ - const Aws::Vector<std::shared_ptr<AWSCredentialsProvider>>& GetProviders() { return m_providerChain; } + const Aws::Vector<std::shared_ptr<AWSCredentialsProvider>>& GetProviders() const { return m_providerChain; } protected: /** @@ -62,6 +62,8 @@ namespace Aws * and InstanceProfileCredentialsProvider in that order. */ DefaultAWSCredentialsProviderChain(); + + DefaultAWSCredentialsProviderChain(const DefaultAWSCredentialsProviderChain& chain); }; } // namespace Auth diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/SSOCredentialsProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/SSOCredentialsProvider.h index 288beccb3b..3b476177b9 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/SSOCredentialsProvider.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/SSOCredentialsProvider.h @@ -8,6 +8,7 @@ #include <aws/core/Core_EXPORTS.h> #include <aws/core/auth/AWSCredentialsProvider.h> +#include <aws/core/auth/bearer-token-provider/SSOBearerTokenProvider.h> #include <memory> namespace Aws { @@ -39,6 +40,8 @@ namespace Aws { Aws::String m_ssoRegion; // The expiration time of the accessToken. Aws::Utils::DateTime m_expiresAt; + // The SSO Token Provider + Aws::Auth::SSOBearerTokenProvider m_bearerTokenProvider; void Reload() override; void RefreshIfExpired(); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/STSCredentialsProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/STSCredentialsProvider.h index 92d997c7ca..720006592c 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/STSCredentialsProvider.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/STSCredentialsProvider.h @@ -46,6 +46,7 @@ namespace Aws Aws::String m_sessionName; Aws::String m_token; bool m_initialized; + bool ExpiresSoon() const; }; } // namespace Auth } // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/AWSBearerTokenProviderBase.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/AWSBearerTokenProviderBase.h new file mode 100644 index 0000000000..d7608a351c --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/AWSBearerTokenProviderBase.h @@ -0,0 +1,30 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/auth/AWSBearerToken.h> + +namespace Aws +{ + namespace Auth + { + /** + * Abstract class for retrieving Bearer Token. Create a derived class from this to allow + * various methods of storing and retrieving auth bearer tokens. + */ + class AWS_CORE_API AWSBearerTokenProviderBase + { + public: + virtual ~AWSBearerTokenProviderBase() = default; + + /** + * The core of the bearer token provider interface. Override this method to control how credentials are retrieved. + */ + virtual AWSBearerToken GetAWSBearerToken() = 0; + }; + } // namespace Auth +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/AWSBearerTokenProviderChainBase.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/AWSBearerTokenProviderChainBase.h new file mode 100644 index 0000000000..e5f3b828bc --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/AWSBearerTokenProviderChainBase.h @@ -0,0 +1,31 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/auth/bearer-token-provider/AWSBearerTokenProviderBase.h> +#include <aws/core/utils/memory/stl/AWSVector.h> +#include <memory> + +namespace Aws +{ + namespace Auth + { + /** + * Abstract class for providing chains of bearer token providers + */ + class AWS_CORE_API AWSBearerTokenProviderChainBase : public AWSBearerTokenProviderBase + { + public: + virtual ~AWSBearerTokenProviderChainBase() = default; + + /** + * Gets all providers stored in this chain. + */ + virtual const Aws::Vector<std::shared_ptr<AWSBearerTokenProviderBase>>& GetProviders() = 0; + }; + } // namespace Auth +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h new file mode 100644 index 0000000000..8e8a4508a3 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h @@ -0,0 +1,49 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/auth/bearer-token-provider/AWSBearerTokenProviderChainBase.h> +#include <aws/core/utils/memory/stl/AWSVector.h> +#include <memory> + +namespace Aws +{ + namespace Auth + { + /** + * Default built-in AWSBearerTokenProviderChainBase implementation that includes Aws::Auth::SSOBearerTokenProvider in the chain. + */ + class AWS_CORE_API DefaultBearerTokenProviderChain : public AWSBearerTokenProviderChainBase + { + public: + DefaultBearerTokenProviderChain(); + virtual ~DefaultBearerTokenProviderChain() = default; + + /** + * Return bearer token, implementation of a base class interface + */ + virtual AWSBearerToken GetAWSBearerToken() override; + + /** + * Gets all providers stored in this chain. + */ + const Aws::Vector<std::shared_ptr<AWSBearerTokenProviderBase>>& GetProviders() override + { + return m_providerChain; + } + + protected: + /** + * Adds a provider to the back of the chain. + */ + void AddProvider(const std::shared_ptr<AWSBearerTokenProviderBase>& provider) { m_providerChain.push_back(provider); } + + Aws::Vector<std::shared_ptr<AWSBearerTokenProviderBase> > m_providerChain; + }; + + } // namespace Auth +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/SSOBearerTokenProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/SSOBearerTokenProvider.h new file mode 100644 index 0000000000..b0656caa8e --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/bearer-token-provider/SSOBearerTokenProvider.h @@ -0,0 +1,63 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/auth/bearer-token-provider/AWSBearerTokenProviderBase.h> + +#include <aws/core/internal/AWSHttpResourceClient.h> +#include <aws/core/utils/threading/ReaderWriterLock.h> + +namespace Aws +{ + namespace Auth + { + /** + * To support usage of SSO bearerToken. + * The SSO token provider assumes that an SSO access token has already been resolved and cached to disk. + */ + class AWS_CORE_API SSOBearerTokenProvider : public AWSBearerTokenProviderBase + { + public: + SSOBearerTokenProvider(); + explicit SSOBearerTokenProvider(const Aws::String& awsProfile); + /** + * Retrieves the bearerToken if found, otherwise returns empty credential set. + */ + AWSBearerToken GetAWSBearerToken() override; + + protected: + struct CachedSsoToken + { + public: + Aws::String accessToken; + Aws::Utils::DateTime expiresAt; + Aws::String refreshToken; + Aws::String clientId; + Aws::String clientSecret; + Aws::Utils::DateTime registrationExpiresAt; + Aws::String region; + Aws::String startUrl; + }; + + static const size_t REFRESH_ATTEMPT_INTERVAL_S; + static const size_t REFRESH_WINDOW_BEFORE_EXPIRATION_S; + // Profile description variables + Aws::UniquePtr<Aws::Internal::SSOCredentialsClient> m_client; + Aws::String m_profileToUse; + + mutable Aws::Auth::AWSBearerToken m_token; + mutable Aws::Utils::DateTime m_lastUpdateAttempt; + + mutable Aws::Utils::Threading::ReaderWriterLock m_reloadLock; + + void Reload(); + void RefreshFromSso(); + CachedSsoToken LoadAccessTokenFile() const; + bool WriteAccessTokenFile(const CachedSsoToken& token) const; + }; + } // namespace Auth +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/AWSAuthSignerProviderBase.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/AWSAuthSignerProviderBase.h new file mode 100644 index 0000000000..0577cef77e --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/AWSAuthSignerProviderBase.h @@ -0,0 +1,33 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/Core_EXPORTS.h> + +#include <aws/core/utils/memory/stl/AWSVector.h> +#include <aws/core/utils/memory/stl/AWSString.h> +#include <memory> + +namespace Aws +{ + namespace Client + { + class AWSAuthSigner; + } + namespace Auth + { + class AWSCredentialsProvider; + + class AWS_CORE_API AWSAuthSignerProvider + { + public: + virtual std::shared_ptr<Aws::Client::AWSAuthSigner> GetSigner(const Aws::String& signerName) const = 0; + virtual void AddSigner(std::shared_ptr<Aws::Client::AWSAuthSigner>& signer) = 0; + virtual ~AWSAuthSignerProvider() = default; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/BearerTokenAuthSignerProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/BearerTokenAuthSignerProvider.h new file mode 100644 index 0000000000..09b83a8e27 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/BearerTokenAuthSignerProvider.h @@ -0,0 +1,38 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/auth/signer-provider/AWSAuthSignerProviderBase.h> +#include <aws/core/utils/memory/stl/AWSSet.h> +#include <aws/core/auth/signer/AWSAuthBearerSigner.h> + + +namespace Aws +{ + namespace Auth + { + class AWSCredentialsProvider; + + class AWS_CORE_API BearerTokenAuthSignerProvider : public AWSAuthSignerProvider + { + public: + /** + * Creates a Signature-V4 signer provider that supports the different implementations of Signature-V4 + * used for standard and event-stream requests. + * + * @param credentialsProvider A provider to retrieve the access/secret key used to derive the signing + * @param serviceName The canonical name of the AWS service to be used in the signature + * @param region The AWS region in which the requests will be made. + */ + BearerTokenAuthSignerProvider() = delete; + BearerTokenAuthSignerProvider(const std::shared_ptr<Aws::Auth::AWSBearerTokenProviderBase> bearerTokenProvider); + void AddSigner(std::shared_ptr<Aws::Client::AWSAuthSigner>& signer) override; + std::shared_ptr<Aws::Client::AWSAuthSigner> GetSigner(const Aws::String& signerName) const override; + private: + Aws::Vector<std::shared_ptr<Aws::Client::AWSAuthSigner>> m_signers; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/DefaultAuthSignerProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/DefaultAuthSignerProvider.h new file mode 100644 index 0000000000..4c31aaaa32 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer-provider/DefaultAuthSignerProvider.h @@ -0,0 +1,42 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/auth/signer-provider/AWSAuthSignerProviderBase.h> + +#include <aws/core/auth/signer/AWSAuthV4Signer.h> + + +namespace Aws +{ + namespace Auth + { + class AWSCredentialsProvider; + + class AWS_CORE_API DefaultAuthSignerProvider : public AWSAuthSignerProvider + { + public: + /** + * Creates a Signature-V4 signer provider that supports the different implementations of Signature-V4 + * used for standard and event-stream requests. + * + * @param credentialsProvider A provider to retrieve the access/secret key used to derive the signing + * @param serviceName The canonical name of the AWS service to be used in the signature + * @param region The AWS region in which the requests will be made. + */ + DefaultAuthSignerProvider(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider, + const Aws::String& serviceName, const Aws::String& region, + Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy signingPolicy = Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::RequestDependent, + bool urlEscapePath = true); + explicit DefaultAuthSignerProvider(const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer); + void AddSigner(std::shared_ptr<Aws::Client::AWSAuthSigner>& signer) override; + std::shared_ptr<Aws::Client::AWSAuthSigner> GetSigner(const Aws::String& signerName) const override; + private: + Aws::Vector<std::shared_ptr<Aws::Client::AWSAuthSigner>> m_signers; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthBearerSigner.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthBearerSigner.h new file mode 100644 index 0000000000..655aeb1a00 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthBearerSigner.h @@ -0,0 +1,106 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include "aws/core/auth/signer/AWSAuthSignerBase.h" + +namespace Aws +{ + namespace Http + { + class HttpRequest; + } // namespace Http + + namespace Utils + { + namespace Event + { + class Message; + } + } // namespace Utils + + namespace Auth + { + class AWSBearerTokenProviderBase; + AWS_CORE_API extern const char BEARER_SIGNER[]; + } // namespace Auth + + namespace Client + { + class AWS_CORE_API AWSAuthBearerSigner : public AWSAuthSigner + { + + public: + /** + * An implementation of a signer interface that uses bearer token auth signature. + */ + AWSAuthBearerSigner(const std::shared_ptr<Aws::Auth::AWSBearerTokenProviderBase> bearerTokenProvider) + : m_bearerTokenProvider(bearerTokenProvider) + {} + + virtual ~AWSAuthBearerSigner() {}; + + /** + * Return the signer's name + */ + const char* GetName() const override + { + return Aws::Auth::BEARER_SIGNER; + } + + /** + * Sign request with a bearer auth token + * @return true if success, false if fail to sign + */ + bool SignRequest(Aws::Http::HttpRequest& ) const override; + + /** + * Dummy function to satisfy the interface requirements of a base Signer interface + * additional arguments are not used. + * @return true if success, false if fail to sign + */ + bool SignRequest(Aws::Http::HttpRequest& ioRequest, const char* /*region*/, const char* /*serviceName*/, bool /*signBody*/) const override + { + return SignRequest(ioRequest); + } + + /** + * Dummy function to satisfy the interface requirements of a base Signer interface + * @return true if success, false if fail to sign + */ + bool PresignRequest(Aws::Http::HttpRequest& ioRequest, long long /*expirationInSeconds = 0*/) const override + { + return SignRequest(ioRequest); + } + + /** + * Dummy function to satisfy the interface requirements of a base Signer interface + * additional arguments are not used. + * @return true if success, false if fail to sign + */ + bool PresignRequest(Aws::Http::HttpRequest& ioRequest, const char* /*region*/, long long expirationInSeconds = 0) const override + { + return PresignRequest(ioRequest, expirationInSeconds); + } + + /** + * Dummy function to satisfy the interface requirements of a base Signer interface + * additional arguments are not used. + * @return true if success, false if fail to sign + */ + bool PresignRequest(Aws::Http::HttpRequest& ioRequest, const char* /*region*/, const char* /*serviceName*/, long long expirationInSeconds = 0) const override + { + return PresignRequest(ioRequest, expirationInSeconds); + } + + protected: + std::shared_ptr<Aws::Auth::AWSBearerTokenProviderBase> m_bearerTokenProvider; + }; + + } // namespace Client +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthEventStreamV4Signer.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthEventStreamV4Signer.h new file mode 100644 index 0000000000..f9c4d4fedf --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthEventStreamV4Signer.h @@ -0,0 +1,114 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include "aws/core/auth/signer/AWSAuthSignerBase.h" + +#include <aws/core/utils/Array.h> +#include <aws/core/utils/memory/stl/AWSSet.h> +#include <aws/core/utils/threading/ReaderWriterLock.h> +#include <aws/core/utils/crypto/Sha256.h> +#include <aws/core/utils/crypto/Sha256HMAC.h> + +#include <aws/crt/auth/Sigv4Signing.h> + +#include <memory> + +namespace Aws +{ + namespace Http + { + class HttpRequest; + } // namespace Http + + namespace Utils + { + namespace Event + { + class Message; + } + } // namespace Utils + + namespace Auth + { + class AWSCredentials; + class AWSCredentialsProvider; + + AWS_CORE_API extern const char EVENTSTREAM_SIGV4_SIGNER[]; + } // namespace Auth + + namespace Client + { + /** + * AWS Auth EventStream v4 Signer implementation of the AWSAuthSigner interface. + */ + class AWS_CORE_API AWSAuthEventStreamV4Signer : public AWSAuthSigner + { + public: + AWSAuthEventStreamV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& credentialsProvider, + const char* serviceName, const Aws::String& region); + + const char* GetName() const override { return Aws::Auth::EVENTSTREAM_SIGV4_SIGNER; } + + bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& priorSignature) const override; + + bool SignRequest(Aws::Http::HttpRequest& request) const override + { + return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), true); + } + + bool SignRequest(Aws::Http::HttpRequest& request, bool signBody) const override + { + return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), signBody); + } + + bool SignRequest(Aws::Http::HttpRequest& request, const char* region, bool signBody) const override + { + return SignRequest(request, region, m_serviceName.c_str(), signBody); + } + + bool SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool signBody) const override; + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, long long) const override { return false; } + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, const char*, long long) const override { return false; } + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, const char*, const char*, long long) const override { return false; } + + bool ShouldSignHeader(const Aws::String& header) const; + private: + Utils::ByteBuffer GenerateSignature(const Aws::Auth::AWSCredentials& credentials, + const Aws::String& stringToSign, const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; + Utils::ByteBuffer GenerateSignature(const Aws::String& stringToSign, const Aws::Utils::ByteBuffer& key) const; + Aws::String GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, + const Aws::String& canonicalRequestHash, const Aws::String& region, + const Aws::String& serviceName) const; + Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, const Aws::String& simpleDate) const; + Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, + const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; + const Aws::String m_serviceName; + const Aws::String m_region; + mutable Aws::Utils::Crypto::Sha256 m_hash; + mutable Aws::Utils::Crypto::Sha256HMAC m_HMAC; + mutable Utils::Threading::ReaderWriterLock m_derivedKeyLock; + mutable Aws::Utils::ByteBuffer m_derivedKey; + mutable Aws::String m_currentDateStr; + mutable Aws::String m_currentSecretKey; + Aws::Vector<Aws::String> m_unsignedHeaders; + std::shared_ptr<Auth::AWSCredentialsProvider> m_credentialsProvider; + }; + } // namespace Client +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerBase.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerBase.h new file mode 100644 index 0000000000..54be880a37 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerBase.h @@ -0,0 +1,142 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include "aws/core/Core_EXPORTS.h" +#include "aws/core/utils/DateTime.h" + +#include <memory> +#include <atomic> +#include <chrono> + +namespace Aws +{ + namespace Http + { + class HttpRequest; + } // namespace Http + + namespace Utils + { + namespace Event + { + class Message; + } + } // namespace Utils + + namespace Client + { + /** + * Auth Signer interface. Takes a generic AWS request and applies crypto tamper resistent signatures on the request. + */ + class AWS_CORE_API AWSAuthSigner + { + public: + AWSAuthSigner() : m_clockSkew() { m_clockSkew.store(std::chrono::milliseconds(0L)); } + virtual ~AWSAuthSigner() = default; + + /** + * Signs the request itself (usually by adding a signature header) based on info in the request and uri. + */ + virtual bool SignRequest(Aws::Http::HttpRequest& request) const = 0; + + /** + * Signs the request itself (usually by adding a signature header) based on info in the request and uri. + * If signBody is false and https is being used then the body of the payload will not be signed. + * The default virtual function, just calls SignRequest. + */ + virtual bool SignRequest(Aws::Http::HttpRequest& request, bool signBody) const + { + AWS_UNREFERENCED_PARAM(signBody); + return SignRequest(request); + } + + /** + * Signs the request itself (usually by adding a signature header) based on info in the request and uri. + * If signBody is false and https is being used then the body of the payload will not be signed. + * The default virtual function, just calls SignRequest. + * Using m_region by default if parameter region is nullptr. + */ + virtual bool SignRequest(Aws::Http::HttpRequest& request, const char* region, bool signBody) const + { + AWS_UNREFERENCED_PARAM(signBody); + AWS_UNREFERENCED_PARAM(region); + return SignRequest(request); + } + + /** + * Signs the request itself (usually by adding a signature header) based on info in the request and uri. + * If signBody is false and https is being used then the body of the payload will not be signed. + * The default virtual function, just calls SignRequest. + * Using m_region by default if parameter region is nullptr. + * Using m_serviceName by default if parameter serviceName is nullptr. + */ + virtual bool SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool signBody) const + { + AWS_UNREFERENCED_PARAM(signBody); + AWS_UNREFERENCED_PARAM(region); + AWS_UNREFERENCED_PARAM(serviceName); + return SignRequest(request); + } + + /** + * Signs a single event message in an event stream. + * The input message buffer is copied and signed. The message's input buffer will be deallocated and a new + * buffer will be assigned. The new buffer encodes the original message with its headers as the payload of + * the new message. The signature of the original message will be added as a header to the new message. + * + * A Hex encoded signature of the previous event (or of the HTTP request headers in case of the first event) + * is provided as the 'priorSignature' parameter. 'priorSignature' will contain the value of the new + * signature after this call returns successfully. + * + * The function returns true if the message is successfully signed. + */ + virtual bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const { return false; } + + /** + * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. + * The URI can then be used in a normal HTTP call until expiration. + */ + virtual bool PresignRequest(Aws::Http::HttpRequest& request, long long expirationInSeconds) const = 0; + + /** + * Generates a signed Uri using the injected signer. for the supplied uri and http method and region. expirationInSeconds defaults + * to 0 which is the default 7 days. + * Using m_region by default if parameter region is nullptr. + */ + virtual bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, long long expirationInSeconds = 0) const = 0; + + /** + * Generates a signed Uri using the injected signer. for the supplied uri and http method, region, and service name. expirationInSeconds defaults + * to 0 which is the default 7 days. + * Using m_region by default if parameter region is nullptr. + * Using m_serviceName by default if parameter serviceName is nullptr. + */ + virtual bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, long long expirationInSeconds = 0) const = 0; + + /** + * Return the signer's name + */ + virtual const char* GetName() const = 0; + + /** + * This handles detection of clock skew between clients and the server and adjusts the clock so that the next request will not + * fail on the timestamp check. + */ + virtual void SetClockSkew(const std::chrono::milliseconds& clockSkew) { m_clockSkew = clockSkew; } + + /** + * Gets the timestamp being used by the signer. This may include a clock skew if a clock skew has been detected. + */ + virtual Aws::Utils::DateTime GetSigningTimestamp() const { return Aws::Utils::DateTime::Now() + GetClockSkewOffset(); } + + protected: + virtual std::chrono::milliseconds GetClockSkewOffset() const { return m_clockSkew.load(); } + + std::atomic<std::chrono::milliseconds> m_clockSkew; + }; + } // namespace Client +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerCommon.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerCommon.h new file mode 100644 index 0000000000..7ed72b87b7 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerCommon.h @@ -0,0 +1,23 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/http/HttpTypes.h> + +namespace Aws +{ + namespace Http + { + class HttpRequest; + } // namespace Http + + namespace Auth + { + AWS_CORE_API extern const char SIGNATURE[]; + } // namespace Client +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerHelper.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerHelper.h new file mode 100644 index 0000000000..955445b6b6 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthSignerHelper.h @@ -0,0 +1,45 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/http/HttpTypes.h> + +namespace Aws +{ + namespace Http + { + class HttpRequest; + } // namespace Http + + namespace Auth + { + class AWSAuthHelper + { + public: + /** + * Helper functions used across different signers + */ + static Aws::String CanonicalizeRequestSigningString(Aws::Http::HttpRequest &request, bool urlEscapePath); + static Aws::Http::HeaderValueCollection CanonicalizeHeaders(Http::HeaderValueCollection &&headers); + + /** + * Static const variables used across different signers + */ + static const char* EQ; + static const char* AWS_HMAC_SHA256; + static const char* AWS4_REQUEST; + static const char* SIGNED_HEADERS; + static const char* CREDENTIAL; + static const char* NEWLINE; + static const char* X_AMZN_TRACE_ID; + static const char* X_AMZ_CONTENT_SHA256; + static const char* SIGNING_KEY; + static const char* SIMPLE_DATE_FORMAT_STR; + }; + } // namespace Client +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthV4Signer.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthV4Signer.h new file mode 100644 index 0000000000..469391a1ca --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSAuthV4Signer.h @@ -0,0 +1,214 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include "aws/core/auth/signer/AWSAuthSignerBase.h" + +#include <aws/core/utils/Array.h> +#include <aws/core/utils/memory/stl/AWSSet.h> +#include <aws/core/utils/threading/ReaderWriterLock.h> +#include <aws/core/utils/crypto/Sha256.h> +#include <aws/core/utils/crypto/Sha256HMAC.h> + +#include <aws/crt/auth/Sigv4Signing.h> + +#include <memory> + +namespace Aws +{ + namespace Http + { + class HttpRequest; + } // namespace Http + + namespace Auth + { + class AWSCredentials; + class AWSCredentialsProvider; + + enum class AWSSigningAlgorithm + { + SIGV4 = static_cast<int>(Aws::Crt::Auth::SigningAlgorithm::SigV4), + ASYMMETRIC_SIGV4 = static_cast<int>(Aws::Crt::Auth::SigningAlgorithm::SigV4A), + }; + + AWS_CORE_API extern const char SIGV4_SIGNER[]; + AWS_CORE_API extern const char ASYMMETRIC_SIGV4_SIGNER[]; + } // namespace Auth + + namespace Client + { + /** + * AWS Auth v4 Signer implementation of the AWSAuthSigner interface. More information on AWS Auth v4 Can be found here: + * http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html + */ + class AWS_CORE_API AWSAuthV4Signer : public AWSAuthSigner + { + + public: + /** + * Even though different payload signing polices, HTTP will force payload signing to be on. + */ + enum class PayloadSigningPolicy + { + /** + * Sign the request based on the value returned by AmazonWebServiceRequest::SignBody() + */ + RequestDependent, + /** + * Always sign the body of the request. + */ + Always, + /** + * Never sign the body of the request + */ + Never + }; + /** + * credentialsProvider, source of AWS Credentials to sign requests with + * serviceName, canonical service name to sign with + * region, region string to use in signature + * signPayloads, if Always, the payload will have a sha256 computed on the body of the request. If this is set + * to Never, the sha256 will not be computed on the body. This is only useful for Amazon S3 over Https. If + * Https is not used then this flag will be ignored. If set to RequestDependent, compute or not is based on + * the value from AmazonWebServiceRequest::SignBody() + */ + AWSAuthV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& credentialsProvider, + const char* serviceName, const Aws::String& region, PayloadSigningPolicy signingPolicy = PayloadSigningPolicy::RequestDependent, + bool urlEscapePath = true, Aws::Auth::AWSSigningAlgorithm signingAlgorithm = Aws::Auth::AWSSigningAlgorithm::SIGV4); + + virtual ~AWSAuthV4Signer(); + + /** + * AWSAuthV4signer's implementation of virtual function from base class + * Return Auth Signer's name, here the value is specified in Aws::Auth::DEFAULT_AUTHV4_SIGNER. + */ + const char* GetName() const override + { + if (m_signingAlgorithm == Aws::Auth::AWSSigningAlgorithm::ASYMMETRIC_SIGV4) + { + return Aws::Auth::ASYMMETRIC_SIGV4_SIGNER; + } + else + { + return Aws::Auth::SIGV4_SIGNER; + } + } + + /** + * Signs the request itself based on info in the request and uri. + * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. + */ + bool SignRequest(Aws::Http::HttpRequest& request) const override + { + return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), true/*signBody*/); + } + + /** + * Signs the request itself based on info in the request and uri. + * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. If signBody is false + * and https is being used then the body of the payload will not be signed. + */ + bool SignRequest(Aws::Http::HttpRequest& request, bool signBody) const override + { + return SignRequest(request, m_region.c_str(), m_serviceName.c_str(), signBody); + } + + /** + * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. If signBody is false + * and https is being used then the body of the payload will not be signed. + * Using m_region by default if parameter region is nullptr. + */ + bool SignRequest(Aws::Http::HttpRequest& request, const char* region, bool signBody) const override + { + return SignRequest(request, region, m_serviceName.c_str(), signBody); + } + + /** + * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. If signBody is false + * and https is being used then the body of the payload will not be signed. + * Using m_region by default if parameter region is nullptr. + */ + bool SignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, bool signBody) const override; + + /** + * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. + * the region the signer was initialized with will be used for the signature. + * The URI can then be used in a normal HTTP call until expiration. + * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. + * expirationInSeconds defaults to 0 which provides a URI good for 7 days. + */ + bool PresignRequest(Aws::Http::HttpRequest& request, long long expirationInSeconds = 0) const override; + + /** + * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. + * The URI can then be used in a normal HTTP call until expiration. + * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. + * expirationInSeconds defaults to 0 which provides a URI good for 7 days. + * Using m_region by default if parameter region is nullptr. + */ + bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, long long expirationInSeconds = 0) const override; + + /** + * Takes a request and signs the URI based on the HttpMethod, URI and other info from the request. + * The URI can then be used in a normal HTTP call until expiration. + * Uses AWS Auth V4 signing method with SHA256 HMAC algorithm. + * expirationInSeconds defaults to 0 which provides a URI good for 7 days. + * Using m_region by default if parameter region is nullptr. + * Using m_serviceName by default if parameter serviceName is nullptr. + */ + bool PresignRequest(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, long long expirationInSeconds = 0) const override; + + Aws::String GetServiceName() const { return m_serviceName; } + Aws::String GetRegion() const { return m_region; } + Aws::String GenerateSignature(const Aws::Auth::AWSCredentials& credentials, + const Aws::String& stringToSign, const Aws::String& simpleDate) const; + bool ShouldSignHeader(const Aws::String& header) const; + + protected: + bool m_includeSha256HashHeader; + + private: + + Aws::String GenerateSignature(const Aws::Auth::AWSCredentials& credentials, + const Aws::String& stringToSign, const Aws::String& simpleDate, const Aws::String& region, + const Aws::String& serviceName) const; + + Aws::String GenerateSignature(const Aws::String& stringToSign, const Aws::Utils::ByteBuffer& key) const; + bool ServiceRequireUnsignedPayload(const Aws::String& serviceName) const; + Aws::String ComputePayloadHash(Aws::Http::HttpRequest&) const; + Aws::String GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, + const Aws::String& canonicalRequestHash, const Aws::String& region, + const Aws::String& serviceName) const; + Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, const Aws::String& simpleDate) const; + Aws::Utils::ByteBuffer ComputeHash(const Aws::String& secretKey, + const Aws::String& simpleDate, const Aws::String& region, const Aws::String& serviceName) const; + bool SignRequestWithSigV4a(Aws::Http::HttpRequest& request, const char* region, const char* serviceName, + bool signBody, long long expirationTimeInSeconds, Aws::Crt::Auth::SignatureType signatureType) const; + + Aws::Auth::AWSSigningAlgorithm m_signingAlgorithm; + std::shared_ptr<Auth::AWSCredentialsProvider> m_credentialsProvider; + const Aws::String m_serviceName; + const Aws::String m_region; + Aws::UniquePtr<Aws::Utils::Crypto::Sha256> m_hash; + Aws::UniquePtr<Aws::Utils::Crypto::Sha256HMAC> m_HMAC; + + Aws::Set<Aws::String> m_unsignedHeaders; + + //these next four fields are ONLY for caching purposes and do not change + //the logical state of the signer. They are marked mutable so the + //interface can remain const. + mutable Aws::Utils::ByteBuffer m_partialSignature; + mutable Aws::String m_currentDateStr; + mutable Aws::String m_currentSecretKey; + mutable Utils::Threading::ReaderWriterLock m_partialSignatureLock; + PayloadSigningPolicy m_payloadSigningPolicy; + bool m_urlEscapePath; + }; + } // namespace Client +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSNullSigner.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSNullSigner.h new file mode 100644 index 0000000000..7c40f44fb4 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/auth/signer/AWSNullSigner.h @@ -0,0 +1,72 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include "aws/core/auth/signer/AWSAuthSignerBase.h" + +namespace Aws +{ + namespace Http + { + class HttpRequest; + } // namespace Http + + namespace Utils + { + namespace Event + { + class Message; + } + } // namespace Utils + + namespace Auth + { + AWS_CORE_API extern const char NULL_SIGNER[]; + } // namespace Auth + + namespace Client + { + /** + * A no-op implementation of the AWSAuthSigner interface + */ + class AWS_CORE_API AWSNullSigner : public AWSAuthSigner + { + public: + /** + * AWSNullSigner's implementation of virtual function from base class + * Here the returned value is specified in Aws::Auth::NULL_SIGNER. + */ + const char* GetName() const override { return Aws::Auth::NULL_SIGNER; } + + /** + * Do nothing + */ + bool SignRequest(Aws::Http::HttpRequest&) const override { return true; } + + /** + * Do nothing + */ + bool SignEventMessage(Aws::Utils::Event::Message&, Aws::String& /* priorSignature */) const override { return true; } + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, long long) const override { return false; } + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, const char*, long long) const override { return false; } + + /** + * Do nothing + */ + bool PresignRequest(Aws::Http::HttpRequest&, const char*, const char*, long long) const override { return false; } + }; + + } // namespace Client +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSAsyncOperationTemplate.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSAsyncOperationTemplate.h new file mode 100644 index 0000000000..15ee45f885 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSAsyncOperationTemplate.h @@ -0,0 +1,191 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/memory/AWSMemory.h> +#include <aws/core/utils/memory/stl/AWSAllocator.h> +#include <aws/core/utils/threading/Executor.h> +#include <functional> +#include <future> + +namespace Aws +{ +namespace Client +{ + /** + * A template function that is used to create an Async Operation function body for AWS Operations + */ + template<typename ClientT, + typename RequestT, + typename HandlerT, + typename HandlerContextT, + typename OperationFuncT, + typename ExecutorT> + inline void AWS_CORE_LOCAL MakeAsyncOperation(OperationFuncT&& operationFunc, + const ClientT* clientThis, + const RequestT& request, + const HandlerT& handler, + const HandlerContextT& context, + ExecutorT* pExecutor) + { + std::function<void()> asyncTask = + [operationFunc, clientThis, request, handler, context]() // note capture by value + { + handler(clientThis, + request, + (clientThis->*operationFunc)(request), + context); + }; + + pExecutor->Submit(std::move(asyncTask)); + } + + /** + * A template function that is used to create an Async Operation function body for AWS Streaming Operations + * The only difference compared to a regular non-streaming Operation is that + * the request is passed by non-const reference, therefore virtual copy constructor is not needed. + * However, caller code must ensure the life time of the request object is maintained during the Async execution. + */ + template<typename ClientT, + typename RequestT, + typename HandlerT, + typename HandlerContextT, + typename OperationFuncT, + typename ExecutorT> + inline void AWS_CORE_LOCAL MakeAsyncStreamingOperation(OperationFuncT&& operationFunc, + const ClientT* clientThis, + RequestT& request, // note non-const ref + const HandlerT& handler, + const HandlerContextT& context, + ExecutorT* pExecutor) + { + std::function<void()> asyncTask = + [operationFunc, clientThis, &request, handler, context]() // note capture by ref + { + handler(clientThis, + request, + (clientThis->*operationFunc)(request), + context); + }; + + pExecutor->Submit(std::move(asyncTask)); + } + + /** + * A template function to create an Async Operation function body for AWS Operation without a request on input. + */ + template<typename ClientT, + typename HandlerT, + typename HandlerContextT, + typename OperationFuncT, + typename ExecutorT> + inline void AWS_CORE_LOCAL MakeAsyncOperation(OperationFuncT&& operationFunc, + const ClientT* clientThis, + const HandlerT& handler, + const HandlerContextT& context, + ExecutorT* pExecutor) + { + std::function<void()> asyncTask = + [operationFunc, clientThis, handler, context]() + { + handler(clientThis, + (clientThis->*operationFunc)(), + context); + }; + + pExecutor->Submit(std::move(asyncTask)); + } + + /** + * A template function that is used to create a Callable Operation function body for AWS Operations + */ + template<typename ClientT, + typename RequestT, + typename OperationFuncT, + typename ExecutorT> + inline auto AWS_CORE_LOCAL MakeCallableOperation(const char* ALLOCATION_TAG, + OperationFuncT&& operationFunc, + const ClientT* clientThis, + const RequestT& request, + ExecutorT* pExecutor) -> std::future<decltype((clientThis->*operationFunc)(request))> + { + using OperationOutcomeT = decltype((clientThis->*operationFunc)(request)); + + auto task = Aws::MakeShared< std::packaged_task< OperationOutcomeT() > >( + ALLOCATION_TAG, + [clientThis, operationFunc, request]() // note capture by value + { + auto futureOutcome = (clientThis->*operationFunc)(request); + return futureOutcome; + } ); + + std::function<void()> packagedFunction = + [task]() { (*task)(); }; + pExecutor->Submit(std::move(packagedFunction)); + return task->get_future(); + } + + /** + * A template function that is used to create a Callable Operation function body for AWS Streaming Operations + * The only difference compared to a regular non-streaming Operation is that + * the request is passed by non-const reference, therefore virtual copy constructor is not needed. + * However, caller code must ensure the life time of the request object is maintained during the Async execution. + */ + template<typename ClientT, + typename RequestT, + typename OperationFuncT, + typename ExecutorT> + inline auto AWS_CORE_LOCAL MakeCallableStreamingOperation(const char* ALLOCATION_TAG, + OperationFuncT&& operationFunc, + const ClientT* clientThis, + RequestT& request, // note non-const ref + ExecutorT* pExecutor) -> std::future<decltype((clientThis->*operationFunc)(request))> + { + using OperationOutcomeT = decltype((clientThis->*operationFunc)(request)); + + auto task = Aws::MakeShared< std::packaged_task< OperationOutcomeT() > >( + ALLOCATION_TAG, + [clientThis, operationFunc, &request]() // note capture by ref + { + return (clientThis->*operationFunc)(request); + } ); + + std::function<void()> packagedFunction = + [task]() { (*task)(); }; + pExecutor->Submit(std::move(packagedFunction)); + return task->get_future(); + } + + /** + * A template function that is used to create a Callable Operation function body for AWS Operation without a request on input. + */ + template<typename ClientT, + typename OperationFuncT, + typename ExecutorT> + inline auto AWS_CORE_LOCAL MakeCallableOperation(const char* ALLOCATION_TAG, + OperationFuncT&& operationFunc, + const ClientT* clientThis, + ExecutorT* pExecutor) -> std::future<decltype((clientThis->*operationFunc)())> + { + using OperationOutcomeT = decltype((clientThis->*operationFunc)()); + + auto task = Aws::MakeShared< std::packaged_task< OperationOutcomeT() > >( + ALLOCATION_TAG, + [clientThis, operationFunc]() + { + return (clientThis->*operationFunc)(); + } ); + + std::function<void()> packagedFunction = + [task]() { (*task)(); }; + pExecutor->Submit(std::move(packagedFunction)); + return task->get_future(); + } +} // namespace Client +} // namespace Aws + + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h index 186206a66e..4e67e8a4df 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h @@ -4,19 +4,21 @@ */ #pragma once +#if !defined(AWS_CLIENT_H) +#define AWS_CLIENT_H #include <aws/core/Core_EXPORTS.h> #include <aws/core/client/CoreErrors.h> +#include <aws/core/client/AWSUrlPresigner.h> #include <aws/core/http/HttpTypes.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/crypto/Hash.h> #include <aws/core/auth/AWSAuthSignerProvider.h> +#include <aws/core/endpoint/AWSEndpoint.h> #include <memory> #include <atomic> -struct aws_array_list; - namespace Aws { namespace Utils @@ -24,16 +26,6 @@ namespace Aws template<typename R, typename E> class Outcome; - namespace Xml - { - class XmlDocument; - } // namespace Xml - - namespace Json - { - class JsonValue; - } // namespace Json - namespace RateLimits { class RateLimiterInterface; @@ -71,7 +63,6 @@ namespace Aws template<typename ERROR_TYPE> class AWSError; class AWSErrorMarshaller; - class AWSRestfulJsonErrorMarshaller; class AWSAuthSigner; struct ClientConfiguration; class RetryStrategy; @@ -80,7 +71,7 @@ namespace Aws typedef Utils::Outcome<AmazonWebServiceResult<Utils::Stream::ResponseStream>, AWSError<CoreErrors>> StreamOutcome; /** - * Abstract AWS Client. Contains most of the functionality necessary to build an http request, get it signed, and send it accross the wire. + * Abstract AWS Client. Contains most of the functionality necessary to build an http request, get it signed, and send it across the wire. */ class AWS_CORE_API AWSClient { @@ -91,8 +82,8 @@ namespace Aws * errorMarshaller tells the client how to convert error payloads into AWSError objects. */ AWSClient(const Aws::Client::ClientConfiguration& configuration, - const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer, - const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); + const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer, + const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); /** * Configuration will be used for http client settings, retry strategy, throttles, and signing information. @@ -100,8 +91,8 @@ namespace Aws * SigV4 signer. errorMarshaller tells the client how to convert error payloads into AWSError objects. */ AWSClient(const Aws::Client::ClientConfiguration& configuration, - const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider, - const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); + const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider, + const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); virtual ~AWSClient() { }; @@ -109,46 +100,69 @@ namespace Aws * Generates a signed Uri using the injected signer. for the supplied uri and http method. expirationInSeconds defaults * to 0 which is the default 7 days. The implication of this function is using auth signer v4 to sign it. */ - Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, long long expirationInSeconds = 0); + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, long long expirationInSeconds = 0); /** * Generates a signed Uri using the injected signer. for the supplied uri, http method and customized headers. expirationInSeconds defaults * to 0 which is the default 7 days. The implication of this function is using auth signer v4 to sign it. */ - Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0); + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0); /** * Generates a signed Uri using the injected signer. for the supplied uri and http method and region. expirationInSeconds defaults * to 0 which is the default 7 days. */ - Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, long long expirationInSeconds = 0) const; + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, long long expirationInSeconds = 0) const; /** * Generates a signed Uri using the injected signer. for the supplied uri, http method and customized headers. expirationInSeconds defaults * to 0 which is the default 7 days. */ - Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0); + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0); /** * Generates a signed Uri using the injected signer. for the supplied uri and http method, region, and service name. expirationInSeconds defaults * to 0 which is the default 7 days. */ - Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, long long expirationInSeconds = 0) const; + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, long long expirationInSeconds = 0) const; /** * Generates a signed Uri using the injected signer. for the supplied uri, http method and customized headers. expirationInSeconds defaults * to 0 which is the default 7 days. */ - Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0); + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0); - Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, - const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; + /** + * Generates a signed Uri using the injected signer. for the supplied uri and http method, region, service name and signer name. expirationInSeconds defaults + * to 0 which is the default 7 days. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, const char* signerName, long long expirationInSeconds = 0) const; - Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, - const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; + /** + * Generates a signed Uri using the injected signer. for the supplied uri, http method, region, service name, signer name and customized headers. expirationInSeconds defaults + * to 0 which is the default 7 days. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, const char* signerName, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0); - Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, - const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; + Aws::String GeneratePresignedUrl(const Aws::Endpoint::AWSEndpoint& endpoint, + Aws::Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const Aws::Http::HeaderValueCollection& customizedHeaders = {}, + uint64_t expirationInSeconds = 0, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr); + + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, const Aws::Http::URI& uri, Aws::Http::HttpMethod method, + const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; + + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, + const char* signerName, const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; + + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, + const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; + + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, + const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const; /** * Stop all requests immediately. @@ -175,11 +189,11 @@ namespace Aws * or encounters and error that is not retryable. */ HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod httpMethod, - const char* signerName, - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod httpMethod, + const char* signerName, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; /** * Calls AttemptOneRequest until it either, succeeds, runs out of retries from the retry strategy, @@ -189,45 +203,45 @@ namespace Aws * name. */ HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri, - Http::HttpMethod httpMethod, - const char* signerName, - const char* requestName = "", - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; + Http::HttpMethod httpMethod, + const char* signerName, + const char* requestName = "", + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; /** - * Build an Http Request from the AmazonWebServiceRequest object. Signs the request, sends it accross the wire + * Build an Http Request from the AmazonWebServiceRequest object. Signs the request, sends it across the wire * then reports the http response. */ HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest, - const Aws::AmazonWebServiceRequest& request, - const char* signerName, - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; + const Aws::AmazonWebServiceRequest& request, + const char* signerName, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; /** - * Signs an Http Request, sends it accross the wire + * Signs an Http Request, sends it across the wire * then reports the http response. This method is for payloadless requests e.g. GET, DELETE, HEAD * * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid * name. */ HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest, - const char* signerName, - const char* requestName = "", - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; + const char* signerName, + const char* requestName = "", + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; /** * This is used for structureless response payloads (file streams, binary data etc...). It calls AttemptExhaustively, but upon * return transfers ownership of the underlying stream for the http response to the caller. */ StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; /** * This is used for structureless response payloads (file streams, binary data etc...). It calls AttemptExhaustively, but upon @@ -237,11 +251,18 @@ namespace Aws * name. */ StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, - const char* requestName = "", - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* requestName = "", + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + StreamOutcome MakeRequestWithUnparsedResponse(const Aws::AmazonWebServiceRequest& request, + const Aws::Endpoint::AWSEndpoint& endpoint, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; /** * Abstract. Subclassing clients should override this to tell the client how to marshall error payloads @@ -252,7 +273,7 @@ namespace Aws * Transforms the AmazonWebServicesResult object into an HttpRequest. */ virtual void BuildHttpRequest(const Aws::AmazonWebServiceRequest& request, - const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest) const; + const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest) const; /** * Gets the underlying ErrorMarshaller for subclasses to use. @@ -266,6 +287,8 @@ namespace Aws * Gets the corresponding signer from the signers map by name. */ Aws::Client::AWSAuthSigner* GetSignerByName(const char* name) const; + + friend Aws::Client::AWSAuthSigner* AWSUrlPresigner::GetSignerByName(const char* name) const; protected: /** @@ -276,14 +299,24 @@ namespace Aws * event-streams. */ std::shared_ptr<Aws::Http::HttpRequest> BuildAndSignHttpRequest(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method, const char* signerName) const; + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method, const char* signerName) const; /** * Performs the HTTP request via the HTTP client while enforcing rate limiters */ std::shared_ptr<Aws::Http::HttpResponse> MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const; Aws::String m_region; + + /** + * Adds "X-Amzn-Trace-Id" header with the value of _X_AMZN_TRACE_ID if both + * environment variables AWS_LAMBDA_FUNCTION_NAME and _X_AMZN_TRACE_ID are set. + * Does not add/modify header "X-Amzn-Trace-Id" if it is already set. + */ + static void AppendRecursionDetectionHeader(std::shared_ptr<Aws::Http::HttpRequest> ioRequest); + + static CoreErrors GuessBodylessErrorType(Aws::Http::HttpResponseCode responseCode); + static bool DoesResponseGenerateError(const std::shared_ptr<Aws::Http::HttpResponse>& response); private: /** * Try to adjust signer's clock @@ -291,12 +324,11 @@ namespace Aws */ bool AdjustClockSkew(HttpResponseOutcome& outcome, const char* signerName) const; void AddHeadersToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const Http::HeaderValueCollection& headerValues) const; + void AddChecksumToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& HttpRequest, const Aws::AmazonWebServiceRequest& request) const; void AddContentBodyToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const std::shared_ptr<Aws::IOStream>& body, bool needsContentMd5 = false, bool isChunked = false) const; void AddCommonHeaders(Aws::Http::HttpRequest& httpRequest) const; - void InitializeGlobalStatics(); - std::shared_ptr<Aws::Http::HttpRequest> ConvertToRequestForPresigning(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, - Aws::Http::HttpMethod method, const Aws::Http::QueryStringParameterCollection& extraParams) const; + std::shared_ptr<Aws::IOStream> GetBodyStream(const Aws::AmazonWebServiceRequest& request) const; std::shared_ptr<Aws::Http::HttpClient> m_httpClient; std::shared_ptr<Aws::Auth::AWSAuthSignerProvider> m_signerProvider; @@ -310,154 +342,19 @@ namespace Aws long m_requestTimeoutMs; bool m_enableClockSkewAdjustment; Aws::String m_serviceName; + Aws::Client::RequestCompressionConfig m_requestCompressionConfig; + void AppendHeaderValueToRequest( + const std::shared_ptr<Http::HttpRequest> &request, String header, + String value) const; }; - typedef Utils::Outcome<AmazonWebServiceResult<Utils::Json::JsonValue>, AWSError<CoreErrors>> JsonOutcome; AWS_CORE_API Aws::String GetAuthorizationHeader(const Aws::Http::HttpRequest& httpRequest); - - /** - * AWSClient that handles marshalling json response bodies. You would inherit from this class - * to create a client that uses Json as its payload format. - */ - class AWS_CORE_API AWSJsonClient : public AWSClient - { - public: - typedef AWSClient BASECLASS; - - /** - * Simply calls AWSClient constructor. - */ - AWSJsonClient(const Aws::Client::ClientConfiguration& configuration, - const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer, - const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); - - /** - * Simply calls AWSClient constructor. - */ - AWSJsonClient(const Aws::Client::ClientConfiguration& configuration, - const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider, - const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); - - virtual ~AWSJsonClient() = default; - - protected: - /** - * Converts/Parses an http response into a meaningful AWSError object using the json message structure. - */ - virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override; - - /** - * Returns a Json document or an error from the request. Does some marshalling json and raw streams, - * then just calls AttemptExhaustively. - * - * method defaults to POST - */ - JsonOutcome MakeRequest(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; - - /** - * Returns a Json document or an error from the request. Does some marshalling json and raw streams, - * then just calls AttemptExhaustively. - * - * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid - * name. - * - * method defaults to POST - */ - JsonOutcome MakeRequest(const Aws::Http::URI& uri, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, - const char* requestName = "", - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; - - JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const; - }; - - typedef Utils::Outcome<AmazonWebServiceResult<Utils::Xml::XmlDocument>, AWSError<CoreErrors>> XmlOutcome; - - /** - * AWSClient that handles marshalling xml response bodies. You would inherit from this class - * to create a client that uses Xml as its payload format. - */ - class AWS_CORE_API AWSXMLClient : public AWSClient - { - public: - - typedef AWSClient BASECLASS; - - AWSXMLClient(const Aws::Client::ClientConfiguration& configuration, - const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer, - const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); - - AWSXMLClient(const Aws::Client::ClientConfiguration& configuration, - const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider, - const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); - - virtual ~AWSXMLClient() = default; - - protected: - /** - * Converts/Parses an http response into a meaningful AWSError object. Using the XML message structure. - */ - virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override; - - /** - * Returns an xml document or an error from the request. Does some marshalling xml and raw streams, - * then just calls AttemptExhaustively. - * - * method defaults to POST - */ - XmlOutcome MakeRequest(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; - - - /** - * Returns an xml document or an error from the request. Does some marshalling xml and raw streams, - * then just calls AttemptExhaustively. - * - * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid - * name. - * - * method defaults to POST - */ - XmlOutcome MakeRequest(const Aws::Http::URI& uri, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, - const char* requestName = "", - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; - - /** - * This is used for event stream response. - */ - XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, - const Aws::AmazonWebServiceRequest& request, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* singerName = Aws::Auth::SIGV4_SIGNER, - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; - - /** - * This is used for event stream response. - * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid - * name. - */ - XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, - Http::HttpMethod method = Http::HttpMethod::HTTP_POST, - const char* signerName = Aws::Auth::SIGV4_SIGNER, - const char* requestName = "", - const char* signerRegionOverride = nullptr, - const char* signerServiceNameOverride = nullptr) const; - }; - } // namespace Client } // namespace Aws + +#if !defined(AWS_JSON_CLIENT_H) && !defined(AWS_XML_CLIENT_H) +/* Legacy backward compatibility macros to not break the build for ones including just AWSClient.h */ +#include <aws/core/client/AWSJsonClient.h> +#include <aws/core/client/AWSXmlClient.h> +#endif // !defined(AWS_JSON_CLIENT_H) && !defined(AWS_XML_CLIENT_H) +#endif // !defined(AWS_CLIENT_H)
\ No newline at end of file diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClientAsyncCRTP.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClientAsyncCRTP.h new file mode 100644 index 0000000000..a31b1c1783 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClientAsyncCRTP.h @@ -0,0 +1,125 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/client/AWSAsyncOperationTemplate.h> + +namespace Aws +{ +namespace Client +{ + class AsyncCallerContext; + + /** + * A helper to determine if AWS Operation is EventStream-enabled or not (based on const-ness of the request) + */ + template<typename T> + struct AWS_CORE_LOCAL IsEventStreamOperation : IsEventStreamOperation<decltype(&T::operator())> {}; + + template<typename ReturnT, typename ClassT, typename RequestT> + struct AWS_CORE_LOCAL IsEventStreamOperation<ReturnT(ClassT::*)(RequestT) const> + { + static const bool value = !std::is_const<typename std::remove_reference<RequestT>::type>::value; + }; + + template<typename ReturnT, typename ClassT> + struct AWS_CORE_LOCAL IsEventStreamOperation<ReturnT(ClassT::*)() const> + { + static const bool value = false; + }; + + + /** + * A CRTP-base class template that is used to add template methods to call AWS Operations in parallel using ThreadExecutor + * An Aws<Service>Client is going to inherit from this class and will get methods below available. + */ + template <typename AwsServiceClientT> + class ClientWithAsyncTemplateMethods + { + public: + /** + * A template to submit a AwsServiceClient regular operation method for async execution. + * This template method copies and queues the request into a thread executor and triggers associated callback when operation has finished. + */ + template<typename RequestT, typename HandlerT, typename OperationFuncT, typename std::enable_if<!IsEventStreamOperation<OperationFuncT>::value, int>::type = 0> + void SubmitAsync(OperationFuncT operationFunc, + const RequestT& request, + const HandlerT& handler, + const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const + { + const AwsServiceClientT* clientThis = static_cast<const AwsServiceClientT*>(this); + Aws::Client::MakeAsyncOperation(operationFunc, clientThis, request, handler, context, clientThis->m_executor.get()); + } + + /** + * A template to submit a AwsServiceClient event stream enabled operation method for async execution. + * This template method queues the original request object into a thread executor and triggers associated callback when operation has finished. + * It is caller's responsibility to ensure the lifetime of the original request object for a duration of the async execution. + */ + template<typename RequestT, typename HandlerT, typename OperationFuncT, typename std::enable_if<IsEventStreamOperation<OperationFuncT>::value, int>::type = 0> + void SubmitAsync(OperationFuncT operationFunc, + RequestT& request, // note non-const ref + const HandlerT& handler, + const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const + { + const AwsServiceClientT* clientThis = static_cast<const AwsServiceClientT*>(this); + Aws::Client::MakeAsyncStreamingOperation(operationFunc, clientThis, request, handler, context, clientThis->m_executor.get()); + } + + /** + * A template to submit a AwsServiceClient regular operation method without arguments for async execution. + * This template method submits a task into a thread executor and triggers associated callback when operation has finished. + */ + template<typename HandlerT, typename OperationFuncT> + void SubmitAsync(OperationFuncT operationFunc, + const HandlerT& handler, + const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const + { + const AwsServiceClientT* clientThis = static_cast<const AwsServiceClientT*>(this); + Aws::Client::MakeAsyncOperation(operationFunc, clientThis, handler, context, clientThis->m_executor.get()); + } + + /** + * A template to submit a AwsServiceClient regular operation method for async execution that returns a future<OperationOutcome> object. + * This template method copies and queues the request into a thread executor and returns a future<OperationOutcome> object when operation has finished. + */ + template<typename RequestT, typename OperationFuncT, typename std::enable_if<!IsEventStreamOperation<OperationFuncT>::value, int>::type = 0> + auto SubmitCallable(OperationFuncT operationFunc, + const RequestT& request) const + -> std::future<decltype((static_cast<const AwsServiceClientT*>(nullptr)->*operationFunc)(request))> + { + const AwsServiceClientT* clientThis = static_cast<const AwsServiceClientT*>(this); + return Aws::Client::MakeCallableOperation(AwsServiceClientT::ALLOCATION_TAG, operationFunc, clientThis, request, clientThis->m_executor.get()); + } + + /** + * A template to submit a AwsServiceClient event stream enabled operation method for async execution that returns a future<OperationOutcome> object. + * This template method queues the original request into a thread executor and returns a future<OperationOutcome> object when operation has finished. + * It is caller's responsibility to ensure the lifetime of the original request object for a duration of the async execution. + */ + template<typename RequestT, typename OperationFuncT, typename std::enable_if<IsEventStreamOperation<OperationFuncT>::value, int>::type = 0> + auto SubmitCallable(OperationFuncT operationFunc, /*note non-const ref*/ RequestT& request) const + -> std::future<decltype((static_cast<const AwsServiceClientT*>(nullptr)->*operationFunc)(request))> + { + const AwsServiceClientT* clientThis = static_cast<const AwsServiceClientT*>(this); + return Aws::Client::MakeCallableStreamingOperation(AwsServiceClientT::ALLOCATION_TAG, operationFunc, clientThis, request, clientThis->m_executor.get()); + } + + /** + * A template to submit a AwsServiceClient regular operation without request argument for + * an async execution that returns a future<OperationOutcome> object. + * This template method copies and queues the request into a thread executor and returns a future<OperationOutcome> object when operation has finished. + */ + template<typename OperationFuncT> + auto SubmitCallable(OperationFuncT operationFunc) const + -> std::future<decltype((static_cast<const AwsServiceClientT*>(nullptr)->*operationFunc)())> + { + const AwsServiceClientT* clientThis = static_cast<const AwsServiceClientT*>(this); + return Aws::Client::MakeCallableOperation(AwsServiceClientT::ALLOCATION_TAG, operationFunc, clientThis, clientThis->m_executor.get()); + } + }; +} // namespace Client +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h index 39f033c3fc..e9df0be8a2 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h @@ -12,6 +12,13 @@ #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/utils/StringUtils.h> +// TODO: temporary fix for naming conflicts on Windows. +#ifdef _WIN32 +#ifdef GetMessage +#undef GetMessage +#endif +#endif + namespace Aws { namespace Client @@ -41,12 +48,17 @@ namespace Aws /** * Initializes AWSError object as empty with the error not being retryable. */ - AWSError() : m_responseCode(Aws::Http::HttpResponseCode::REQUEST_NOT_MADE), m_isRetryable(false) {} + AWSError() + : m_errorType(), + m_responseCode(Aws::Http::HttpResponseCode::REQUEST_NOT_MADE), + m_isRetryable(false), + m_errorPayloadType(ErrorPayloadType::NOT_SET) + {} /** * Initializes AWSError object with errorType, exceptionName, message, and retryable flag. */ - AWSError(ERROR_TYPE errorType, Aws::String exceptionName, const Aws::String message, bool isRetryable) : - m_errorType(errorType), m_exceptionName(exceptionName), m_message(message), + AWSError(ERROR_TYPE errorType, Aws::String exceptionName, Aws::String message, bool isRetryable) + : m_errorType(errorType), m_exceptionName(std::move(exceptionName)), m_message(std::move(message)), m_responseCode(Aws::Http::HttpResponseCode::REQUEST_NOT_MADE), m_isRetryable(isRetryable), m_errorPayloadType(ErrorPayloadType::NOT_SET) {} /** @@ -85,7 +97,7 @@ namespace Aws /** * Move assignment operator */ - AWSError& operator=(AWSError<ERROR_TYPE>&& other) = default; + AWSError& operator=(AWSError<ERROR_TYPE>&&) = default; /** * Gets underlying errorType. @@ -191,10 +203,10 @@ namespace Aws Aws::String m_remoteHostIpAddress; Aws::String m_requestId; Aws::Http::HeaderValueCollection m_responseHeaders; - Aws::Http::HttpResponseCode m_responseCode; - bool m_isRetryable; + Aws::Http::HttpResponseCode m_responseCode = Aws::Http::HttpResponseCode::REQUEST_NOT_MADE; + bool m_isRetryable = false; - ErrorPayloadType m_errorPayloadType; + ErrorPayloadType m_errorPayloadType = ErrorPayloadType::NOT_SET; Aws::Utils::Xml::XmlDocument m_xmlPayload; Aws::Utils::Json::JsonValue m_jsonPayload; }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSJsonClient.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSJsonClient.h new file mode 100644 index 0000000000..877db0aec5 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSJsonClient.h @@ -0,0 +1,110 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once +#if !defined(AWS_JSON_CLIENT_H) +#define AWS_JSON_CLIENT_H + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/client/AWSClient.h> + +namespace Aws +{ + namespace Utils + { + namespace Json + { + class JsonValue; + } // namespace Json + } // namespace Utils + + namespace Client + { + typedef Utils::Outcome<AmazonWebServiceResult<Utils::Json::JsonValue>, AWSError<CoreErrors>> JsonOutcome; + /** + * AWSClient that handles marshalling json response bodies. You would inherit from this class + * to create a client that uses Json as its payload format. + */ + class AWS_CORE_API AWSJsonClient : public AWSClient + { + public: + typedef AWSClient BASECLASS; + + /** + * Simply calls AWSClient constructor. + */ + AWSJsonClient(const Aws::Client::ClientConfiguration& configuration, + const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer, + const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); + + /** + * Simply calls AWSClient constructor. + */ + AWSJsonClient(const Aws::Client::ClientConfiguration& configuration, + const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider, + const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); + + virtual ~AWSJsonClient() = default; + + protected: + /** + * Converts/Parses an http response into a meaningful AWSError object using the json message structure. + */ + virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override; + + /** + * Returns a Json document or an error from the request. Does some marshalling json and raw streams, + * then just calls AttemptExhaustively. + * + * method defaults to POST + */ + JsonOutcome MakeRequest(const Aws::AmazonWebServiceRequest& request, + const Aws::Endpoint::AWSEndpoint& endpoint, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + JsonOutcome MakeRequest(const Aws::Endpoint::AWSEndpoint& endpoint, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + /** + * Returns a Json document or an error from the request. Does some marshalling json and raw streams, + * then just calls AttemptExhaustively. + * + * method defaults to POST + */ + JsonOutcome MakeRequest(const Aws::Http::URI& uri, + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + /** + * Returns a Json document or an error from the request. Does some marshalling json and raw streams, + * then just calls AttemptExhaustively. + * + * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid + * name. + * + * method defaults to POST + */ + JsonOutcome MakeRequest(const Aws::Http::URI& uri, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* requestName = "", + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const; + }; + } // namespace Client +} // namespace Aws + +#endif // !defined(AWS_JSON_CLIENT_H)
\ No newline at end of file diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSUrlPresigner.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSUrlPresigner.h new file mode 100644 index 0000000000..01601c1eb1 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSUrlPresigner.h @@ -0,0 +1,176 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/AmazonWebServiceRequest.h> +#include <aws/core/endpoint/AWSEndpoint.h> + +#include <aws/core/utils/memory/stl/AWSString.h> + +namespace Aws +{ + namespace Client + { + class AWSClient; + + /** + * Helper class to generate pre-signed AWS URLs. + */ + class AWS_CORE_API AWSUrlPresigner + { + public: + AWSUrlPresigner(const AWSClient& client); + + virtual ~AWSUrlPresigner() {}; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri and http method. expirationInSeconds defaults + * to 0 which is the default 7 days. The implication of this function is using auth signer v4 to sign it. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri, http method, and customized headers. expirationInSeconds defaults + * to 0 which is the default 7 days. The implication of this function is using auth signer v4 to sign it. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const Aws::Http::HeaderValueCollection &customizedHeaders, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri, http method, and region. expirationInSeconds defaults + * to 0 which is the default 7 days. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri, http method, and customized headers. expirationInSeconds defaults + * to 0 which is the default 7 days. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const Aws::Http::HeaderValueCollection &customizedHeaders, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri, http method, region, and service name. expirationInSeconds defaults + * to 0 which is the default 7 days. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const char *serviceNameOverride, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri, http method, and customized headers. expirationInSeconds defaults + * to 0 which is the default 7 days. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const char *serviceNameOverride, + const Aws::Http::HeaderValueCollection &customizedHeaders, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri, http method, region, service name, and signer name. expirationInSeconds defaults + * to 0 which is the default 7 days. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const char *serviceNameOverride, + const char *signerName, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer, for the supplied uri, http method, region, service name, signer name, and customized headers. expirationInSeconds defaults + * to 0 which is the default 7 days. + * + * This is a real method for uri pre-signing, the rest are just overloads. + */ + Aws::String GeneratePresignedUrl(const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const char *serviceNameOverride, + const char *signerName, + const Aws::Http::HeaderValueCollection &customizedHeaders, + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri for a supplied AWSEndpoint. + */ + Aws::String GeneratePresignedUrl(const Aws::Endpoint::AWSEndpoint &endpoint, + Aws::Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const Aws::Http::HeaderValueCollection &customizedHeaders = {}, + uint64_t expirationInSeconds = 0, + const char *signerName = Aws::Auth::SIGV4_SIGNER, + const char *signerRegionOverride = nullptr, + const char *signerServiceNameOverride = nullptr) const; + + /** + * Generates a signed Uri for a supplied request and uri. + */ + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest &request, + const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const Aws::Http::QueryStringParameterCollection &extraParams = Aws::Http::QueryStringParameterCollection(), + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri using the injected signer. for the supplied request object, uri, http method, region, service name, signer name, and customized headers. + * expirationInSeconds defaults to 0 which is the default 7 days. + * + * This is a real method for request+uri pre-signing, the rest are just overloads. + */ + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest &request, + const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const char *serviceNameOverride, + const char *signerName, + const Aws::Http::QueryStringParameterCollection &extraParams = Aws::Http::QueryStringParameterCollection(), + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri for a supplied request and uri. + */ + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest &request, + const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const char *serviceNameOverride, + const Aws::Http::QueryStringParameterCollection &extraParams = Aws::Http::QueryStringParameterCollection(), + long long expirationInSeconds = 0) const; + + /** + * Generates a signed Uri for a supplied request and uri. + */ + Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest &request, + const Aws::Http::URI &uri, + Aws::Http::HttpMethod method, + const char *regionOverride, + const Aws::Http::QueryStringParameterCollection &extraParams = Aws::Http::QueryStringParameterCollection(), + long long expirationInSeconds = 0) const; + + protected: + const AWSClient& m_awsClient; + + friend class AWSClient; // allow AWSClient to see method below to make friends with it + Aws::Client::AWSAuthSigner* GetSignerByName(const char* name) const; + }; // class AWSUrlPresigner + + } // namespace Client +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSXmlClient.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSXmlClient.h new file mode 100644 index 0000000000..1d3426e6e8 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSXmlClient.h @@ -0,0 +1,135 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once +#if !defined(AWS_XML_CLIENT_H) +#define AWS_XML_CLIENT_H + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/client/AWSClient.h> + +namespace Aws +{ + namespace Utils + { + namespace Xml + { + class XmlDocument; + } // namespace Xml + } // namespace Utils + + namespace Client + { + typedef Utils::Outcome<AmazonWebServiceResult<Utils::Xml::XmlDocument>, AWSError<CoreErrors>> XmlOutcome; + + /** + * AWSClient that handles marshalling xml response bodies. You would inherit from this class + * to create a client that uses Xml as its payload format. + */ + class AWS_CORE_API AWSXMLClient : public AWSClient + { + public: + typedef AWSClient BASECLASS; + + AWSXMLClient(const Aws::Client::ClientConfiguration& configuration, + const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer, + const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); + + AWSXMLClient(const Aws::Client::ClientConfiguration& configuration, + const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider, + const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller); + + virtual ~AWSXMLClient() = default; + + protected: + /** + * Converts/Parses an http response into a meaningful AWSError object. Using the XML message structure. + */ + virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override; + + /** + * Returns an xml document or an error from the request. Does some marshalling xml and raw streams, + * then just calls AttemptExhaustively. + * + * method defaults to POST + */ + XmlOutcome MakeRequest(const Aws::AmazonWebServiceRequest& request, + const Aws::Endpoint::AWSEndpoint& endpoint, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + XmlOutcome MakeRequest(const Aws::Endpoint::AWSEndpoint& endpoint, + const char* requestName = "", + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + /** + * Returns an xml document or an error from the request. Does some marshalling xml and raw streams, + * then just calls AttemptExhaustively. + * + * method defaults to POST + */ + XmlOutcome MakeRequest(const Aws::Http::URI& uri, + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + + /** + * Returns an xml document or an error from the request. Does some marshalling xml and raw streams, + * then just calls AttemptExhaustively. + * + * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid + * name. + * + * method defaults to POST + */ + XmlOutcome MakeRequest(const Aws::Http::URI& uri, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* requestName = "", + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + /** + * This is used for event stream response. + */ + XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, + const Aws::AmazonWebServiceRequest& request, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* singerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + XmlOutcome MakeRequestWithEventStream(const Aws::AmazonWebServiceRequest& request, + const Aws::Endpoint::AWSEndpoint& endpoint, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + + /** + * This is used for event stream response. + * requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid + * name. + */ + XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri, + Http::HttpMethod method = Http::HttpMethod::HTTP_POST, + const char* signerName = Aws::Auth::SIGV4_SIGNER, + const char* requestName = "", + const char* signerRegionOverride = nullptr, + const char* signerServiceNameOverride = nullptr) const; + }; + + } // namespace Client +} // namespace Aws + +#endif // !defined(AWS_XML_CLIENT_H)
\ No newline at end of file diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AdaptiveRetryStrategy.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AdaptiveRetryStrategy.h new file mode 100644 index 0000000000..b0a51126cd --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AdaptiveRetryStrategy.h @@ -0,0 +1,154 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/client/RetryStrategy.h> +#include <aws/core/utils/DateTime.h> + +namespace Aws +{ +namespace Client +{ + +/** + * A helper class of the AdaptiveRetryStrategy + * representing a (send) token bucket with a dynamically changing fill rate and capacity. + */ +class AWS_CORE_API RetryTokenBucket +{ +public: + /** + * C-tor + */ + RetryTokenBucket() = default; + + /** + * Acquire tokens from the bucket. If the bucket contains enough capacity + * to satisfy the request, this method will return immediately, otherwise + * the method will block the calling thread until enough tokens are refilled + * unless fast fail is provided as an argument. + */ + bool Acquire(size_t amount = 1, bool fastFail = false); + + /** + * Update limiter's client sending rate during the request bookkeeping process + * based on a service response. + */ + void UpdateClientSendingRate(bool throttlingResponse, const Aws::Utils::DateTime& now = Aws::Utils::DateTime::Now()); + +protected: + /** + * Internal C-tor for unit testing + */ + RetryTokenBucket(double fillRate, double maxCapacity, double currentCapacity, + const Aws::Utils::DateTime& lastTimestamp, double measuredTxRate, double lastTxRateBucket, + size_t requestCount, bool enabled, double lastMaxRate, const Aws::Utils::DateTime& lastThrottleTime); + + /** + * Internal method to update the token bucket's fill rate when we receive a response from the service. + * The update amount will depend on whether or not a throttling response is received from a service. + * The request rate is measured using an exponentially smoothed average, + * with the rate being updated in half second buckets. + */ + void UpdateMeasuredRate(const Aws::Utils::DateTime& now = Aws::Utils::DateTime::Now()); + + /** + * Internal method to enable rate limiting. + */ + void Enable(); + + /** + * Internal method to refill and update refill rate with a new refill rate. + */ + void UpdateRate(double newRps, const Aws::Utils::DateTime& now = Aws::Utils::DateTime::Now()); + + /** + * Internal method to refill send tokens based on a current fill rate. + */ + void Refill(const Aws::Utils::DateTime& now = Aws::Utils::DateTime::Now()); + + /** + * Internal method to compute time window for a last max fill rate. + */ + double CalculateTimeWindow() const; + + /** + * Internal method with a modified CUBIC algorithm to compute new max sending rate for a successful response. + */ + double CUBICSuccess(const Aws::Utils::DateTime& timestamp, const double timeWindow) const; + + /** + * Internal method with a modified CUBIC algorithm to compute new max sending rate for a throttled response. + */ + double CUBICThrottle(const double rateToUse) const; + + // The rate at which token are replenished. + double m_fillRate = 0.0; + // The maximum capacity allowed in the token bucket. + double m_maxCapacity = 0.0; + // The current capacity of the token bucket. + double m_currentCapacity = 0.0; + // The last time the token bucket was refilled. + Aws::Utils::DateTime m_lastTimestamp; + // The smoothed rate which tokens are being retrieved. + double m_measuredTxRate = 0.0; + // The last half second time bucket used. + double m_lastTxRateBucket = 0.0; + // The number of requests seen within the current time bucket. + size_t m_requestCount = 0; + // Boolean indicating if the token bucket is enabled. + bool m_enabled = false; + // The maximum rate when the client was last throttled. + double m_lastMaxRate = 0.0; + // The last time when the client was throttled. + Aws::Utils::DateTime m_lastThrottleTime; + + // TokenBucket's mutex to synchronize read/write operations + std::recursive_mutex m_mutex; +}; + +/** + * A retry strategy that builds on the standard strategy and introduces congestion control through + * client side rate limiting. + */ +class AWS_CORE_API AdaptiveRetryStrategy : public StandardRetryStrategy +{ +public: + /** + * C-tors + */ + AdaptiveRetryStrategy(long maxAttempts = 3); + AdaptiveRetryStrategy(std::shared_ptr<RetryQuotaContainer> retryQuotaContainer, long maxAttempts = 3); + + /** + * Retrieve and consume a send token. + * Returns true if send token is available. + * + * If there is not sufficient capacity, HasSendToken() will either sleep a certain amount of time until the rate + * limiter can retrieve a token from its token bucket or return false indicating there is insufficient capacity. + */ + virtual bool HasSendToken() override; + + /** + * Update status, like the information of retry quota when receiving a response. + */ + virtual void RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome) override; + virtual void RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome, const AWSError<CoreErrors>& lastError) override; + +protected: + RetryTokenBucket m_retryTokenBucket; + bool m_fastFail = false; + +private: + /** + * An internal helper function to check if a given service response is classified as a throttled one. + */ + static bool IsThrottlingResponse(const HttpResponseOutcome& httpResponseOutcome); +}; + +} // namespace Client +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AsyncCallerContext.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AsyncCallerContext.h index 6831791ffc..03ebca5151 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AsyncCallerContext.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AsyncCallerContext.h @@ -33,11 +33,11 @@ namespace Aws * Initializes object with UUID */ AsyncCallerContext(const char* uuid) : m_uuid(uuid) {} - + virtual ~AsyncCallerContext() {} /** - * Gets underlying UUID + * Gets underlying UUID */ inline const Aws::String& GetUUID() const { return m_uuid; } @@ -56,4 +56,3 @@ namespace Aws }; } } - diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h index 69c2166a6e..b8e32b5fe4 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h @@ -11,6 +11,7 @@ #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/http/HttpTypes.h> #include <aws/core/utils/Array.h> +#include <aws/crt/Optional.h> #include <memory> namespace Aws @@ -45,6 +46,20 @@ namespace Aws }; /** + * This setting is an enumeration, not a boolean, to allow for future expansion. + */ + enum class UseRequestCompression + { + DISABLE, + ENABLE, + }; + + struct RequestCompressionConfig { + UseRequestCompression useRequestCompression=UseRequestCompression::ENABLE; + size_t requestMinCompressionSizeBytes = 10240; + }; + + /** * This mutable structure is used to configure any of the AWS clients. * Default values can only be overwritten prior to passing to the client constructors. */ @@ -55,8 +70,18 @@ namespace Aws /** * Create a configuration based on settings in the aws configuration file for the given profile name. * The configuration file location can be set via the environment variable AWS_CONFIG_FILE + * @param profileName the aws profile name. + * @param shouldDisableIMDS whether or not to disable IMDS calls. */ - ClientConfiguration(const char* profileName); + ClientConfiguration(const char* profileName, bool shouldDisableIMDS = false); + + /** + * Create a configuration with a predefined smart defaults + * @param useSmartDefaults, required to differentiate c-tors + * @param defaultMode, default mode to use + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + explicit ClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false); /** * User Agent string user for http calls. This is filled in for you in the constructor. Don't override this unless you have a really good reason. @@ -73,47 +98,53 @@ namespace Aws /** * Use dual stack endpoint in the endpoint calculation. It is your responsibility to verify that the service supports ipv6 in the region you select. */ - bool useDualStack; + bool useDualStack = false; + + /** + * Use FIPS endpoint in the endpoint calculation. Please check first that the service supports FIPS in a selected region. + */ + bool useFIPS = false; + /** * Max concurrent tcp connections for a single http client to use. Default 25. */ - unsigned maxConnections; + unsigned maxConnections = 25; /** * This is currently only applicable for Curl to set the http request level timeout, including possible dns lookup time, connection establish time, ssl handshake time and actual data transmission time. * the corresponding Curl option is CURLOPT_TIMEOUT_MS * defaults to 0, no http request level timeout. */ - long httpRequestTimeoutMs; + long httpRequestTimeoutMs = 0; /** - * Socket read timeouts for HTTP clients on Windows. Default 3000 ms. This should be more than adequate for most services. However, if you are transfering large amounts of data + * Socket read timeouts for HTTP clients on Windows. Default 3000 ms. This should be more than adequate for most services. However, if you are transferring large amounts of data * or are worried about higher latencies, you should set to something that makes more sense for your use case. * For Curl, it's the low speed time, which contains the time in number milliseconds that transfer speed should be below "lowSpeedLimit" for the library to consider it too slow and abort. * Note that for Curl this config is converted to seconds by rounding down to the nearest whole second except when the value is greater than 0 and less than 1000. In this case it is set to one second. When it's 0, low speed limit check will be disabled. * Note that for Windows when this config is 0, the behavior is not specified by Windows. */ - long requestTimeoutMs; + long requestTimeoutMs = 0; /** - * Socket connect timeout. Default 1000 ms. Unless you are very far away from your the data center you are talking to. 1000ms is more than sufficient. + * Socket connect timeout. Default 1000 ms. Unless you are very far away from your the data center you are talking to, 1000ms is more than sufficient. */ - long connectTimeoutMs; + long connectTimeoutMs = 1000; /** * Enable TCP keep-alive. Default true; * No-op for WinHTTP, WinINet and IXMLHTTPRequest2 client. */ - bool enableTcpKeepAlive; + bool enableTcpKeepAlive = true; /** * Interval to send a keep-alive packet over the connection. Default 30 seconds. Minimum 15 seconds. * WinHTTP & libcurl support this option. Note that for Curl, this value will be rounded to an integer with second granularity. * No-op for WinINet and IXMLHTTPRequest2 client. */ - unsigned long tcpKeepAliveIntervalMs; + unsigned long tcpKeepAliveIntervalMs = 30000; /** * Average transfer speed in bytes per second that the transfer should be below during the request timeout interval for it to be considered too slow and abort. * Default 1 byte/second. Only for CURL client currently. */ - unsigned long lowSpeedLimit; + unsigned long lowSpeedLimit = 1; /** - * Strategy to use in case of failed requests. Default is DefaultRetryStrategy (e.g. exponential backoff) + * Strategy to use in case of failed requests. Default is DefaultRetryStrategy (i.e. exponential backoff) */ std::shared_ptr<RetryStrategy> retryStrategy; /** @@ -131,7 +162,7 @@ namespace Aws /** * If you have users going through a proxy, set the port here. */ - unsigned proxyPort; + unsigned proxyPort = 0; /** * If you have users going through a proxy, set the username here. */ @@ -175,9 +206,9 @@ namespace Aws std::shared_ptr<Aws::Utils::Threading::Executor> executor; /** * If you need to test and want to get around TLS validation errors, do that here. - * you probably shouldn't use this flag in a production scenario. + * You probably shouldn't use this flag in a production scenario. */ - bool verifySSL; + bool verifySSL = true; /** * If your Certificate Authority path is different from the default, you can tell * clients that aren't using the default trust store where to find your CA trust store. @@ -226,35 +257,73 @@ namespace Aws * But be careful when Http request has large payload such S3 PutObject. You don't want to spend long time sending a large payload just getting a error response for server. * The default value will be false. */ - bool disableExpectHeader; + bool disableExpectHeader = false; /** * If set to true clock skew will be adjusted after each http attempt, default to true. */ - bool enableClockSkewAdjustment; + bool enableClockSkewAdjustment = true; /** * Enable host prefix injection. * For services whose endpoint is injectable. e.g. servicediscovery, you can modify the http host's prefix so as to add "data-" prefix for DiscoverInstances request. * Default to true, enabled. You can disable it for testing purpose. + * + * Deprecated in API v. 1.10. Please set in service-specific client configuration. */ - bool enableHostPrefixInjection; + bool enableHostPrefixInjection = true; /** * Enable endpoint discovery * For some services to dynamically set up their endpoints for different requests. - * Defaults to false, it's an opt-in feature. - * If disabled, regional or overriden endpoint will be used instead. + * By default, service clients will decide if endpoint discovery is enabled or not. + * If disabled, regional or overridden endpoint will be used instead. * If a request requires endpoint discovery but you disabled it. The request will never succeed. + * A boolean value is either true of false, use Optional here to have an instance does not contain a value, + * such that SDK will decide the default behavior as stated before, if no value specified. + * + * Deprecated in API v. 1.10. Please set in service-specific client configuration. */ - bool enableEndpointDiscovery; + Aws::Crt::Optional<bool> enableEndpointDiscovery; /** - * profileName in config file that will be used by this object to reslove more configurations. + * profileName in config file that will be used by this object to resolve more configurations. */ Aws::String profileName; + /** + * Request compression configuration + * To use this feature, the service needs to provide the support, and the compression + * algorithms needs to be available at SDK build time. + */ + Aws::Client::RequestCompressionConfig requestCompressionConfig; + + /** + * Disable all internal IMDS Calls + */ + bool disableIMDS = false; + + /** + * A helper function to read config value from env variable or aws profile config + */ + static Aws::String LoadConfigFromEnvOrProfile(const Aws::String& envKey, + const Aws::String& profile, + const Aws::String& profileProperty, + const Aws::Vector<Aws::String>& allowedValues, + const Aws::String& defaultValue); }; + /** + * A helper function to initialize a retry strategy. + * Default is DefaultRetryStrategy (i.e. exponential backoff) + */ + std::shared_ptr<RetryStrategy> InitRetryStrategy(Aws::String retryMode = ""); + + /** + * A helper function to compute a user agent + * @return Aws::String with a user-agent + */ + AWS_CORE_API Aws::String ComputeUserAgentString(); + } // namespace Client } // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h index 52ebe51c82..08803b5016 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/CoreErrors.h @@ -4,7 +4,8 @@ */ #pragma once -#include "aws/core/Core_EXPORTS.h" +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/memory/stl/AWSStreamFwd.h> namespace Aws { @@ -51,9 +52,16 @@ namespace Aws UNKNOWN = 100, // Unknown to the SDK CLIENT_SIGNING_FAILURE = 101, // Client failed to sign the request USER_CANCELLED = 102, // User cancelled the request - SERVICE_EXTENSION_START_RANGE = 128 + ENDPOINT_RESOLUTION_FAILURE = 103, + SERVICE_EXTENSION_START_RANGE = 128, + OK = -1 // No error set }; + /** + * Overload ostream operator<< for CoreErrors enum class for a prettier output such as "128" + */ + AWS_CORE_API Aws::OStream& operator<< (Aws::OStream& oStream, CoreErrors code); + namespace CoreErrorsMapper { /** diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/GenericClientConfiguration.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/GenericClientConfiguration.h new file mode 100644 index 0000000000..81dda32db9 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/GenericClientConfiguration.h @@ -0,0 +1,86 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/client/ClientConfiguration.h> + +namespace Aws +{ + namespace Client + { + /** + * This mutable structure is used to configure a regular AWS client. + */ + template<bool HasEndpointDiscovery = false> + struct AWS_CORE_API GenericClientConfiguration : public ClientConfiguration + { + static const bool EndpointDiscoverySupported = HasEndpointDiscovery; + + GenericClientConfiguration() + : ClientConfiguration() + {} + + /** + * Create a configuration based on settings in the aws configuration file for the given profile name. + * The configuration file location can be set via the environment variable AWS_CONFIG_FILE + * @param profileName the aws profile name. + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + GenericClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS = false) + : ClientConfiguration(inputProfileName, shouldDisableIMDS) + {} + + /** + * Create a configuration with a predefined smart defaults + * @param useSmartDefaults, required to differentiate c-tors + * @param defaultMode, default mode to use + * @param shouldDisableIMDS whether or not to disable IMDS calls. + */ + explicit GenericClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false) + : ClientConfiguration(useSmartDefaults, defaultMode, shouldDisableIMDS) + {} + + GenericClientConfiguration(const ClientConfiguration& config) + : ClientConfiguration(config) + {} + }; + + /** + * This mutable structure is used to configure a regular AWS client that supports endpoint discovery. + */ + template <> struct AWS_CORE_API GenericClientConfiguration<true> : public ClientConfiguration + { + static const bool EndpointDiscoverySupported = true; + + GenericClientConfiguration(); + GenericClientConfiguration(const char* profileName, bool shouldDisableIMDS = false); + explicit GenericClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false); + GenericClientConfiguration(const ClientConfiguration& config); + GenericClientConfiguration(const GenericClientConfiguration&); + GenericClientConfiguration& operator=(const GenericClientConfiguration&); + + + /** + * Enable host prefix injection. + * For services whose endpoint is injectable. e.g. servicediscovery, you can modify the http host's prefix so as to add "data-" prefix for DiscoverInstances request. + * Default to true, enabled. You can disable it for testing purpose. + */ + bool& enableHostPrefixInjection; + + /** + * Enable endpoint discovery + * For some services to dynamically set up their endpoints for different requests. + * By default, service clients will decide if endpoint discovery is enabled or not. + * If disabled, regional or overridden endpoint will be used instead. + * If a request requires endpoint discovery but you disabled it. The request will never succeed. + * A boolean value is either true of false, use Optional here to have an instance does not contain a value, + * such that SDK will decide the default behavior as stated before, if no value specified. + */ + Aws::Crt::Optional<bool>& enableEndpointDiscovery; + }; + } // namespace Client +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/RequestCompression.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/RequestCompression.h new file mode 100644 index 0000000000..31c0bc98cc --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/RequestCompression.h @@ -0,0 +1,66 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/client/ClientConfiguration.h> +#include <aws/core/utils/Outcome.h> +#include <aws/core/utils/memory/stl/AWSStreamFwd.h> +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSVector.h> + +using iostream_outcome = + Aws::Utils::Outcome<std::shared_ptr<Aws::IOStream>, bool>; + +namespace Aws { +namespace Client { +enum class CompressionAlgorithm { NONE, GZIP }; + +/** + * Converts a compression Algorithms enum to String to be used as content-type + * header value when compressing a request. + * @param algorithm + * @return string with HTTP content type algorithm id + */ +Aws::String AWS_CORE_API +GetCompressionAlgorithmId(const CompressionAlgorithm &algorithm); + +/** + * Request compression API + */ +class AWS_CORE_API RequestCompression final { +public: + /** + * Select the best matching algorithm based in proposed ones, config, length + * of content and the available algorithms. + * @param proposedAlgorithms + * @param config + * @param payloadLength + * @return selected compression algorithm + */ + CompressionAlgorithm + selectAlgorithm(const Aws::Vector<CompressionAlgorithm> &proposedAlgorithms, + const Aws::Client::RequestCompressionConfig &config, + const size_t payloadLength); + /** + * Compress a IOStream input using the requested algorithm. + * @param input + * @param algorithm + * @return IOStream compressed + */ + iostream_outcome compress(std::shared_ptr<Aws::IOStream> input, + const CompressionAlgorithm &algorithm) const; + /** + * Uncompress a IOStream input using the requested algorithm. + * @param input + * @param algorithm + * @return + */ + iostream_outcome uncompress(std::shared_ptr<Aws::IOStream> input, + const CompressionAlgorithm &algorithm) const; +}; +} // namespace Client +} // namespace Aws
\ No newline at end of file diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/RetryStrategy.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/RetryStrategy.h index 930eaa581d..a0b5ea8131 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/RetryStrategy.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/RetryStrategy.h @@ -24,6 +24,8 @@ namespace Aws namespace Client { + static const int NO_RETRY_INCREMENT = 1; + enum class CoreErrors; template<typename ERROR_TYPE> class AWSError; @@ -54,11 +56,20 @@ namespace Aws virtual long GetMaxAttempts() const { return 0; } /** - * Retrives send tokens from the bucket. + * Retrieves send tokens from the bucket. Throws an exception if not available. */ virtual void GetSendToken() {} /** + * Retrieves send tokens from the bucket. Returns true is send token is retrieved. + */ + virtual bool HasSendToken() + { + GetSendToken(); // first call old method for backward compatibility + return true; + } + + /** * Update status, like the information of retry quota when receiving a response. */ virtual void RequestBookkeeping(const HttpResponseOutcome& /* httpResponseOutcome */) {} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSConfigFileProfileConfigLoader.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSConfigFileProfileConfigLoader.h new file mode 100644 index 0000000000..cc778241b6 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSConfigFileProfileConfigLoader.h @@ -0,0 +1,51 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/config/AWSProfileConfigLoaderBase.h> + +#include <aws/core/utils/memory/stl/AWSString.h> + +namespace Aws +{ + namespace Config + { + /** + * Reads configuration from a config file (e.g. $HOME/.aws/config or $HOME/.aws/credentials + */ + class AWS_CORE_API AWSConfigFileProfileConfigLoader : public AWSProfileConfigLoader + { + public: + /** + * fileName - file to load config from + * useProfilePrefix - whether or not the profiles are prefixed with "profile", credentials file is not + * while the config file is. Defaults to off. + */ + AWSConfigFileProfileConfigLoader(const Aws::String& fileName, bool useProfilePrefix = false); + + virtual ~AWSConfigFileProfileConfigLoader() = default; + + /** + * File path being used for the config loader. + */ + const Aws::String& GetFileName() const { return m_fileName; } + + /** + * Give loader the ability to change the file path to load config from. + * This can avoid creating new loader object if the file changed. + */ + void SetFileName(const Aws::String& fileName) { m_fileName = fileName; } + + protected: + virtual bool LoadInternal() override; + virtual bool PersistInternal(const Aws::Map<Aws::String, Aws::Config::Profile>&) override; + + private: + Aws::String m_fileName; + bool m_useProfilePrefix; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfig.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfig.h new file mode 100644 index 0000000000..4f08231d9c --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfig.h @@ -0,0 +1,120 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/auth/AWSCredentials.h> + +namespace Aws +{ + namespace Config + { + /** + * Simple data container for a Profile. + */ + class Profile + { + public: + /* + * Data container for a sso-session config entry. + * This is independent of the general profile configuration and used by a bearer auth token provider. + */ + class SsoSession + { + public: + inline const Aws::String& GetName() const { return m_name; } + inline void SetName(const Aws::String& value) { m_name = value; } + inline const Aws::String& GetSsoRegion() const { return m_ssoRegion; } + inline void SetSsoRegion(const Aws::String& value) { m_ssoRegion = value; } + inline const Aws::String& GetSsoStartUrl() const { return m_ssoStartUrl; } + inline void SetSsoStartUrl(const Aws::String& value) { m_ssoStartUrl = value; } + + inline void SetAllKeyValPairs(const Aws::Map<Aws::String, Aws::String>& map) { m_allKeyValPairs = map; } + inline const Aws::String GetValue(const Aws::String& key) const + { + auto iter = m_allKeyValPairs.find(key); + if (iter == m_allKeyValPairs.end()) return {}; + return iter->second; + } + + bool operator==(SsoSession const& other) const + { + return this->m_name == other.m_name && + this->m_ssoRegion == other.m_ssoRegion && + this->m_ssoStartUrl == other.m_ssoStartUrl && + this->m_allKeyValPairs == other.m_allKeyValPairs; + } + bool operator!=(SsoSession const& other) const + { + return !operator==(other); + } + private: + // This is independent of the general configuration + Aws::String m_name; + Aws::String m_ssoRegion; + Aws::String m_ssoStartUrl; + Aws::Map<Aws::String, Aws::String> m_allKeyValPairs; + }; + + inline const Aws::String& GetName() const { return m_name; } + inline void SetName(const Aws::String& value) { m_name = value; } + inline const Aws::Auth::AWSCredentials& GetCredentials() const { return m_credentials; } + inline void SetCredentials(const Aws::Auth::AWSCredentials& value) { m_credentials = value; } + inline const Aws::String& GetRegion() const { return m_region; } + inline void SetRegion(const Aws::String& value) { m_region = value; } + inline const Aws::String& GetRoleArn() const { return m_roleArn; } + inline void SetRoleArn(const Aws::String& value) { m_roleArn = value; } + inline const Aws::String& GetExternalId() const { return m_externalId; } + inline void SetExternalId(const Aws::String& value) { m_externalId = value; } + inline const Aws::String& GetSsoStartUrl() const { return m_ssoStartUrl; } + inline void SetSsoStartUrl(const Aws::String& value) { m_ssoStartUrl = value; } + inline const Aws::String& GetSsoRegion() const { return m_ssoRegion; } + inline void SetSsoRegion(const Aws::String& value) { m_ssoRegion = value; } + inline const Aws::String& GetSsoAccountId() const { return m_ssoAccountId; } + inline void SetSsoAccountId(const Aws::String& value) { m_ssoAccountId = value; } + inline const Aws::String& GetSsoRoleName() const { return m_ssoRoleName; } + inline void SetSsoRoleName(const Aws::String& value) { m_ssoRoleName = value; } + inline const Aws::String& GetDefaultsMode() const { return m_defaultsMode; } + inline void SetDefaultsMode(const Aws::String& value) { m_defaultsMode = value; } + inline const Aws::String& GetSourceProfile() const { return m_sourceProfile; } + inline void SetSourceProfile(const Aws::String& value ) { m_sourceProfile = value; } + inline const Aws::String& GetCredentialProcess() const { return m_credentialProcess; } + inline void SetCredentialProcess(const Aws::String& value ) { m_credentialProcess = value; } + inline void SetAllKeyValPairs(const Aws::Map<Aws::String, Aws::String>& map) { m_allKeyValPairs = map; } + inline void SetAllKeyValPairs(Aws::Map<Aws::String, Aws::String>&& map) { m_allKeyValPairs = std::move(map); } + inline const Aws::String GetValue(const Aws::String& key) const + { + auto iter = m_allKeyValPairs.find(key); + if (iter == m_allKeyValPairs.end()) return {}; + return iter->second; + } + + inline bool IsSsoSessionSet() const { return m_ssoSessionSet; } + inline const SsoSession& GetSsoSession() const { return m_ssoSession; } + inline void SetSsoSession(const SsoSession& value) { m_ssoSessionSet = true; m_ssoSession = value; } + inline void SetSsoSession(SsoSession&& value) { m_ssoSessionSet = true; m_ssoSession = std::move(value); } + + private: + Aws::String m_name; + Aws::String m_region; + Aws::Auth::AWSCredentials m_credentials; + Aws::String m_roleArn; + Aws::String m_externalId; + Aws::String m_sourceProfile; + Aws::String m_credentialProcess; + Aws::String m_ssoStartUrl; + Aws::String m_ssoRegion; + Aws::String m_ssoAccountId; + Aws::String m_ssoRoleName; + Aws::String m_defaultsMode; + Aws::Map<Aws::String, Aws::String> m_allKeyValPairs; + + bool m_ssoSessionSet = false; + SsoSession m_ssoSession; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h index ee467c5640..b9b4bd9e30 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoader.h @@ -1,261 +1,14 @@ -/** +/**AWSProfileConfigLoaderBaseAWSProfileConfigLoader * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once -#include <aws/core/utils/memory/stl/AWSString.h> -#include <aws/core/utils/memory/stl/AWSMap.h> -#include <aws/core/auth/AWSCredentials.h> -#include <aws/core/utils/DateTime.h> -#include <aws/core/utils/threading/ReaderWriterLock.h> +#include <aws/core/config/AWSProfileConfig.h> +#include <aws/core/config/AWSProfileConfigLoaderBase.h> +#include <aws/core/config/AWSConfigFileProfileConfigLoader.h> +#include <aws/core/config/EC2InstanceProfileConfigLoader.h> +#include <aws/core/config/ConfigAndCredentialsCacheManager.h> -namespace Aws -{ - namespace Internal - { - class EC2MetadataClient; - } - - namespace Config - { - /** - * Simple data container for a Profile. - */ - class Profile - { - public: - inline const Aws::String& GetName() const { return m_name; } - inline void SetName(const Aws::String& value) { m_name = value; } - inline const Aws::Auth::AWSCredentials& GetCredentials() const { return m_credentials; } - inline void SetCredentials(const Aws::Auth::AWSCredentials& value) { m_credentials = value; } - inline const Aws::String& GetRegion() const { return m_region; } - inline void SetRegion(const Aws::String& value) { m_region = value; } - inline const Aws::String& GetRoleArn() const { return m_roleArn; } - inline void SetRoleArn(const Aws::String& value) { m_roleArn = value; } - inline const Aws::String& GetExternalId() const { return m_externalId; } - inline void SetExternalId(const Aws::String& value) { m_externalId = value; } - inline const Aws::String& GetSsoStartUrl() const { return m_ssoStartUrl; } - inline void SetSsoStartUrl(const Aws::String& value) { m_ssoStartUrl = value; } - inline const Aws::String& GetSsoRegion() const { return m_ssoRegion; } - inline void SetSsoRegion(const Aws::String& value) { m_ssoRegion = value; } - inline const Aws::String& GetSsoAccountId() const { return m_ssoAccountId; } - inline void SetSsoAccountId(const Aws::String& value) { m_ssoAccountId = value; } - inline const Aws::String& GetSsoRoleName() const { return m_ssoRoleName; } - inline void SetSsoRoleName(const Aws::String& value) { m_ssoRoleName = value; } - inline const Aws::String& GetSourceProfile() const { return m_sourceProfile; } - inline void SetSourceProfile(const Aws::String& value ) { m_sourceProfile = value; } - inline const Aws::String& GetCredentialProcess() const { return m_credentialProcess; } - inline void SetCredentialProcess(const Aws::String& value ) { m_credentialProcess = value; } - inline void SetAllKeyValPairs(const Aws::Map<Aws::String, Aws::String>& map) { m_allKeyValPairs = map; } - inline const Aws::String GetValue(const Aws::String& key) const - { - auto iter = m_allKeyValPairs.find(key); - if (iter == m_allKeyValPairs.end()) return {}; - return iter->second; - } - - private: - Aws::String m_name; - Aws::String m_region; - Aws::Auth::AWSCredentials m_credentials; - Aws::String m_roleArn; - Aws::String m_externalId; - Aws::String m_sourceProfile; - Aws::String m_credentialProcess; - Aws::String m_ssoStartUrl; - Aws::String m_ssoRegion; - Aws::String m_ssoAccountId; - Aws::String m_ssoRoleName; - Aws::Map<Aws::String, Aws::String> m_allKeyValPairs; - }; - - /** - * Loads Configuration such as .aws/config, .aws/credentials or ec2 metadata service. - */ - class AWS_CORE_API AWSProfileConfigLoader - { - public: - virtual ~AWSProfileConfigLoader() = default; - - /** - * Load the configuration - */ - bool Load(); - - /** - * Over writes the entire config source with the newly configured profile data. - */ - bool PersistProfiles(const Aws::Map<Aws::String, Aws::Config::Profile>& profiles); - - /** - * Gets all profiles from the configuration file. - */ - inline const Aws::Map<Aws::String, Aws::Config::Profile>& GetProfiles() const { return m_profiles; }; - - /** - * the timestamp from the last time the profile information was loaded from file. - */ - inline const Aws::Utils::DateTime& LastLoadTime() const { return m_lastLoadTime; } - - using ProfilesContainer = Aws::Map<Aws::String, Aws::Config::Profile>; - - protected: - /** - * Subclasses override this method to implement fetching the profiles. - */ - virtual bool LoadInternal() = 0; - - /** - * Subclasses override this method to implement persisting the profiles. Default returns false. - */ - virtual bool PersistInternal(const Aws::Map<Aws::String, Aws::Config::Profile>&) { return false; } - - ProfilesContainer m_profiles; - Aws::Utils::DateTime m_lastLoadTime; - }; - - /** - * Reads configuration from a config file (e.g. $HOME/.aws/config or $HOME/.aws/credentials - */ - class AWS_CORE_API AWSConfigFileProfileConfigLoader : public AWSProfileConfigLoader - { - public: - /** - * fileName - file to load config from - * useProfilePrefix - whether or not the profiles are prefixed with "profile", credentials file is not - * while the config file is. Defaults to off. - */ - AWSConfigFileProfileConfigLoader(const Aws::String& fileName, bool useProfilePrefix = false); - - virtual ~AWSConfigFileProfileConfigLoader() = default; - - /** - * File path being used for the config loader. - */ - const Aws::String& GetFileName() const { return m_fileName; } - - /** - * Give loader the ability to change the file path to load config from. - * This can avoid creating new loader object if the file changed. - */ - void SetFileName(const Aws::String& fileName) { m_fileName = fileName; } - - protected: - virtual bool LoadInternal() override; - virtual bool PersistInternal(const Aws::Map<Aws::String, Aws::Config::Profile>&) override; - - private: - Aws::String m_fileName; - bool m_useProfilePrefix; - }; - - static const char* const INSTANCE_PROFILE_KEY = "InstanceProfile"; - - /** - * Loads configuration from the EC2 Metadata Service - */ - class AWS_CORE_API EC2InstanceProfileConfigLoader : public AWSProfileConfigLoader - { - public: - /** - * If client is nullptr, the default EC2MetadataClient will be created. - */ - EC2InstanceProfileConfigLoader(const std::shared_ptr<Aws::Internal::EC2MetadataClient>& = nullptr); - - virtual ~EC2InstanceProfileConfigLoader() = default; - - protected: - virtual bool LoadInternal() override; - private: - std::shared_ptr<Aws::Internal::EC2MetadataClient> m_ec2metadataClient; - }; - - /** - * Stores the contents of config file and credentials file to avoid multiple file readings. - * At the same time provides the flexibility to reload from file. - */ - class AWS_CORE_API ConfigAndCredentialsCacheManager - { - public: - ConfigAndCredentialsCacheManager(); - - void ReloadConfigFile(); - - void ReloadCredentialsFile(); - - bool HasConfigProfile(const Aws::String& profileName) const; - - /** - * Returns cached config profile with the specified profile name. - * Using copy instead of const reference to avoid reading bad contents due to thread contention. - */ - Aws::Config::Profile GetConfigProfile(const Aws::String& profileName) const; - - /** - * Returns cached config profiles - * Using copy instead of const reference to avoid reading bad contents due to thread contention. - */ - Aws::Map<Aws::String, Aws::Config::Profile> GetConfigProfiles() const; - - /** - * Returns cached config value with the specified profile name and key. - * Using copy instead of const reference to avoid reading bad contents due to thread contention. - */ - Aws::String GetConfig(const Aws::String& profileName, const Aws::String& key) const; - - bool HasCredentialsProfile(const Aws::String& profileName) const; - /** - * Returns cached credentials profile with the specified profile name. - * Using copy instead of const reference to avoid reading bad contents due to thread contention. - */ - Aws::Config::Profile GetCredentialsProfile(const Aws::String& profileName) const; - - /** - * Returns cached credentials profiles. - * Using copy instead of const reference to avoid reading bad contents due to thread contention. - */ - Aws::Map<Aws::String, Aws::Config::Profile> GetCredentialsProfiles() const; - - /** - * Returns cached credentials with the specified profile name. - * Using copy instead of const reference to avoid reading bad contents due to thread contention. - */ - Aws::Auth::AWSCredentials GetCredentials(const Aws::String& profileName) const; - - private: - mutable Aws::Utils::Threading::ReaderWriterLock m_credentialsLock; - Aws::Config::AWSConfigFileProfileConfigLoader m_credentialsFileLoader; - mutable Aws::Utils::Threading::ReaderWriterLock m_configLock; - Aws::Config::AWSConfigFileProfileConfigLoader m_configFileLoader; - }; - - AWS_CORE_API void InitConfigAndCredentialsCacheManager(); - - AWS_CORE_API void CleanupConfigAndCredentialsCacheManager(); - - AWS_CORE_API void ReloadCachedConfigFile(); - - AWS_CORE_API void ReloadCachedCredentialsFile(); - - AWS_CORE_API bool HasCachedConfigProfile(const Aws::String& profileName); - - AWS_CORE_API Aws::Config::Profile GetCachedConfigProfile(const Aws::String& profileName); - - AWS_CORE_API Aws::Map<Aws::String, Aws::Config::Profile> GetCachedConfigProfiles(); - - AWS_CORE_API Aws::String GetCachedConfigValue(const Aws::String& profileName, const Aws::String& key); - - AWS_CORE_API Aws::String GetCachedConfigValue(const Aws::String& key); - - AWS_CORE_API bool HasCachedCredentialsProfile(const Aws::String &profileName); - - AWS_CORE_API Aws::Config::Profile GetCachedCredentialsProfile(const Aws::String& profileName); - - AWS_CORE_API Aws::Auth::AWSCredentials GetCachedCredentials(const Aws::String& profileName); - - AWS_CORE_API Aws::Map<Aws::String, Aws::Config::Profile> GetCachedCredentialsProfiles(); - - } -} +// This is a header that represents old legacy all-in-one header to maintain backward compatibility diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoaderBase.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoaderBase.h new file mode 100644 index 0000000000..8403f8fed0 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfigLoaderBase.h @@ -0,0 +1,71 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/config/AWSProfileConfig.h> + +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/auth/AWSCredentials.h> +#include <aws/core/utils/DateTime.h> +#include <aws/core/utils/threading/ReaderWriterLock.h> + +namespace Aws +{ + namespace Config { + /** + * Loads Configuration such as .aws/config, .aws/credentials or ec2 metadata service. + */ + class AWS_CORE_API AWSProfileConfigLoader + { + public: + virtual ~AWSProfileConfigLoader() = default; + + /** + * Load the configuration + */ + bool Load(); + + /** + * Over writes the entire config source with the newly configured profile data. + */ + bool PersistProfiles(const Aws::Map<Aws::String, Aws::Config::Profile> &profiles); + + /** + * Gets all profiles from the configuration file. + */ + inline const Aws::Map<Aws::String, Aws::Config::Profile> &GetProfiles() const { return m_profiles; }; + + /** + * the timestamp from the last time the profile information was loaded from file. + */ + inline const Aws::Utils::DateTime &LastLoadTime() const { return m_lastLoadTime; } + + using ProfilesContainer = Aws::Map<Aws::String, Aws::Config::Profile>; + + // Delete copy c-tor and assignment operator + AWSProfileConfigLoader() = default; + + AWSProfileConfigLoader(const AWSProfileConfigLoader &) = delete; + + const AWSProfileConfigLoader &operator=(AWSProfileConfigLoader &) = delete; + + protected: + /** + * Subclasses override this method to implement fetching the profiles. + */ + virtual bool LoadInternal() = 0; + + /** + * Subclasses override this method to implement persisting the profiles. Default returns false. + */ + virtual bool PersistInternal(const Aws::Map<Aws::String, Aws::Config::Profile> &) { return false; } + + ProfilesContainer m_profiles; + Aws::Utils::DateTime m_lastLoadTime; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/ConfigAndCredentialsCacheManager.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/ConfigAndCredentialsCacheManager.h new file mode 100644 index 0000000000..12470b4087 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/ConfigAndCredentialsCacheManager.h @@ -0,0 +1,104 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/config/AWSProfileConfigLoader.h> + +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/auth/AWSCredentials.h> +#include <aws/core/utils/threading/ReaderWriterLock.h> + +namespace Aws +{ + namespace Config + { + /** + * Stores the contents of config file and credentials file to avoid multiple file readings. + * At the same time provides the flexibility to reload from file. + */ + class AWS_CORE_API ConfigAndCredentialsCacheManager + { + public: + ConfigAndCredentialsCacheManager(); + + void ReloadConfigFile(); + + void ReloadCredentialsFile(); + + bool HasConfigProfile(const Aws::String& profileName) const; + + /** + * Returns cached config profile with the specified profile name. + * Using copy instead of const reference to avoid reading bad contents due to thread contention. + */ + Aws::Config::Profile GetConfigProfile(const Aws::String& profileName) const; + + /** + * Returns cached config profiles + * Using copy instead of const reference to avoid reading bad contents due to thread contention. + */ + Aws::Map<Aws::String, Aws::Config::Profile> GetConfigProfiles() const; + + /** + * Returns cached config value with the specified profile name and key. + * Using copy instead of const reference to avoid reading bad contents due to thread contention. + */ + Aws::String GetConfig(const Aws::String& profileName, const Aws::String& key) const; + + bool HasCredentialsProfile(const Aws::String& profileName) const; + /** + * Returns cached credentials profile with the specified profile name. + * Using copy instead of const reference to avoid reading bad contents due to thread contention. + */ + Aws::Config::Profile GetCredentialsProfile(const Aws::String& profileName) const; + + /** + * Returns cached credentials profiles. + * Using copy instead of const reference to avoid reading bad contents due to thread contention. + */ + Aws::Map<Aws::String, Aws::Config::Profile> GetCredentialsProfiles() const; + + /** + * Returns cached credentials with the specified profile name. + * Using copy instead of const reference to avoid reading bad contents due to thread contention. + */ + Aws::Auth::AWSCredentials GetCredentials(const Aws::String& profileName) const; + + private: + mutable Aws::Utils::Threading::ReaderWriterLock m_credentialsLock; + Aws::Config::AWSConfigFileProfileConfigLoader m_credentialsFileLoader; + mutable Aws::Utils::Threading::ReaderWriterLock m_configLock; + Aws::Config::AWSConfigFileProfileConfigLoader m_configFileLoader; + }; + + AWS_CORE_API void InitConfigAndCredentialsCacheManager(); + + AWS_CORE_API void CleanupConfigAndCredentialsCacheManager(); + + AWS_CORE_API void ReloadCachedConfigFile(); + + AWS_CORE_API void ReloadCachedCredentialsFile(); + + AWS_CORE_API bool HasCachedConfigProfile(const Aws::String& profileName); + + AWS_CORE_API Aws::Config::Profile GetCachedConfigProfile(const Aws::String& profileName); + + AWS_CORE_API Aws::Map<Aws::String, Aws::Config::Profile> GetCachedConfigProfiles(); + + AWS_CORE_API Aws::String GetCachedConfigValue(const Aws::String& profileName, const Aws::String& key); + + AWS_CORE_API Aws::String GetCachedConfigValue(const Aws::String& key); + + AWS_CORE_API bool HasCachedCredentialsProfile(const Aws::String &profileName); + + AWS_CORE_API Aws::Config::Profile GetCachedCredentialsProfile(const Aws::String& profileName); + + AWS_CORE_API Aws::Auth::AWSCredentials GetCachedCredentials(const Aws::String& profileName); + + AWS_CORE_API Aws::Map<Aws::String, Aws::Config::Profile> GetCachedCredentialsProfiles(); + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/EC2InstanceProfileConfigLoader.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/EC2InstanceProfileConfigLoader.h new file mode 100644 index 0000000000..ae3a743fc3 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/EC2InstanceProfileConfigLoader.h @@ -0,0 +1,47 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/config/AWSProfileConfigLoaderBase.h> + +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/utils/DateTime.h> +#include <aws/core/utils/threading/ReaderWriterLock.h> + +namespace Aws +{ + namespace Internal + { + class EC2MetadataClient; + } + + namespace Config + { + static const char* const INSTANCE_PROFILE_KEY = "InstanceProfile"; + + /** + * Loads configuration from the EC2 Metadata Service + */ + class AWS_CORE_API EC2InstanceProfileConfigLoader : public AWSProfileConfigLoader + { + public: + /** + * If client is nullptr, the default EC2MetadataClient will be created. + */ + EC2InstanceProfileConfigLoader(const std::shared_ptr<Aws::Internal::EC2MetadataClient>& = nullptr); + + virtual ~EC2InstanceProfileConfigLoader() = default; + + protected: + virtual bool LoadInternal() override; + private: + std::shared_ptr<Aws::Internal::EC2MetadataClient> m_ec2metadataClient; + int64_t credentialsValidUntilMillis = 0; + int64_t calculateRetryTime() const; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/defaults/ClientConfigurationDefaults.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/defaults/ClientConfigurationDefaults.h new file mode 100644 index 0000000000..cbea1ce997 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/config/defaults/ClientConfigurationDefaults.h @@ -0,0 +1,124 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +/** + * Please note that this file is autogenerated. + * The backwards compatibility of the default values provided by new client configuration defaults is not guaranteed; + * the values might change over time. + */ + +#pragma once + +#include <aws/core/client/ClientConfiguration.h> + +namespace Aws +{ + namespace Config + { + namespace Defaults + { + /** + * Set default client configuration parameters per provided default mode + * + * @param clientConfig, a ClientConfiguration to update + * @param defaultMode, requested default mode name + * @param hasEc2MetadataRegion, if ec2 metadata region has been already queried + * @param ec2MetadataRegion, a region resolved by EC2 Instance Metadata service + */ + AWS_CORE_API void SetSmartDefaultsConfigurationParameters(Aws::Client::ClientConfiguration& clientConfig, + const Aws::String& defaultMode, + bool hasEc2MetadataRegion, + const Aws::String& ec2MetadataRegion); + + /** + * Resolve the name of an actual mode for a default mode "auto" + * + * The AUTO mode is an experimental mode that builds on the standard mode. The SDK + * will attempt to discover the execution environment to determine the appropriate + * settings automatically. + * + * Note that the auto detection is heuristics-based and does not guarantee 100% + * accuracy. STANDARD mode will be used if the execution environment cannot be + * determined. The auto detection might query EC2 Instance Metadata service, which + * might introduce latency. Therefore we recommend choosing an explicit + * defaults_mode instead if startup latency is critical to your application. + */ + AWS_CORE_API const char* ResolveAutoClientConfiguration(const Aws::Client::ClientConfiguration& clientConfig, + const Aws::String& ec2MetadataRegion); + + /** + * Default mode "legacy" + * + * The LEGACY mode provides default settings that vary per SDK and were used prior + * to establishment of defaults_mode. + */ + AWS_CORE_API void SetLegacyClientConfiguration(Aws::Client::ClientConfiguration& clientConfig); + + /** + * Default mode "standard" + * + * The STANDARD mode provides the latest recommended default values that should be + * safe to run in most scenarios. + * + * Note that the default values vended from this mode might change as best + * practices may evolve. As a result, it is encouraged to perform tests when + * upgrading the SDK. + */ + AWS_CORE_API void SetStandardClientConfiguration(Aws::Client::ClientConfiguration& clientConfig); + + /** + * Default mode "in-region" + * + * The IN_REGION mode builds on the standard mode and includes optimization + * tailored for applications which call AWS services from within the same AWS + * region. + * + * Note that the default values vended from this mode might change as best + * practices may evolve. As a result, it is encouraged to perform tests when + * upgrading the SDK. + */ + AWS_CORE_API void SetInRegionClientConfiguration(Aws::Client::ClientConfiguration& clientConfig); + + /** + * Default mode "cross-region" + * + * The CROSS_REGION mode builds on the standard mode and includes optimization + * tailored for applications which call AWS services in a different region. + * + * Note that the default values vended from this mode might change as best + * practices may evolve. As a result, it is encouraged to perform tests when + * upgrading the SDK. + */ + AWS_CORE_API void SetCrossRegionClientConfiguration(Aws::Client::ClientConfiguration& clientConfig); + + /** + * Default mode "mobile" + * + * The MOBILE mode builds on the standard mode and includes optimization tailored + * for mobile applications. + * + * Note that the default values vended from this mode might change as best + * practices may evolve. As a result, it is encouraged to perform tests when + * upgrading the SDK. + */ + AWS_CORE_API void SetMobileClientConfiguration(Aws::Client::ClientConfiguration& clientConfig); + + /** + * Internal helper function to resolve smart defaults mode if not provided + * + * @param clientConfig, a ClientConfiguration to update + * @param requestedDefaultMode, requested default mode name + * @param configFileDefaultMode, default mode specified in a config file + * @param hasEc2MetadataRegion, if ec2 metadata region has been already queried + * @param ec2MetadataRegion, a region resolved by EC2 Instance Metadata service + */ + AWS_CORE_API Aws::String ResolveDefaultModeName(const Aws::Client::ClientConfiguration& clientConfig, + Aws::String requestedDefaultMode, + const Aws::String& configFileDefaultMode, + bool hasEc2MetadataRegion, + Aws::String ec2MetadataRegion); + } //namespace Defaults + } //namespace Config +} //namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/AWSEndpoint.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/AWSEndpoint.h new file mode 100644 index 0000000000..311ac71426 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/AWSEndpoint.h @@ -0,0 +1,71 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSMap.h> + +#include <aws/core/endpoint/internal/AWSEndpointAttribute.h> + +namespace Aws +{ + namespace Endpoint + { + /** + * A public type that encapsulates the information about an endpoint + */ + class AWS_CORE_API AWSEndpoint + { + public: + using EndpointAttributes = Internal::Endpoint::EndpointAttributes; + + virtual ~AWSEndpoint() + {}; + + Aws::String GetURL() const; + void SetURL(Aws::String url); + + const Aws::Http::URI& GetURI() const; + void SetURI(Aws::Http::URI uri); + + template<typename T> + inline void AddPathSegment(T&& pathSegment) + { + m_uri.AddPathSegment(std::forward<T>(pathSegment)); + } + + template<typename T> + inline void AddPathSegments(T&& pathSegments) + { + m_uri.AddPathSegments(std::forward<T>(pathSegments)); + } + + using OptionalError = Crt::Optional<Aws::Client::AWSError<Aws::Client::CoreErrors>>; + OptionalError AddPrefixIfMissing(const Aws::String& prefix); + + void SetQueryString(const Aws::String& queryString); + + const Crt::Optional<EndpointAttributes>& GetAttributes() const; + Crt::Optional<EndpointAttributes>& AccessAttributes(); + void SetAttributes(EndpointAttributes&& attributes); + + const Aws::UnorderedMap<Aws::String, Aws::String>& GetHeaders() const; + void SetHeaders(Aws::UnorderedMap<Aws::String, Aws::String> headers); + + protected: + // A URI containing at minimum the scheme and host. May optionally include a port and a path. + Aws::Http::URI m_uri; + + // A grab bag property map of endpoint attributes. The values here are considered unstable. + Crt::Optional<EndpointAttributes> m_attributes; + + // A map of additional headers to be set when calling the endpoint. + // Note: the values in these maps are Lists to support multi-value headers. + Aws::UnorderedMap<Aws::String, Aws::String> m_headers; + }; + } +} diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/AWSPartitions.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/AWSPartitions.h new file mode 100644 index 0000000000..fe08b9f4b6 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/AWSPartitions.h @@ -0,0 +1,23 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once +#include <cstddef> +#include <aws/core/Core_EXPORTS.h> + +namespace Aws +{ +namespace Endpoint +{ + struct AWS_CORE_API AWSPartitions + { + public: + static const size_t PartitionsBlobStrLen; + static const size_t PartitionsBlobSize; + + static const char* GetPartitionsBlob(); + }; +} // namespace Endpoint +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/BuiltInParameters.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/BuiltInParameters.h new file mode 100644 index 0000000000..c55dac969f --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/BuiltInParameters.h @@ -0,0 +1,44 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/endpoint/EndpointParameter.h> +#include <aws/core/client/ClientConfiguration.h> +#include <aws/core/client/GenericClientConfiguration.h> +#include <aws/core/utils/memory/stl/AWSVector.h> + +namespace Aws +{ + namespace Endpoint + { + class AWS_CORE_API BuiltInParameters + { + public: + using EndpointParameter = Aws::Endpoint::EndpointParameter; + + BuiltInParameters() = default; + BuiltInParameters(const BuiltInParameters&) = delete; // avoid accidental copy + virtual ~BuiltInParameters(){}; + + virtual void SetFromClientConfiguration(const Client::ClientConfiguration& config); + virtual void SetFromClientConfiguration(const Client::GenericClientConfiguration<false>& config); + virtual void SetFromClientConfiguration(const Client::GenericClientConfiguration<true>& config); + + virtual void OverrideEndpoint(const Aws::String& endpoint, const Aws::Http::Scheme& scheme = Aws::Http::Scheme::HTTPS); + + const EndpointParameter& GetParameter(const Aws::String& name) const; + void SetParameter(EndpointParameter param); + void SetStringParameter(Aws::String name, Aws::String value); + void SetBooleanParameter(Aws::String name, bool value); + + const Aws::Vector<EndpointParameter>& GetAllParameters() const; + + protected: + Aws::Vector<EndpointParameter> m_params; + }; + } // namespace Endpoint +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/ClientContextParameters.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/ClientContextParameters.h new file mode 100644 index 0000000000..e39eeed2e6 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/ClientContextParameters.h @@ -0,0 +1,37 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/endpoint/EndpointParameter.h> +#include <aws/core/utils/memory/stl/AWSVector.h> + +namespace Aws +{ + namespace Endpoint + { + class AWS_CORE_API ClientContextParameters + { + public: + using EndpointParameter = Aws::Endpoint::EndpointParameter; + + ClientContextParameters() = default; + // avoid accidental copy from endpointProvider::AccessClientContextParameters() + ClientContextParameters(const ClientContextParameters&) = delete; + + virtual ~ClientContextParameters(){}; + + const EndpointParameter& GetParameter(const Aws::String& name) const; + void SetParameter(EndpointParameter param); + void SetStringParameter(Aws::String name, Aws::String value); + void SetBooleanParameter(Aws::String name, bool value); + + const Aws::Vector<EndpointParameter>& GetAllParameters() const; + protected: + Aws::Vector<EndpointParameter> m_params; + }; + } // namespace Endpoint +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/DefaultEndpointProvider.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/DefaultEndpointProvider.h new file mode 100644 index 0000000000..d4d5cdd941 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/DefaultEndpointProvider.h @@ -0,0 +1,116 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/endpoint/AWSPartitions.h> +#include <aws/core/endpoint/EndpointProviderBase.h> +#include <aws/core/endpoint/EndpointParameter.h> +#include <aws/core/endpoint/ClientContextParameters.h> +#include <aws/core/endpoint/BuiltInParameters.h> +#include <aws/core/utils/memory/stl/AWSArray.h> + +#include <aws/crt/endpoints/RuleEngine.h> + +#include <aws/core/utils/Outcome.h> +#include <aws/core/client/AWSError.h> +#include <aws/core/client/CoreErrors.h> +#include "aws/core/utils/logging/LogMacros.h" + +namespace Aws +{ + namespace Endpoint + { + static const char DEFAULT_ENDPOINT_PROVIDER_TAG[] = "Aws::Endpoint::DefaultEndpointProvider"; + + /** + * Default template implementation for endpoint resolution + * @param ruleEngine + * @param builtInParameters + * @param clientContextParameters + * @param endpointParameters + * @return + */ + AWS_CORE_API ResolveEndpointOutcome + ResolveEndpointDefaultImpl(const Aws::Crt::Endpoints::RuleEngine& ruleEngine, + const EndpointParameters& builtInParameters, + const EndpointParameters& clientContextParameters, + const EndpointParameters& endpointParameters); + + /** + * Default endpoint provider template used in this SDK. + */ + template<typename ClientConfigurationT = Aws::Client::GenericClientConfiguration<false>, + typename BuiltInParametersT = Aws::Endpoint::BuiltInParameters, + typename ClientContextParametersT = Aws::Endpoint::ClientContextParameters> + class AWS_CORE_API DefaultEndpointProvider : public EndpointProviderBase<ClientConfigurationT, BuiltInParametersT, ClientContextParametersT> + { + public: + DefaultEndpointProvider(const char* endpointRulesBlob, const size_t endpointRulesBlobSz) + : m_crtRuleEngine(Aws::Crt::ByteCursorFromArray((const uint8_t*) endpointRulesBlob, endpointRulesBlobSz), + Aws::Crt::ByteCursorFromArray((const uint8_t*) AWSPartitions::GetPartitionsBlob(), AWSPartitions::PartitionsBlobSize)) + { + if(!m_crtRuleEngine) { + AWS_LOGSTREAM_FATAL(DEFAULT_ENDPOINT_PROVIDER_TAG, "Invalid CRT Rule Engine state"); + } + } + + virtual ~DefaultEndpointProvider() + { + } + + void InitBuiltInParameters(const ClientConfigurationT& config) override + { + m_builtInParameters.SetFromClientConfiguration(config); + } + + /** + * Default implementation of the ResolveEndpoint + */ + ResolveEndpointOutcome ResolveEndpoint(const EndpointParameters& endpointParameters) const override + { + auto ResolveEndpointDefaultImpl = Aws::Endpoint::ResolveEndpointDefaultImpl; + return ResolveEndpointDefaultImpl(m_crtRuleEngine, m_builtInParameters.GetAllParameters(), m_clientContextParameters.GetAllParameters(), endpointParameters); + }; + + const ClientContextParametersT& GetClientContextParameters() const override + { + return m_clientContextParameters; + } + ClientContextParametersT& AccessClientContextParameters() override + { + return m_clientContextParameters; + } + + const BuiltInParametersT& GetBuiltInParameters() const + { + return m_builtInParameters; + } + BuiltInParametersT& AccessBuiltInParameters() + { + return m_builtInParameters; + } + + void OverrideEndpoint(const Aws::String& endpoint) override + { + m_builtInParameters.OverrideEndpoint(endpoint); + } + + protected: + /* Crt RuleEngine evaluator built using the service's Rule engine */ + Aws::Crt::Endpoints::RuleEngine m_crtRuleEngine; + + /* Also known as a configurable parameters defined by the AWS Service in their c2j/smithy model definition */ + ClientContextParametersT m_clientContextParameters; + + /* Also known as parameters on the ClientConfiguration in this SDK */ + BuiltInParametersT m_builtInParameters; + }; + + // Export symbol from the DLL: + template class AWS_CORE_API DefaultEndpointProvider<Aws::Client::GenericClientConfiguration</*HasEndpointDiscovery*/ true> >; + } // namespace Endpoint +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/EndpointParameter.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/EndpointParameter.h new file mode 100644 index 0000000000..85911eb94a --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/EndpointParameter.h @@ -0,0 +1,139 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/client/AWSError.h> +#include <aws/core/utils/memory/stl/AWSVector.h> + +namespace Aws +{ + namespace Endpoint + { + class AWS_CORE_API EndpointParameter + { + public: + enum class ParameterType + { + BOOLEAN, + STRING + }; + enum class ParameterOrigin + { + STATIC_CONTEXT, + OPERATION_CONTEXT, + CLIENT_CONTEXT, + BUILT_IN, + NOT_SET = -1 + }; + + EndpointParameter(Aws::String name, bool initialValue, ParameterOrigin parameterOrigin = ParameterOrigin::NOT_SET) + : m_storedType(ParameterType::BOOLEAN), + m_parameterOrigin(parameterOrigin), + m_name(std::move(name)), + m_boolValue(initialValue) + {} + + EndpointParameter(Aws::String name, Aws::String initialValue, ParameterOrigin parameterOrigin = ParameterOrigin::NOT_SET) + : m_storedType(ParameterType::STRING), + m_parameterOrigin(parameterOrigin), + m_name(std::move(name)), + m_stringValue(std::move(initialValue)) + {} + + EndpointParameter(Aws::String name, const char* initialValue, ParameterOrigin parameterOrigin = ParameterOrigin::NOT_SET) + : m_storedType(ParameterType::STRING), + m_parameterOrigin(parameterOrigin), + m_name(std::move(name)), + m_stringValue(initialValue) + {} + + EndpointParameter(ParameterType storedType, ParameterOrigin parameterOrigin, Aws::String name) + : m_storedType(storedType), + m_parameterOrigin(parameterOrigin), + m_name(std::move(name)) + {} + + EndpointParameter(const EndpointParameter&) = default; + EndpointParameter(EndpointParameter&&) = default; + EndpointParameter& operator=(const EndpointParameter&) = default; + EndpointParameter& operator=(EndpointParameter&&) = default; + + inline ParameterType GetStoredType() const + { + return m_storedType; + } + + inline ParameterOrigin GetParameterOrigin() const + { + return m_parameterOrigin; + } + + inline const Aws::String& GetName() const + { + return m_name; + } + + enum class GetSetResult + { + SUCCESS, + ERROR_WRONG_TYPE + }; + + inline GetSetResult GetBool(bool& ioValue) const + { + if(m_storedType != ParameterType::BOOLEAN) + return GetSetResult::ERROR_WRONG_TYPE; + ioValue = m_boolValue; + return GetSetResult::SUCCESS; + } + + inline GetSetResult GetString(Aws::String& ioValue) const + { + // disabled RTTI... + if(m_storedType != ParameterType::STRING) + return GetSetResult::ERROR_WRONG_TYPE; + ioValue = m_stringValue; + return GetSetResult::SUCCESS; + } + + inline GetSetResult SetBool(bool iValue) + { + if(m_storedType != ParameterType::BOOLEAN) + return GetSetResult::ERROR_WRONG_TYPE; + m_boolValue = iValue; + return GetSetResult::SUCCESS; + } + + inline GetSetResult SetString(Aws::String iValue) + { + if(m_storedType != ParameterType::STRING) + return GetSetResult::ERROR_WRONG_TYPE; + m_stringValue = std::move(iValue); + return GetSetResult::SUCCESS; + } + + bool GetBoolValueNoCheck() const + { + return m_boolValue; + } + const Aws::String& GetStrValueNoCheck() const + { + return m_stringValue; + } + + protected: + ParameterType m_storedType; + ParameterOrigin m_parameterOrigin; + Aws::String m_name; + + bool m_boolValue = false; + Aws::String m_stringValue; + }; + + using EndpointParameters = Aws::Vector<Aws::Endpoint::EndpointParameter>; + } // namespace Endpoint +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/EndpointProviderBase.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/EndpointProviderBase.h new file mode 100644 index 0000000000..29b67626e3 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/EndpointProviderBase.h @@ -0,0 +1,76 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/endpoint/AWSEndpoint.h> +#include <aws/core/client/AWSError.h> +#include <aws/core/endpoint/EndpointParameter.h> +#include <aws/core/endpoint/BuiltInParameters.h> +#include <aws/core/endpoint/ClientContextParameters.h> + +namespace Aws +{ + namespace Utils + { + template< typename R, typename E> class Outcome; + } // namespace Utils + namespace Client + { + enum class CoreErrors; + } // namespace CoreErrors + + namespace Endpoint + { + using EndpointParameters = Aws::Vector<EndpointParameter>; + using ResolveEndpointOutcome = Aws::Utils::Outcome<AWSEndpoint, Aws::Client::AWSError<Aws::Client::CoreErrors> >; + + /** + * EndpointProviderBase is an interface definition that resolves the provided + * EndpointParameters to either an Endpoint or an error. + * This Base class represents a min interface required to be implemented to override an endpoint provider. + */ + template<typename ClientConfigurationT = Aws::Client::GenericClientConfiguration<false>, + typename BuiltInParametersT = Aws::Endpoint::BuiltInParameters, + typename ClientContextParametersT = Aws::Endpoint::ClientContextParameters> + class AWS_CORE_API EndpointProviderBase + { + public: + using BuiltInParameters = BuiltInParametersT; + using ClientContextParameters = ClientContextParametersT; + + virtual ~EndpointProviderBase() = default; + + /** + * Initialize client context parameters from a ClientConfiguration + */ + virtual void InitBuiltInParameters(const ClientConfigurationT& config) = 0; + + /** + * Function to override endpoint, i.e. to set built-in parameter "AWS::Endpoint" + */ + virtual void OverrideEndpoint(const Aws::String& endpoint) = 0; + + /** + * Method for write access to Client Context Parameters (i.e. configurable service-specific parameters) + */ + virtual ClientContextParametersT& AccessClientContextParameters() = 0; + + /** + * Method for read-only access to Client Context Parameters (i.e. configurable service-specific parameters) + */ + virtual const ClientContextParametersT& GetClientContextParameters() const = 0; + + /** + * The core of the endpoint provider interface. + */ + virtual ResolveEndpointOutcome ResolveEndpoint(const EndpointParameters& endpointParameters) const = 0; + }; + + // Export symbol from the DLL: + template class AWS_CORE_API EndpointProviderBase<Aws::Client::GenericClientConfiguration</*HasEndpointDiscovery*/ true> >; + } // namespace Endpoint +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/internal/AWSEndpointAttribute.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/internal/AWSEndpointAttribute.h new file mode 100644 index 0000000000..c4dfd07eb3 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/endpoint/internal/AWSEndpointAttribute.h @@ -0,0 +1,89 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + + +#pragma once + +#include <aws/core/client/AWSError.h> +#include <aws/crt/Optional.h> + +namespace Aws +{ + namespace Internal + { + namespace Endpoint + { + class AWS_CORE_API EndpointAuthScheme + { + public: + virtual ~EndpointAuthScheme(){}; + + inline const Aws::String& GetName() const + { + return m_name; + } + inline void SetName(Aws::String name) + { + m_name = std::move(name); + } + + inline const Crt::Optional<Aws::String>& GetSigningName() const + { + return m_signingName; + } + inline void SetSigningName(Aws::String signingName) + { + m_signingName = std::move(signingName); + } + + inline const Crt::Optional<Aws::String>& GetSigningRegion() const + { + return m_signingRegion; + } + inline void SetSigningRegion(Aws::String signingRegion) + { + m_signingRegion = std::move(signingRegion); + } + + inline const Crt::Optional<Aws::String>& GetSigningRegionSet() const + { + return m_signingRegionSet; + } + inline void SetSigningRegionSet(Aws::String signingRegionSet) + { + m_signingRegionSet = std::move(signingRegionSet); + } + + inline const Crt::Optional<bool>& GetDisableDoubleEncoding() const + { + return m_disableDoubleEncoding; + } + inline void SetDisableDoubleEncoding(bool disableDoubleEncoding) + { + m_disableDoubleEncoding = disableDoubleEncoding; + } + + private: + Aws::String m_name; + + Crt::Optional<Aws::String> m_signingName; + Crt::Optional<Aws::String> m_signingRegion; + Crt::Optional<Aws::String> m_signingRegionSet; + Crt::Optional<bool> m_disableDoubleEncoding; + }; + + /** + * A grab bag property map of endpoint attributes. The values here are considered unstable. + * C++ SDK supports only (and single so far) endpoint attribute "AuthScheme" + */ + struct AWS_CORE_API EndpointAttributes + { + Aws::Internal::Endpoint::EndpointAuthScheme authScheme; + + static EndpointAttributes BuildEndpointAttributesFromJson(const Aws::String& iJsonStr); + }; + } // namespace Endpoint + } // namespace Internal +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h index 92ccec786c..a069f3c772 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/external/cjson/cJSON.h @@ -183,8 +183,10 @@ CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_GetArrayItem(const cJSON *array, int i CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_GetObjectItem(const cJSON * const object, const char * const string); CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string); CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_HasObjectItem(const cJSON *object, const char *string); -/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_AS4CPP_Parse() returns 0. 0 when cJSON_AS4CPP_Parse() succeeds. */ +/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_AS4CPP_Parse() returns 0. 0 when cJSON_AS4CPP_Parse() succeeds. + * NOTE: disabled, since this method is not thread-safe. See comments in source/external/cjson/cJSON.cpp. CJSON_AS4CPP_PUBLIC(const char *) cJSON_AS4CPP_GetErrorPtr(void); + */ /* Check item type and return its value */ CJSON_AS4CPP_PUBLIC(char *) cJSON_AS4CPP_GetStringValue(const cJSON * const item); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h index ab71a3a29b..129bd3bd36 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpRequest.h @@ -18,6 +18,20 @@ namespace Aws { + namespace Crt + { + namespace Http + { + class HttpRequest; + } + } + namespace Utils + { + namespace Crypto + { + class Hash; + } + } namespace Http { extern AWS_CORE_API const char DATE_HEADER[]; @@ -29,8 +43,10 @@ namespace Aws extern AWS_CORE_API const char AUTHORIZATION_HEADER[]; extern AWS_CORE_API const char AWS_AUTHORIZATION_HEADER[]; extern AWS_CORE_API const char COOKIE_HEADER[]; + extern AWS_CORE_API const char DECODED_CONTENT_LENGTH_HEADER[]; extern AWS_CORE_API const char CONTENT_LENGTH_HEADER[]; extern AWS_CORE_API const char CONTENT_TYPE_HEADER[]; + extern AWS_CORE_API const char CONTENT_ENCODING_HEADER[]; extern AWS_CORE_API const char TRANSFER_ENCODING_HEADER[]; extern AWS_CORE_API const char USER_AGENT_HEADER[]; extern AWS_CORE_API const char VIA_HEADER[]; @@ -39,9 +55,13 @@ namespace Aws extern AWS_CORE_API const char X_AMZ_EXPIRES_HEADER[]; extern AWS_CORE_API const char CONTENT_MD5_HEADER[]; extern AWS_CORE_API const char API_VERSION_HEADER[]; + extern AWS_CORE_API const char AWS_TRAILER_HEADER[]; extern AWS_CORE_API const char SDK_INVOCATION_ID_HEADER[]; extern AWS_CORE_API const char SDK_REQUEST_HEADER[]; + extern AWS_CORE_API const char X_AMZN_TRACE_ID_HEADER[]; extern AWS_CORE_API const char CHUNKED_VALUE[]; + extern AWS_CORE_API const char AWS_CHUNKED_VALUE[]; + extern AWS_CORE_API const char X_AMZN_ERROR_TYPE[]; class HttpRequest; class HttpResponse; @@ -107,7 +127,7 @@ namespace Aws */ virtual bool HasHeader(const char* name) const = 0; /** - * Get size in bytes of the request when as it will be going accross the wire. + * Get size in bytes of the request when as it will be going across the wire. */ virtual int64_t GetSize() const = 0; /** @@ -525,6 +545,21 @@ namespace Aws bool IsEventStreamRequest() { return m_isEvenStreamRequest; } void SetEventStreamRequest(bool eventStreamRequest) { m_isEvenStreamRequest = eventStreamRequest; } + + virtual std::shared_ptr<Aws::Crt::Http::HttpRequest> ToCrtHttpRequest(); + + void SetRequestHash(const Aws::String& algorithmName, const std::shared_ptr<Aws::Utils::Crypto::Hash>& hash) + { + m_requestHash = std::make_pair(algorithmName, hash); + } + const std::pair<Aws::String, std::shared_ptr<Aws::Utils::Crypto::Hash>>& GetRequestHash() { return m_requestHash; } + + void AddResponseValidationHash(const Aws::String& algorithmName, const std::shared_ptr<Aws::Utils::Crypto::Hash>& hash) + { + m_responseValidationHashes.emplace_back(algorithmName, hash); + } + const Aws::Vector<std::pair<Aws::String, std::shared_ptr<Aws::Utils::Crypto::Hash>>>& GetResponseValidationHashes() const { return m_responseValidationHashes; } + private: URI m_uri; HttpMethod m_method; @@ -536,6 +571,8 @@ namespace Aws Aws::String m_signingAccessKey; Aws::String m_resolvedRemoteHost; Aws::Monitoring::HttpClientMetricsCollection m_httpRequestMetrics; + std::pair<Aws::String, std::shared_ptr<Aws::Utils::Crypto::Hash>> m_requestHash; + Aws::Vector<std::pair<Aws::String, std::shared_ptr<Aws::Utils::Crypto::Hash>>> m_responseValidationHashes; }; } // namespace Http diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpResponse.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpResponse.h index 1db30d1730..8082547a71 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpResponse.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/HttpResponse.h @@ -105,6 +105,11 @@ namespace Aws NETWORK_CONNECT_TIMEOUT = 599 }; + /** + * Overload ostream operator<< for HttpResponseCode enum class for a prettier output such as "200" + */ + AWS_CORE_API Aws::OStream& operator<< (Aws::OStream& oStream, HttpResponseCode code); + inline bool IsRetryableHttpResponseCode(HttpResponseCode responseCode) { switch (responseCode) @@ -137,7 +142,8 @@ namespace Aws HttpResponse(const std::shared_ptr<const HttpRequest>& originatingRequest) : m_httpRequest(originatingRequest), m_responseCode(HttpResponseCode::REQUEST_NOT_MADE), - m_hasClientError(false) + m_hasClientError(false), + m_clientErrorType(Aws::Client::CoreErrors::OK) {} virtual ~HttpResponse() = default; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/URI.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/URI.h index d72e96b863..724c24379f 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/URI.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/URI.h @@ -9,7 +9,7 @@ #include <aws/core/http/Scheme.h> #include <aws/core/utils/memory/stl/AWSMap.h> -#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/StringUtils.h> #include <stdint.h> @@ -21,6 +21,9 @@ namespace Aws static const uint16_t HTTP_DEFAULT_PORT = 80; static const uint16_t HTTPS_DEFAULT_PORT = 443; + extern bool s_compliantRfc3986Encoding; + AWS_CORE_API void SetCompliantRfc3986Encoding(bool compliant); + //per https://tools.ietf.org/html/rfc3986#section-3.4 there is nothing preventing servers from allowing //multiple values for the same key. So use a multimap instead of a map. typedef Aws::MultiMap<Aws::String, Aws::String> QueryStringParameterCollection; @@ -89,12 +92,17 @@ namespace Aws * Gets the path portion of the uri e.g. the portion after the first slash after the authority and prior to the * query string. This is not url encoded. */ - inline const Aws::String& GetPath() const { return m_path; } + Aws::String GetPath() const; /** * Gets the path portion of the uri, url encodes it and returns it */ - inline Aws::String GetURLEncodedPath() const { return URLEncodePath(m_path); } + Aws::String GetURLEncodedPath() const; + + /** + * Gets the path portion of the uri, url encodes it according to RFC3986 and returns it. + */ + Aws::String GetURLEncodedPathRFC3986() const; /** * Sets the path portion of the uri. URL encodes it if needed @@ -102,6 +110,39 @@ namespace Aws void SetPath(const Aws::String& value); /** + * Add a path segment to the uri. + * Leading slashes and trailing slashes will be removed. + * Use AddPathSegments() to enable trailing slashes. + */ + template<typename T> + inline void AddPathSegment(T pathSegment) + { + Aws::StringStream ss; + ss << pathSegment; + Aws::String segment = ss.str(); + segment.erase(0, segment.find_first_not_of('/')); + segment.erase(segment.find_last_not_of('/') + 1); + m_pathSegments.push_back(segment); + m_pathHasTrailingSlash = false; + } + + /** + * Add path segments to the uri. + */ + template<typename T> + inline void AddPathSegments(T pathSegments) + { + Aws::StringStream ss; + ss << pathSegments; + Aws::String segments = ss.str(); + for (const auto& segment : Aws::Utils::StringUtils::Split(segments, '/')) + { + m_pathSegments.push_back(segment); + } + m_pathHasTrailingSlash = (!segments.empty() && segments.back() == '/'); + } + + /** * Gets the raw query string including the ? */ inline const Aws::String& GetQueryString() const { return m_queryString; } @@ -159,10 +200,11 @@ namespace Aws void ExtractAndSetQueryString(const Aws::String& uri); bool CompareURIParts(const URI& other) const; - Scheme m_scheme; + Scheme m_scheme = Scheme::HTTP; Aws::String m_authority; - uint16_t m_port; - Aws::String m_path; + uint16_t m_port = HTTP_DEFAULT_PORT; + Aws::Vector<Aws::String> m_pathSegments; + bool m_pathHasTrailingSlash = false; Aws::String m_queryString; }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/curl/CurlHandleContainer.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/curl/CurlHandleContainer.h index c2745753eb..15cfdbf10a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/curl/CurlHandleContainer.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/curl/CurlHandleContainer.h @@ -43,7 +43,7 @@ public: void ReleaseCurlHandle(CURL* handle); /** - * When the handle has bad DNS entries, problematic live connections, we need to destory the handle from pool. + * When the handle has bad DNS entries, problematic live connections, we need to destroy the handle from pool. */ void DestroyCurlHandle(CURL* handle); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/standard/StandardHttpRequest.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/standard/StandardHttpRequest.h index c9c0016ef5..adf10fd182 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/standard/StandardHttpRequest.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/http/standard/StandardHttpRequest.h @@ -63,7 +63,7 @@ namespace Aws */ virtual bool HasHeader(const char*) const override; /** - * Get size in bytes of the request when as it will be going accross the wire. + * Get size in bytes of the request when as it will be going across the wire. */ virtual int64_t GetSize() const override; /** @@ -79,7 +79,6 @@ namespace Aws HeaderValueCollection headerMap; std::shared_ptr<Aws::IOStream> bodyStream; Aws::IOStreamFactory m_responseStreamFactory; - Aws::String m_emptyHeader; }; } // namespace Standard diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/internal/AWSHttpResourceClient.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/internal/AWSHttpResourceClient.h index bc28cd8861..ba03f6f39a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/internal/AWSHttpResourceClient.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/internal/AWSHttpResourceClient.h @@ -118,12 +118,13 @@ namespace Aws */ virtual Aws::String GetResource(const char* resourcePath) const; +#if !defined(DISABLE_IMDSV1) /** * Connects to the Amazon EC2 Instance Metadata Service to retrieve the * default credential information (if any). */ virtual Aws::String GetDefaultCredentials() const; - +#endif /** * Connects to the Amazon EC2 Instance Metadata Service to retrieve the * credential information (if any) in a more secure way. @@ -136,8 +137,19 @@ namespace Aws */ virtual Aws::String GetCurrentRegion() const; + /** + * Sets endpoint used to connect to the EC2 Instance metadata Service + */ + virtual void SetEndpoint(const Aws::String& endpoint); + + /** + * Gets endpoint used to connect to the EC2 Instance metadata Service + */ + virtual Aws::String GetEndpoint() const; + private: Aws::String m_endpoint; + bool m_disableIMDS; mutable std::recursive_mutex m_tokenMutex; mutable Aws::String m_token; mutable bool m_tokenRequired; @@ -249,8 +261,31 @@ namespace Aws SSOGetRoleCredentialsResult GetSSOCredentials(const SSOGetRoleCredentialsRequest& request); + struct SSOCreateTokenRequest + { + Aws::String clientId; + Aws::String clientSecret; + Aws::String grantType; + Aws::String refreshToken; + }; + + struct SSOCreateTokenResult + { + Aws::String accessToken; + size_t expiresIn = 0; //seconds + Aws::String idToken; + Aws::String refreshToken; + Aws::String clientId; + Aws::String tokenType; + }; + + SSOCreateTokenResult CreateToken(const SSOCreateTokenRequest& request); private: + Aws::String buildEndpoint(const Aws::Client::ClientConfiguration& clientConfiguration, + const Aws::String& domain, + const Aws::String& endpoint); Aws::String m_endpoint; + Aws::String m_oidcEndpoint; }; } // namespace Internal } // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringInterface.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringInterface.h index ebe50722c7..68a308a092 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringInterface.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringInterface.h @@ -26,7 +26,7 @@ namespace Aws /** * @brief This function lets you do preparation work when a http attempt(request) starts. It returns a pointer to an implementation defined context which will be * passed down with the other facilities that completes the request's lifetime. This context can be used to track the lifetime of the request and record metrics - * specific to this particular request. You are responsible for deleteing the context during your OnFinish call. + * specific to this particular request. You are responsible for deleting the context during your OnFinish call. * @param serviceName, the service client who initiates this http attempt. like "s3", "ec2", etc. * @param requestName, the operation or API name of this http attempt, like "GetObject" in s3. * @param request, the actual Http Request. diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringManager.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringManager.h index aaa5bca5d1..87b04fcbbf 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringManager.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/monitoring/MonitoringManager.h @@ -57,7 +57,8 @@ namespace Aws AWS_CORE_API void InitMonitoring(const std::vector<MonitoringFactoryCreateFunction>& monitoringFactoryCreateFunctions); /** - * Clean up monitoring related global variables + * Clean up monitoring related global variables. This should be done first at shutdown, to avoid a race condition in + * testing whether the global Monitoring instance has been destructed. */ AWS_CORE_API void CleanupMonitoring(); } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/net/SimpleUDP.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/net/SimpleUDP.h index 2e96b509fb..a9f2f4f59f 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/net/SimpleUDP.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/net/SimpleUDP.h @@ -26,7 +26,7 @@ namespace Aws * @brief Constructor of SimpleUDP * @param addressFamily, AF_INET for IPV4 or AF_INET6 for IPV6 * @param sendBufSize, if nonzero, try set socket's send buffer size to this value. - * @param receieveBufSize, if nonzero, try set socket's receive buffer size to this value. + * @param receiveBufSize, if nonzero, try set socket's receive buffer size to this value. * @param nonBlocking, if it is true, implementation will try to create a non-blocking underlying UDP socket. * Implementation should create and set the underlying udp socket. */ @@ -36,7 +36,7 @@ namespace Aws * @brief An easy constructor of an IPV4 or IPV6 SimpleUDP * @param addressFamily, either AF_INET for IPV4 or AF_INET6 for IPV6 * @param sendBufSize, if nonzero, try set socket's send buffer size to this value. - * @param receieveBufSize, if nonzero, try set socket's receive buffer size to this value. + * @param receiveBufSize, if nonzero, try set socket's receive buffer size to this value. * @param nonBlocking, if it is true, implementation will try to create a non-blocking underlying UDP socket. * Implementation should create and set the underlying udp socket. */ @@ -48,7 +48,7 @@ namespace Aws * Note that "localhost" is not necessarily bind to 127.0.0.1, it could bind to ipv6 address ::1, or other type of ip addresses. If you pass localhost here, we will go through getaddrinfo procedure on Linux and Windows. * @param port, the port number that the host listens on. * @param sendBufSize, if nonzero, try set socket's send buffer size to this value. - * @param receieveBufSize, if nonzero, try set socket's receive buffer size to this value. + * @param receiveBufSize, if nonzero, try set socket's receive buffer size to this value. * @param nonBlocking, if it is true, implementation will try to create a non-blocking underlying UDP socket. * Implementation should create and set the underlying udp socket. */ @@ -131,7 +131,7 @@ namespace Aws /** * @brief Receive data from network. * @param address, if not null and underlying implementation supply the incoming data's source address, this will be filled with source address info. - * @param addressLength, the size of source adddress, should not be null. + * @param addressLength, the size of source address, should not be null. * @param buffer, the memory address where you want to store received data. * @param bufferLen, the size of data buffer. * @return -1 on failure, check errno for detailed error information, on success, returns the actual bytes of data received. diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DateTime.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DateTime.h index a410279011..878fc1ac63 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DateTime.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/DateTime.h @@ -49,7 +49,7 @@ namespace Aws }; /** - * Wrapper for all the weird crap we need to do with timestamps. + * Wrapper for timestamp functionality. */ class AWS_CORE_API DateTime { @@ -145,6 +145,11 @@ namespace Aws double SecondsWithMSPrecision() const; /** + * Get the seconds without millisecond precision. + */ + int64_t Seconds() const; + + /** * Milliseconds since epoch of this datetime. */ int64_t Millis() const; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/Document.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/Document.h new file mode 100644 index 0000000000..2c062b8ca6 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/Document.h @@ -0,0 +1,370 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> + +#include <aws/core/utils/Array.h> +#include <aws/core/utils/memory/stl/AWSStreamFwd.h> +#include <aws/core/utils/memory/stl/AWSString.h> +#include <aws/core/utils/memory/stl/AWSMap.h> +#include <aws/core/external/cjson/cJSON.h> + +#include <utility> + +namespace Aws +{ + namespace Utils + { + namespace Json + { + class JsonValue; + class JsonView; + } + + class DocumentView; + /** + * A Document type represents open content that is serialized using the same format as its surroundings and requires no additional encoding or escaping. + * Document types provide a JSON "view" of data regardless of the underlying protocol. This normalized JSON interface makes document types protocol-agnostic. + * Clients can use the data stored in a document without prior knowledge of the protocol by interacting with the normalized JSON view of the data. + * Document types are only initially supported in JSON protocol, so it's identical to Aws::Utils::Json::JsonValue and Aws::Utils::Json::JsonView at this moment. + */ + class AWS_CORE_API Document + { + public: + /** + * Constructs empty Document. + */ + Document(); + + /** + * Constructs a Document by parsing the input string. + */ + Document(const Aws::String& value); + + /** + * Constructs a Document by parsing the text in the input stream. + */ + Document(Aws::IStream& istream); + + /** + * Performs a deep copy of the Document parameter. + * Prefer using a @ref DocumentView if copying is not needed. + */ + Document(const Document& value); + + /** + * Moves the ownership of the internal Document. + * No copying is performed. + */ + Document(Document&& value); + + /** + * Performs a deep copy of the JsonView parameter. + */ + Document(const Json::JsonView& view); + + ~Document(); + + /** + * Performs a deep copy of the Document parameter. + */ + Document& operator=(const Document& other); + + /** + * Performs a deep copy of the JsonView parameter. + */ + Document& operator=(const Json::JsonView& view); + + /** + * Moves the ownership of the internal Document of the parameter to the current object. + * No copying is performed. + * A Document currently owned by the object will be freed prior to copying. + * @warning This will result in invalidating any outstanding views of the current Document. However, views + * to the moved-from Document would still valid. + */ + Document& operator=(Document&& other); + + bool operator==(const Document& other) const; + bool operator!=(const Document& other) const; + + /** + * Adds a string to the top level of this Document with key. + */ + Document& WithString(const Aws::String& key, const Aws::String& value); + Document& WithString(const char* key, const Aws::String& value); + /** + * Converts the current Document to a string. + */ + Document& AsString(const Aws::String& value); + + /** + * Adds a bool value with key to the top level of this Document. + */ + Document& WithBool(const Aws::String& key, bool value); + Document& WithBool(const char* key, bool value); + /** + * Converts the current Document to a bool. + */ + Document& AsBool(bool value); + + /** + * Adds an integer value at key at the top level of this Document. + */ + Document& WithInteger(const Aws::String& key, int value); + Document& WithInteger(const char* key, int value); + /** + * Converts the current Document to an integer. + */ + Document& AsInteger(int value); + + /** + * Adds a 64-bit integer value at key to the top level of this Document. + */ + Document& WithInt64(const Aws::String& key, long long value); + Document& WithInt64(const char* key, long long value); + /** + * Converts the current Document to a 64-bit integer. + */ + Document& AsInt64(long long value); + + /** + * Adds a double value at key at the top level of this Document. + */ + Document& WithDouble(const Aws::String& key, double value); + Document& WithDouble(const char* key, double value); + /** + * Converts the current Document to a double. + */ + Document& AsDouble(double value); + + /** + * Adds an array of strings to the top level of this Document at key. + */ + Document& WithArray(const Aws::String& key, const Array<Aws::String>& array); + Document& WithArray(const char* key, const Array<Aws::String>& array); + /** + * Adds an array of arbitrary Document objects to the top level of this Document at key. + * The values in the array parameter will be deep-copied. + */ + Document& WithArray(const Aws::String& key, const Array<Document>& array); + /** + * Adds an array of arbitrary Document objects to the top level of this Document at key. + * The values in the array parameter will be moved-from. + */ + Document& WithArray(const Aws::String& key, Array<Document>&& array); + /** + * Converts the current Document to an array whose values are deep-copied from the array parameter. + */ + Document& AsArray(const Array<Document>& array); + /** + * Converts the current Document to an array whose values are moved from the array parameter. + */ + Document& AsArray(Array<Document>&& array); + + /** + * Adds a Document object to the top level of this Document at key. + * The object parameter is deep-copied. + */ + Document& WithObject(const Aws::String& key, const Document& value); + Document& WithObject(const char* key, const Document& value); + /** + * Adds a Document object to the top level of this Document at key. + */ + Document& WithObject(const Aws::String& key, Document&& value); + Document& WithObject(const char* key, Document&& value); + /** + * Converts the current Document to a Document object by deep-copying the parameter. + */ + Document& AsObject(const Document& value); + /** + * Converts the current Document to a Document object by moving from the parameter. + */ + Document& AsObject(Document&& value); + + /** + * Returns true if the last parse request was successful. If this returns false, + * you can call GetErrorMessage() to find the cause. + */ + inline bool WasParseSuccessful() const + { + return m_wasParseSuccessful; + } + + /** + * Returns the last error message from a failed parse attempt. Returns empty string if no error. + */ + inline const Aws::String& GetErrorMessage() const + { + return m_errorMessage; + } + + /** + * Creates a view from the current Document. + */ + DocumentView View() const; + + private: + void Destroy(); + Document(cJSON* value); + cJSON* m_json; + bool m_wasParseSuccessful; + Aws::String m_errorMessage; + friend DocumentView; + }; + + /** + * Provides read-only view to an existing Document. This allows lightweight copying without making deep + * copies of the Document. + * Note: This class does not extend the lifetime of the given Document. It's your responsibility to ensure + * the lifetime of the Document is extended beyond the lifetime of its view. + */ + class AWS_CORE_API DocumentView + { + public: + /* constructors */ + DocumentView(); + DocumentView(const Document& value); + DocumentView& operator=(const Document& value); + + /** + * Gets a string from this Document by its key. + */ + Aws::String GetString(const Aws::String& key) const; + /** + * Returns the value of this Document as a string. + */ + Aws::String AsString() const; + /** + * Tests whether the current value is a string. + */ + bool IsString() const; + + /** + * Gets a boolean value from this Document by its key. + */ + bool GetBool(const Aws::String& key) const; + /** + * Returns the value of this Document as a boolean. + */ + bool AsBool() const; + /** + * Tests whether the current value is a boolean. + */ + bool IsBool() const; + + /** + * Gets an integer value from this Document by its key. + * The integer is of the same size as an int on the machine. + */ + int GetInteger(const Aws::String& key) const; + /** + * Returns the value of this Document as an int. + */ + int AsInteger() const; + /** + * Tests whether the current value is an int or int64_t. + * Returns false if the value is floating-point. + */ + bool IsIntegerType() const; + + /** + * Converts the current Document to a 64-bit integer. + */ + Document& AsInt64(long long value); + /** + * Gets a 64-bit integer value from this Document by its key. + * The value is 64-bit regardless of the platform/machine. + */ + int64_t GetInt64(const Aws::String& key) const; + /** + * Returns the value of this Document as 64-bit integer. + */ + int64_t AsInt64() const; + + /** + * Gets a double precision floating-point value from this Document by its key. + */ + double GetDouble(const Aws::String& key) const; + /** + * Returns the value of this Document as a double precision floating-point. + */ + double AsDouble() const; + /** + * Tests whether the current value is a floating-point. + */ + bool IsFloatingPointType() const; + + /** + * Gets an array of DocumentView objects from this Document by its key. + */ + Array<DocumentView> GetArray(const Aws::String& key) const; + /** + * Returns the value of this Document as an array of DocumentView objects. + */ + Array<DocumentView> AsArray() const; + /** + * Tests whether the current value is a Document array. + */ + bool IsListType() const; + + /** + * Gets a DocumentView object from this Document by its key. + */ + DocumentView GetObject(const Aws::String& key) const; + /** + * Returns the value of this Document as a DocumentView object. + */ + DocumentView AsObject() const; + /** + * Reads all Document objects at the top level of this Document (does not traverse the tree any further) + * along with their keys. + */ + Aws::Map<Aws::String, DocumentView> GetAllObjects() const; + /** + * Tests whether the current value is a Document object. + */ + bool IsObject() const; + + /** + * Tests whether the current value is NULL. + */ + bool IsNull() const; + + /** + * Tests whether a value exists at the current Document level for the given key. + * Returns true if a value has been found and its value is not null, false otherwise. + */ + bool ValueExists(const Aws::String& key) const; + + /** + * Tests whether a key exists at the current Document level. + */ + bool KeyExists(const Aws::String& key) const; + + /** + * Writes the current Document view without whitespace characters starting at the current level to a string. + */ + Aws::String WriteCompact() const; + + /** + * Writes the current Document view to a string in a human friendly format. + */ + Aws::String WriteReadable() const; + + /** + * Creates a deep copy of the JSON value rooted in the current JSON view. + */ + Document Materialize() const; + private: + DocumentView(cJSON* value); + DocumentView& operator=(cJSON* value); + cJSON* m_json; + friend Aws::Utils::Json::JsonValue; + }; + + } // namespace Utils +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/FileSystemUtils.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/FileSystemUtils.h index d62ff4c094..430e7ae441 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/FileSystemUtils.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/FileSystemUtils.h @@ -45,7 +45,7 @@ namespace Aws */ TempFile(const char* prefix, std::ios_base::openmode openFlags); /** - * Creates a temporary file with a randome string for the name. + * Creates a temporary file with a random string for the name. */ TempFile(std::ios_base::openmode openFlags); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/HashingUtils.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/HashingUtils.h index 465c9827b2..d09fe5c94f 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/HashingUtils.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/HashingUtils.h @@ -87,6 +87,26 @@ namespace Aws */ static ByteBuffer CalculateMD5(Aws::IOStream& stream); + /** + * Calculates a CRC32 Hash value + */ + static ByteBuffer CalculateCRC32(const Aws::String& str); + + /** + * Calculates a CRC32 Hash value + */ + static ByteBuffer CalculateCRC32(Aws::IOStream& stream); + + /** + * Calculates a CRC32C Hash value + */ + static ByteBuffer CalculateCRC32C(const Aws::String& str); + + /** + * Calculates a CRC32C Hash value + */ + static ByteBuffer CalculateCRC32C(Aws::IOStream& stream); + static int HashString(const char* strToHash); }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/ResourceManager.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/ResourceManager.h index 517f65d0fa..c564e58650 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/ResourceManager.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/ResourceManager.h @@ -96,7 +96,6 @@ namespace Aws */ Aws::Vector<RESOURCE_TYPE> ShutdownAndWait(size_t resourceCount) { - Aws::Vector<RESOURCE_TYPE> resources; std::unique_lock<std::mutex> locker(m_queueLock); m_shutdown = true; @@ -106,8 +105,7 @@ namespace Aws m_semaphore.wait(locker, [&]() { return m_resources.size() == resourceCount; }); } - resources = m_resources; - m_resources.clear(); + Aws::Vector<RESOURCE_TYPE> resources{std::move(m_resources)}; return resources; } diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h index 312342b86a..0281a8fe06 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/StringUtils.h @@ -10,7 +10,7 @@ #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> - +#include <aws/common/byte_buf.h> namespace Aws @@ -82,14 +82,14 @@ namespace Aws /** * @brief Splits a string on a delimiter (empty items are excluded). * @param toSplit, the original string to split - * @param splitOn, the delemiter you want to use. + * @param splitOn, the delimiter you want to use. */ static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn); /** * @brief Splits a string on a delimiter. * @param toSplit, the original string to split - * @param splitOn, the delemiter you want to use. + * @param splitOn, the delimiter you want to use. * @param option, if INCLUDE_EMPTY_ENTRIES, includes empty entries in the result, otherwise removes empty entries. */ static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, SplitOptions option); @@ -97,7 +97,7 @@ namespace Aws /** * @brief Splits a string on a delimiter (empty items are excluded). * @param toSplit, the original string to split - * @param splitOn, the delemiter you want to use. + * @param splitOn, the delimiter you want to use. * @param numOfTargetParts, how many target parts you want to get, if it is 0, as many as possible. */ static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, size_t numOfTargetParts); @@ -105,7 +105,7 @@ namespace Aws /** * @brief Splits a string on a delimiter. * @param toSplit, the original string to split - * @param splitOn, the delemiter you want to use. + * @param splitOn, the delimiter you want to use. * @param numOfTargetParts, how many target parts you want to get, if it is 0, as many as possible. * @param option, if INCLUDE_EMPTY_ENTRIES, includes empty entries in the result, otherwise removes empty entries. */ @@ -212,8 +212,13 @@ namespace Aws std::reverse(s.begin(), s.end()); return s; } + + static Aws::String FromByteCursor(aws_byte_cursor cursor) + { + return Aws::String(reinterpret_cast<char *>(cursor.ptr), cursor.len); + } }; } // namespace Utils -} // namespace Aws
\ No newline at end of file +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/CRC32.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/CRC32.h new file mode 100644 index 0000000000..75fc30f0d5 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/CRC32.h @@ -0,0 +1,147 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +/* +* Interface for CRC32 and CRC32C +*/ +#pragma once + +#ifdef __APPLE__ + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif // __clang__ + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif // __GNUC__ + +#endif // __APPLE__ + +#include <aws/core/Core_EXPORTS.h> + +#include <aws/core/utils/crypto/Hash.h> + +namespace Aws +{ + namespace Utils + { + namespace Crypto + { + /** + * CRC32 hash implementation. + */ + class AWS_CORE_API CRC32 : public Hash + { + public: + /** + * Initializes platform crypto libs for crc32. + */ + CRC32(); + virtual ~CRC32(); + + /** + * Calculates a CRC32 Hash digest + */ + virtual HashResult Calculate(const Aws::String& str) override; + + /** + * Calculates a CRC32 Hash digest on a stream (the entire stream is read) + */ + virtual HashResult Calculate(Aws::IStream& stream) override; + + /** + * Updates a Hash digest + */ + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + /** + * Get the result in the current value + */ + virtual HashResult GetHash() override; + private: + + std::shared_ptr< Hash > m_hashImpl; + }; + + /** + * CRC32C hash implementation. + */ + class AWS_CORE_API CRC32C : public Hash + { + public: + /** + * Initializes platform crypto libs for crc32c. + */ + CRC32C(); + virtual ~CRC32C(); + + /** + * Calculates a CRC32C Hash digest + */ + virtual HashResult Calculate(const Aws::String& str) override; + + /** + * Calculates a CRC32C Hash digest on a stream (the entire stream is read) + */ + virtual HashResult Calculate(Aws::IStream& stream) override; + + /** + * Updates a Hash digest + */ + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + /** + * Get the result in the current value + */ + virtual HashResult GetHash() override; + + private: + + std::shared_ptr< Hash > m_hashImpl; + }; + + class AWS_CORE_API CRC32Impl : public Hash + { + public: + + CRC32Impl(); + virtual ~CRC32Impl() {} + + virtual HashResult Calculate(const Aws::String& str) override; + + virtual HashResult Calculate(Aws::IStream& stream) override; + + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + virtual HashResult GetHash() override; + + private: + int m_runningCrc32; + }; + + class AWS_CORE_API CRC32CImpl : public Hash + { + public: + + CRC32CImpl(); + virtual ~CRC32CImpl() {} + + virtual HashResult Calculate(const Aws::String& str) override; + + virtual HashResult Calculate(Aws::IStream& stream) override; + + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + virtual HashResult GetHash() override; + + private: + int m_runningCrc32c; + }; + + } // namespace Crypto + } // namespace Utils +} // namespace Aws + diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Factories.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Factories.h index a219d3eae5..12f610d4de 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Factories.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Factories.h @@ -44,6 +44,14 @@ namespace Aws */ AWS_CORE_API std::shared_ptr<Hash> CreateMD5Implementation(); /** + * Create a CRC32 Hash provider + */ + AWS_CORE_API std::shared_ptr<Hash> CreateCRC32Implementation(); + /** + * Create a CRC32C Hash provider + */ + AWS_CORE_API std::shared_ptr<Hash> CreateCRC32CImplementation(); + /** * Create a Sha1 Hash provider */ AWS_CORE_API std::shared_ptr<Hash> CreateSha1Implementation(); @@ -106,18 +114,26 @@ namespace Aws /** * Create AES in Key Wrap mode off of a 256 bit key. */ - AWS_CORE_API std::shared_ptr<SymmetricCipher> CreateAES_KeyWrapImplementation(const CryptoBuffer& key); + AWS_CORE_API std::shared_ptr<SymmetricCipher> CreateAES_KeyWrapImplementation(const CryptoBuffer& key); /** * Create SecureRandomBytes instance */ AWS_CORE_API std::shared_ptr<SecureRandomBytes> CreateSecureRandomBytesImplementation(); - + /** * Set the global factory for MD5 Hash providers */ AWS_CORE_API void SetMD5Factory(const std::shared_ptr<HashFactory>& factory); /** + * Set the global factory for CRC32 Hash providers + */ + AWS_CORE_API void SetCRC32Factory(const std::shared_ptr<HashFactory>& factory); + /** + * Set the global factory for CRC32C Hash providers + */ + AWS_CORE_API void SetCRC32CFactory(const std::shared_ptr<HashFactory>& factory); + /** * Set the global factory for Sha1 Hash providers */ AWS_CORE_API void SetSha1Factory(const std::shared_ptr<HashFactory>& factory); diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Hash.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Hash.h index 8ebbe009fc..c39f012f4c 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Hash.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Hash.h @@ -36,6 +36,16 @@ namespace Aws */ virtual HashResult Calculate(Aws::IStream& stream) = 0; + /** + * Updates a Hash digest + */ + virtual void Update(unsigned char*, size_t bufferSize) = 0; + + /** + * Get the result in the current value + */ + virtual HashResult GetHash() = 0; + // when hashing streams, this is the size of our internal buffer we read the stream into static const uint32_t INTERNAL_HASH_STREAM_BUFFER_SIZE = 8192; }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/MD5.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/MD5.h index 59304a4a88..6cc7178630 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/MD5.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/MD5.h @@ -55,6 +55,16 @@ namespace Aws */ virtual HashResult Calculate(Aws::IStream& stream) override; + /** + * Updates a Hash digest + */ + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + /** + * Get the result in the current value + */ + virtual HashResult GetHash() override; + private: std::shared_ptr<Hash> m_hashImpl; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha1.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha1.h index 5d9d44f867..547ca65555 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha1.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha1.h @@ -54,6 +54,15 @@ namespace Aws */ virtual HashResult Calculate(Aws::IStream& stream) override; + /** + * Updates a Hash digest + */ + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + /** + * Get the result in the current value + */ + virtual HashResult GetHash() override; private: std::shared_ptr< Hash > m_hashImpl; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha256.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha256.h index 441752b0a6..40782cd58e 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha256.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Sha256.h @@ -54,6 +54,16 @@ namespace Aws */ virtual HashResult Calculate(Aws::IStream& stream) override; + /** + * Updates a Hash digest + */ + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + /** + * Get the result in the current value + */ + virtual HashResult GetHash() override; + private: std::shared_ptr< Hash > m_hashImpl; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h index 39f5e5fcd4..aa31d3602f 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h @@ -39,7 +39,7 @@ namespace Aws * OpenSSL implementation for SecureRandomBytes. * Incidentally, this implementation is thread safe, though it is not * on other platforms. You should treat an instance of SecureRandomBytes - * as needed to be memory fenced if you will be using accross multiple threads + * as needed to be memory fenced if you will be using across multiple threads */ class SecureRandomBytes_OpenSSLImpl : public SecureRandomBytes { @@ -59,40 +59,59 @@ namespace Aws { public: - MD5OpenSSLImpl() - { } + MD5OpenSSLImpl(); - virtual ~MD5OpenSSLImpl() = default; + virtual ~MD5OpenSSLImpl(); virtual HashResult Calculate(const Aws::String& str) override; virtual HashResult Calculate(Aws::IStream& stream) override; + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + virtual HashResult GetHash() override; + + private: + EVP_MD_CTX *m_ctx; }; class Sha1OpenSSLImpl : public Hash { public: - Sha1OpenSSLImpl() {} - virtual ~Sha1OpenSSLImpl() = default; + Sha1OpenSSLImpl(); + + virtual ~Sha1OpenSSLImpl(); virtual HashResult Calculate(const Aws::String& str) override; virtual HashResult Calculate(Aws::IStream& stream) override; + + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + virtual HashResult GetHash() override; + + private: + EVP_MD_CTX *m_ctx; }; class Sha256OpenSSLImpl : public Hash { public: - Sha256OpenSSLImpl() - { } + Sha256OpenSSLImpl(); - virtual ~Sha256OpenSSLImpl() = default; + virtual ~Sha256OpenSSLImpl(); virtual HashResult Calculate(const Aws::String& str) override; virtual HashResult Calculate(Aws::IStream& stream) override; + + virtual void Update(unsigned char* buffer, size_t bufferSize) override; + + virtual HashResult GetHash() override; + + private: + EVP_MD_CTX *m_ctx; }; class Sha256HMACOpenSSLImpl : public HMAC @@ -187,7 +206,7 @@ namespace Aws void Cleanup(); /* openssl has bug finalize decryption of an empty string */ - bool m_emptyPlaintext; + bool m_emptyPlaintext = false; }; /** diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h index c60dda0435..ae58ad5def 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h @@ -44,10 +44,11 @@ namespace Aws UNKNOWN }; - EventHeaderValue() = default; + EventHeaderValue() : m_eventHeaderType(EventHeaderType::UNKNOWN), m_eventHeaderStaticValue({0}) {} EventHeaderValue(aws_event_stream_header_value_pair* header) : - m_eventHeaderType(static_cast<EventHeaderType>(header->header_value_type)) + m_eventHeaderType(static_cast<EventHeaderType>(header->header_value_type)), + m_eventHeaderStaticValue({0}) { switch (m_eventHeaderType) { @@ -88,49 +89,57 @@ namespace Aws EventHeaderValue(const Aws::String& s) : m_eventHeaderType(EventHeaderType::STRING), - m_eventHeaderVariableLengthValue(reinterpret_cast<const uint8_t*>(s.data()), s.length()) + m_eventHeaderVariableLengthValue(reinterpret_cast<const uint8_t*>(s.data()), s.length()), + m_eventHeaderStaticValue({0}) { } EventHeaderValue(const ByteBuffer& bb) : m_eventHeaderType(EventHeaderType::BYTE_BUF), - m_eventHeaderVariableLengthValue(bb) + m_eventHeaderVariableLengthValue(bb), + m_eventHeaderStaticValue({0}) { } EventHeaderValue(ByteBuffer&& bb) : m_eventHeaderType(EventHeaderType::BYTE_BUF), - m_eventHeaderVariableLengthValue(std::move(bb)) + m_eventHeaderVariableLengthValue(std::move(bb)), + m_eventHeaderStaticValue({0}) { } explicit EventHeaderValue(unsigned char byte) : - m_eventHeaderType(EventHeaderType::BYTE) + m_eventHeaderType(EventHeaderType::BYTE), + m_eventHeaderStaticValue({0}) { m_eventHeaderStaticValue.byteValue = byte; } explicit EventHeaderValue(bool b) : - m_eventHeaderType(b ? EventHeaderType::BOOL_TRUE : EventHeaderType::BOOL_FALSE) + m_eventHeaderType(b ? EventHeaderType::BOOL_TRUE : EventHeaderType::BOOL_FALSE), + m_eventHeaderStaticValue({0}) { m_eventHeaderStaticValue.boolValue = b; } explicit EventHeaderValue(int16_t n) : - m_eventHeaderType(EventHeaderType::INT16) + m_eventHeaderType(EventHeaderType::INT16), + m_eventHeaderStaticValue({0}) { m_eventHeaderStaticValue.int16Value = n; } explicit EventHeaderValue(int32_t n) : - m_eventHeaderType(EventHeaderType::INT32) + m_eventHeaderType(EventHeaderType::INT32), + m_eventHeaderStaticValue({0}) { m_eventHeaderStaticValue.int32Value = n; } explicit EventHeaderValue(int64_t n, EventHeaderType type = EventHeaderType::INT64) : - m_eventHeaderType(type) + m_eventHeaderType(type), + m_eventHeaderStaticValue({0}) { if (type == EventHeaderType::TIMESTAMP) { @@ -295,12 +304,12 @@ namespace Aws ByteBuffer m_eventHeaderVariableLengthValue; union { - bool boolValue; - uint8_t byteValue; - int16_t int16Value; - int32_t int32Value; - int64_t int64Value; int64_t timestampValue; + int64_t int64Value; + int32_t int32Value; + int16_t int16Value; + uint8_t byteValue; + bool boolValue; } m_eventHeaderStaticValue; }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h index 4540fbe79c..48e13c0865 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventMessage.h @@ -109,9 +109,9 @@ namespace Aws inline Aws::String GetEventPayloadAsString() { return Aws::String(m_eventPayload.begin(), m_eventPayload.end()); } private: - size_t m_totalLength; - size_t m_headersLength; - size_t m_payloadLength; + size_t m_totalLength = 0; + size_t m_headersLength = 0; + size_t m_payloadLength = 0; Aws::Utils::Event::EventHeaderValueCollection m_eventHeaders; Aws::Vector<unsigned char> m_eventPayload; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h index 3cd06a9df2..8b9c123241 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamEncoder.h @@ -41,8 +41,20 @@ namespace Aws */ Aws::Vector<unsigned char> EncodeAndSign(const Aws::Utils::Event::Message& msg); private: - aws_event_stream_message Encode(const Aws::Utils::Event::Message& msg); - aws_event_stream_message Sign(aws_event_stream_message* msg); + /** + * Initialize C struct based on C++ object. + * Returns true if successful. + * A successfully initialized struct must be cleaned up when you're done with it. + */ + bool InitEncodedStruct(const Aws::Utils::Event::Message& msg, aws_event_stream_message* encoded); + + /** + * Initialize signed C struct based on unsigned C struct. + * Returns true if successful. + * A successfully initialized struct must be cleaned up when you're done with it. + */ + bool InitSignedStruct(const aws_event_stream_message* msg, aws_event_stream_message* signedmsg); + Aws::Client::AWSAuthSigner* m_signer; Aws::String m_signatureSeed; }; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h index 257bfd8288..ac13c8ee28 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/event/EventStreamHandler.h @@ -29,7 +29,7 @@ namespace Aws { public: EventStreamHandler() : - m_failure(false), m_internalError(EventStreamErrors::EVENT_STREAM_NO_ERROR), m_headersBytesReceived(0), m_payloadBytesReceived(0) + m_failure(false), m_internalError(EventStreamErrors::EVENT_STREAM_NO_ERROR), m_headersBytesReceived(0), m_payloadBytesReceived(0), m_message() {} virtual ~EventStreamHandler() = default; diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h index 657ee6eff4..8b2ccc139b 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/json/JsonSerializer.h @@ -19,6 +19,9 @@ namespace Aws { namespace Utils { + class Document; + class DocumentView; + namespace Json { class JsonView; @@ -56,6 +59,11 @@ namespace Aws */ JsonValue(JsonValue&& value); + /** + * Performs a deep copy of the Document parameter. + */ + JsonValue(const Aws::Utils::DocumentView& value); + ~JsonValue(); /** @@ -72,6 +80,11 @@ namespace Aws */ JsonValue& operator=(JsonValue&& other); + /** + * Performs a deep copy of the Document parameter. + */ + JsonValue& operator=(const Aws::Utils::DocumentView& value); + bool operator==(const JsonValue& other) const; bool operator!=(const JsonValue& other) const; @@ -373,6 +386,7 @@ namespace Aws JsonView(cJSON* val); JsonView& operator=(cJSON* val); cJSON* m_value; + friend class Aws::Utils::Document; }; } // namespace Json diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/CRTLogSystem.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/CRTLogSystem.h new file mode 100644 index 0000000000..204f974bbf --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/CRTLogSystem.h @@ -0,0 +1,67 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <aws/core/utils/logging/LogLevel.h> +#include <aws/common/logging.h> + +#include <atomic> + +namespace Aws +{ + namespace Utils + { + namespace Logging + { + enum class LogLevel : int; + + /** + * Interface for CRT (common runtime libraries) logging implementations. + * A wrapper on the top of aws_logger, the logging interface used by common runtime libraries. + */ + class AWS_CORE_API CRTLogSystemInterface + { + public: + virtual ~CRTLogSystemInterface() = default; + }; + + /** + * The default CRT log system will just do a redirection of all logs from common runtime libraries to C++ SDK. + * You can override virtual function Log() in your subclass to change the default behaviors. + */ + class AWS_CORE_API DefaultCRTLogSystem : public CRTLogSystemInterface + { + public: + DefaultCRTLogSystem(LogLevel logLevel); + virtual ~DefaultCRTLogSystem(); + + /** + * Gets the currently configured log level. + */ + LogLevel GetLogLevel() const { return m_logLevel; } + /** + * Set a new log level. This has the immediate effect of changing the log output to the new level. + */ + void SetLogLevel(LogLevel logLevel) { m_logLevel.store(logLevel); } + + /** + * Handle the logging information from common runtime libraries. + * Redirect them to C++ SDK logging system by default. + */ + virtual void Log(LogLevel logLevel, const char* subjectName, const char* formatStr, va_list args); + + protected: + std::atomic<LogLevel> m_logLevel; + /** + * Underlying logging interface used by common runtime libraries. + */ + aws_logger m_logger; + }; + + } // namespace Logging + } // namespace Utils +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/CRTLogging.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/CRTLogging.h new file mode 100644 index 0000000000..5b0e6ac580 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/CRTLogging.h @@ -0,0 +1,31 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> +#include <memory> + +namespace Aws +{ + namespace Utils + { + namespace Logging + { + class CRTLogSystemInterface; + + /** + * Initialize CRT (common runtime libraries) log system to handle loggings from common runtime libraries, including aws-c-auth, aws-c-http, aws-c-event-stream and etc. + */ + AWS_CORE_API void InitializeCRTLogging(const std::shared_ptr<CRTLogSystemInterface>& crtLogSystem); + + /** + * Shutdown CRT (common runtime libraries) log system. + */ + AWS_CORE_API void ShutdownCRTLogging(); + + } // namespace Logging + } // namespace Utils +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/ErrorMacros.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/ErrorMacros.h new file mode 100644 index 0000000000..8783ba9c0a --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/logging/ErrorMacros.h @@ -0,0 +1,57 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once + +#include <aws/core/Core_EXPORTS.h> + +#include <aws/core/utils/logging/LogLevel.h> +#include <aws/core/utils/logging/AWSLogging.h> +#include <aws/core/utils/logging/LogMacros.h> + +#define AWS_OPERATION_CHECK_PTR(PTR, OPERATION, ERROR_TYPE, ERROR) \ +do { \ + if (PTR == nullptr) \ + { \ + AWS_LOGSTREAM_FATAL(#OPERATION, "Unexpected nullptr: " #PTR); \ + return OPERATION##Outcome(Aws::Client::AWSError<ERROR_TYPE>(ERROR, #ERROR, "Unexpected nullptr: " #PTR, false)); \ + } \ +} while (0) + +#define AWS_CHECK(LOG_TAG, CONDITION, ERROR_MESSAGE, RETURN) \ +do { \ + if (!(CONDITION)) \ + { \ + AWS_LOGSTREAM_ERROR(LOG_TAG, ERROR_MESSAGE); \ + return RETURN; \ + } \ +} while (0) + +#define AWS_CHECK_PTR(LOG_TAG, PTR) \ +do { \ + if (PTR == nullptr) \ + { \ + AWS_LOGSTREAM_FATAL(LOG_TAG, "Unexpected nullptr: " #PTR); \ + return; \ + } \ +} while (0) + +#define AWS_OPERATION_CHECK_SUCCESS(OUTCOME, OPERATION, ERROR_TYPE, ERROR, ERROR_MESSAGE) \ +do { \ + if (!OUTCOME.IsSuccess()) \ + { \ + AWS_LOGSTREAM_ERROR(#OPERATION, ERROR_MESSAGE); \ + return OPERATION##Outcome(Aws::Client::AWSError<ERROR_TYPE>(ERROR, #ERROR, ERROR_MESSAGE, false)); \ + } \ +} while (0) + +#define AWS_OPERATION_CHECK_PARAMETER_PRESENT(REQUEST, FIELD, OPERATION, CLIENT_NAMESPACE) \ +do { \ + if (!REQUEST##.##FIELD##HasBeenSet()) \ + { \ + AWS_LOGSTREAM_ERROR(#OPERATION, "Required field: "#FIELD" is not set"); \ + return OPERATION##Outcome(Aws::Client::AWSError<CLIENT_NAMESPACE##Errors>(CLIENT_NAMESPACE##Errors::MISSING_PARAMETER, "MISSING_PARAMETER", "Missing required field ["#FIELD"]", false)); \ + } \ +} while (0) diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/AWSMemory.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/AWSMemory.h index 5b1221917a..125b4e05a5 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/AWSMemory.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/AWSMemory.h @@ -9,6 +9,7 @@ #include <aws/core/utils/UnreferencedParam.h> #include <aws/core/utils/memory/MemorySystemInterface.h> +#include <assert.h> #include <memory> #include <cstdlib> #include <algorithm> @@ -246,7 +247,50 @@ namespace Aws } }; - template< typename T > using UniquePtr = std::unique_ptr< T, Deleter< T > >; + template< typename T, typename D = Deleter< T > > using UniquePtr = std::unique_ptr< T, D >; + + /* + * A UniquePtr that ensures that underlying pointer is set to null on destruction. + * ...thanks to the legacy design, UniquePtr is used as a static global variable that may be destructed twice. + */ + template< typename T, typename D = Deleter< T > > + class UniquePtrSafeDeleted : public UniquePtr< T, D > + { + public: + using UniquePtr<T,D>::UniquePtr; + UniquePtrSafeDeleted(const UniquePtrSafeDeleted&) noexcept = delete; + UniquePtrSafeDeleted(UniquePtrSafeDeleted&&) noexcept = default; + UniquePtrSafeDeleted& operator=( const UniquePtrSafeDeleted<T,D>& r ) noexcept = delete; + UniquePtrSafeDeleted& operator=( UniquePtrSafeDeleted<T,D>&& r ) noexcept + { + if(&r != this) { + UniquePtr<T, D>::operator=(std::move(r)); + r.forceReset(); + } + return *this; + } + UniquePtrSafeDeleted& operator=( std::nullptr_t ) noexcept + { + forceReset(); + return *this; + } + + void forceReset() + { + if(!this->get()) + return; + this->reset(nullptr); + T volatile* newVal = this->get(); // volatile to prohibit optimizing out setting ptr to null + AWS_UNREFERENCED_PARAM(newVal); + // issue happens in Release where asserts are not enabled, so the next statement is for you, my dear reader + assert(newVal == nullptr && this->get() == nullptr); + } + + ~UniquePtrSafeDeleted() + { + forceReset(); + } + }; /** * ::new, ::delete, ::malloc, ::free, std::make_shared, and std::make_unique should not be used in SDK code @@ -255,9 +299,20 @@ namespace Aws template<typename T, typename ...ArgTypes> UniquePtr<T> MakeUnique(const char* allocationTag, ArgTypes&&... args) { + static_assert(!std::is_array<T>::value || std::is_trivial<T>::value, + "This wrapper/function is not designed to support non-trivial arrays."); return UniquePtr<T>(Aws::New<T>(allocationTag, std::forward<ArgTypes>(args)...)); } + template<typename T, typename D = Deleter<T>, typename ...ArgTypes> + UniquePtrSafeDeleted<T, D> MakeUniqueSafeDeleted(const char* allocationTag, ArgTypes&&... args) + { + static_assert(!std::is_array<T>::value || std::is_trivial<T>::value, + "This wrapper/function is not designed to support non-trivial arrays."); + + return UniquePtrSafeDeleted<T, D>(Aws::New<T>(allocationTag, std::forward<ArgTypes>(args)...), D()); + } + template<typename T> struct ArrayDeleter { diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSAllocator.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSAllocator.h index 932408b761..0e680cb9b1 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSAllocator.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSAllocator.h @@ -10,6 +10,7 @@ #include <aws/core/SDKConfig.h> #include <aws/core/utils/memory/AWSMemory.h> #include <aws/core/utils/memory/MemorySystemInterface.h> +#include <aws/crt/StlAllocator.h> #include <memory> #include <cstdlib> @@ -17,54 +18,8 @@ namespace Aws { #ifdef USE_AWS_MEMORY_MANAGEMENT - /** - * Std allocator interface that is used for all STL types in the event that Custom Memory Management is being used. - */ - template <typename T> - class Allocator : public std::allocator<T> - { - public: - - typedef std::allocator<T> Base; - - Allocator() throw() : - Base() - {} - - Allocator(const Allocator<T>& a) throw() : - Base(a) - {} - - template <class U> - Allocator(const Allocator<U>& a) throw() : - Base(a) - {} - - ~Allocator() throw() {} - typedef std::size_t size_type; - - template<typename U> - struct rebind - { - typedef Allocator<U> other; - }; - - typename Base::pointer allocate(size_type n, const void *hint = nullptr) - { - AWS_UNREFERENCED_PARAM(hint); - - return reinterpret_cast<typename Base::pointer>(Malloc("AWSSTL", n * sizeof(T))); - } - - void deallocate(typename Base::pointer p, size_type n) - { - AWS_UNREFERENCED_PARAM(n); - - Free(p); - } - - }; + template< typename T > using Allocator = Aws::Crt::StlAllocator<T>; #ifdef __ANDROID__ #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 @@ -80,7 +35,7 @@ namespace Aws #endif // __ANDROID__ #else - + template< typename T > using Allocator = std::allocator<T>; #endif // USE_AWS_MEMORY_MANAGEMENT diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSArray.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSArray.h new file mode 100644 index 0000000000..f80be9e4a5 --- /dev/null +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSArray.h @@ -0,0 +1,12 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#pragma once +#include <array> + +namespace Aws +{ + template< typename T, std::size_t N > using Array = std::array< T, N >; +} // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSSet.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSSet.h index 6aee204f39..e3ee9a0c6d 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSSet.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSSet.h @@ -10,10 +10,12 @@ #include <aws/core/utils/memory/stl/AWSAllocator.h> #include <set> +#include <unordered_set> namespace Aws { template< typename T > using Set = std::set< T, std::less< T >, Aws::Allocator< T > >; +template< typename T > using UnorderedSet = std::unordered_set< T, std::hash< T >, std::equal_to< T >, Aws::Allocator< T > >; } // namespace Aws diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSString.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSString.h index 3cd013e3f8..8b6b691b84 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSString.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSString.h @@ -104,5 +104,18 @@ using WString = std::basic_string< wchar_t, std::char_traits< wchar_t >, Aws::Al } // namespace Aws +#ifdef USE_AWS_MEMORY_MANAGEMENT +#include <aws/crt/StringUtils.h> - +/* Inject hash method for an Aws::String with a custom allocator to workaround original C++ defect: + * "hash support for std::basic_string with customized allocators was not enabled" + * see LWG 3705: https://en.cppreference.com/w/cpp/string/basic_string/hash */ +namespace std +{ + template<> + struct hash<Aws::String> + { + size_t operator()(const Aws::String& t) const { return Aws::Crt::HashString(t.c_str()); } + }; +} +#endif diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ResponseStream.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ResponseStream.h index e82e6448cd..b4488a7636 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ResponseStream.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/stream/ResponseStream.h @@ -49,14 +49,22 @@ namespace Aws /** * Gives access to underlying stream, but keep in mind that this changes state of the stream */ - inline Aws::IOStream& GetUnderlyingStream() const { return *m_underlyingStream; } + Aws::IOStream& GetUnderlyingStream() const; private: void ReleaseStream(); + void RegisterStream(); + void DeregisterStream(); - Aws::IOStream* m_underlyingStream; + Aws::IOStream* m_underlyingStream = nullptr; + + static const int xindex; + static void StreamCallback(Aws::IOStream::event evt, std::ios_base& str, int idx); }; + /** + * A default IOStream for ResponseStream. + */ class AWS_CORE_API DefaultUnderlyingStream : public Aws::IOStream { public: diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/threading/Executor.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/threading/Executor.h index 36975af513..376abf480a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/threading/Executor.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/threading/Executor.h @@ -42,6 +42,12 @@ namespace Aws return SubmitToThread(std::move(callable)); } + /* explicit _overload_ of the template function above to avoid template bloat */ + bool Submit(std::function<void()>&& callable) + { + return SubmitToThread(std::move(callable)); + } + protected: /** * To implement your own executor implementation, then simply subclass Executor and implement this method. @@ -71,7 +77,7 @@ namespace Aws enum class OverflowPolicy { - QUEUE_TASKS_EVENLY_ACCROSS_THREADS, + QUEUE_TASKS_EVENLY_ACROSS_THREADS, REJECT_IMMEDIATELY }; @@ -81,7 +87,7 @@ namespace Aws class AWS_CORE_API PooledThreadExecutor : public Executor { public: - PooledThreadExecutor(size_t poolSize, OverflowPolicy overflowPolicy = OverflowPolicy::QUEUE_TASKS_EVENLY_ACCROSS_THREADS); + PooledThreadExecutor(size_t poolSize, OverflowPolicy overflowPolicy = OverflowPolicy::QUEUE_TASKS_EVENLY_ACROSS_THREADS); ~PooledThreadExecutor(); /** diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/xml/XmlSerializer.h b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/xml/XmlSerializer.h index d1ca79ffab..bb6fe2ca58 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/xml/XmlSerializer.h +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/xml/XmlSerializer.h @@ -160,6 +160,7 @@ namespace Aws */ XmlDocument(const XmlDocument& other); XmlDocument(XmlDocument&& doc); + XmlDocument(); XmlDocument& operator=(const XmlDocument& other); XmlDocument& operator=(XmlDocument&& other); @@ -197,7 +198,6 @@ namespace Aws static XmlDocument CreateWithRootNode(const Aws::String&); private: - XmlDocument(); void InitDoc(); Aws::External::tinyxml2::XMLDocument* m_doc; @@ -215,4 +215,3 @@ namespace Aws } // namespace Xml } // namespace Utils } // namespace Aws - |