AWS SDK for C++  0.12.9
AWS SDK for C++
AWSAuthSigner.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <aws/core/Core_EXPORTS.h>
19 
20 #include <aws/core/Region.h>
22 
23 #include <memory>
24 
25 namespace Aws
26 {
27  namespace Http
28  {
29  class HttpClientFactory;
30  class HttpRequest;
31  } // namespace Http
32 
33  namespace Utils
34  {
35  namespace Crypto
36  {
37  class Sha256;
38  class Sha256HMAC;
39  } // namespace Crypto
40  } // namespace Utils
41 
42  namespace Auth
43  {
44  class AWSCredentials;
45  class AWSCredentialsProvider;
46  } // namespace Auth
47 
48  namespace Client
49  {
50  struct ClientConfiguration;
51 
56  {
57  public:
58  virtual ~AWSAuthSigner() = default;
59 
63  virtual bool SignRequest(Aws::Http::HttpRequest& request) const = 0;
64 
69  virtual bool PresignRequest(Aws::Http::HttpRequest& request, long long expirationInSeconds) const = 0;
70  };
71 
77  {
78 
79  public:
88  AWSAuthV4Signer(const std::shared_ptr<Auth::AWSCredentialsProvider>& credentialsProvider,
89  const char* serviceName, const Aws::String& region, bool signPayloads = true);
90 
91  virtual ~AWSAuthV4Signer();
92 
97  bool SignRequest(Aws::Http::HttpRequest& request) const override;
98 
105  bool PresignRequest(Aws::Http::HttpRequest& request, long long expirationInSeconds = 0) const override;
106 
107  private:
108  Aws::String GenerateSignature(const Aws::Auth::AWSCredentials& credentials, const Aws::String& stringToSign, const Aws::String& simpleDate) const;
109  Aws::String ComputePayloadHash(Aws::Http::HttpRequest&) const;
110  Aws::String GenerateStringToSign(const Aws::String& dateValue, const Aws::String& simpleDate, const Aws::String& canonicalRequestHash) const;
111 
112  std::shared_ptr<Auth::AWSCredentialsProvider> m_credentialsProvider;
113  Aws::String m_serviceName;
114  Aws::String m_region;
117  bool m_signPayloads;
118  };
119 
120  } // namespace Client
121 } // namespace Aws
122 
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
std::unique_ptr< T, Deleter< T > > UniquePtr
Definition: AWSMemory.h:203
#define AWS_CORE_API
Definition: Core_EXPORTS.h:30
JSON (JavaScript Object Notation).