/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include #include #include #include #include #include #include namespace smithy { class AwsSignerCommon { public: virtual ~AwsSignerCommon() = default; /** * 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 m_clockSkew = {}; }; template class AwsSignerBase : public AwsSignerCommon { public: using IdentityT = IDENTITY_T; static_assert(std::is_base_of::value, "Identity type should inherit AwsIdentity"); using SigningProperties = Aws::UnorderedMap>; using AdditionalParameters = Aws::UnorderedMap>; using HttpRequest = Aws::Http::HttpRequest; using SigningError = Aws::Client::AWSError; using SigningFutureOutcome = Aws::Utils::FutureOutcome, SigningError>; // signer may copy the original httpRequest or create a new one virtual SigningFutureOutcome sign(std::shared_ptr httpRequest, const IdentityT& identity, SigningProperties properties) = 0; virtual ~AwsSignerBase() {}; }; }