azure-data-tables
Loading...
Searching...
No Matches
shared_key_lite_policy.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include "azure/data/tables/credentials/named_key_credential.hpp"
7
8#include <azure/core/http/policies/policy.hpp>
9
10#include <memory>
11#include <string>
12
13namespace Azure { namespace Data { namespace Tables { namespace _detail { namespace Policies {
14 class SharedKeyLitePolicy final : public Core::Http::Policies::HttpPolicy {
15 public:
16 explicit SharedKeyLitePolicy(std::shared_ptr<Credentials::NamedKeyCredential> credential)
17 : m_credential{std::move(credential)}
18 {
19 }
20
21 ~SharedKeyLitePolicy() override {}
22
23 std::unique_ptr<HttpPolicy> Clone() const override
24 {
25 return std::make_unique<SharedKeyLitePolicy>(m_credential);
26 }
27
28 std::unique_ptr<Core::Http::RawResponse> Send(
29 Core::Http::Request& request,
30 Core::Http::Policies::NextHttpPolicy nextPolicy,
31 Core::Context const& context) const override
32 {
33 request.SetHeader(
34 "Authorization",
35 "SharedKeyLite " + m_credential->AccountName + ":" + GetSignature(request));
36 return nextPolicy.Send(request, context);
37 }
38
39 std::string GetSignature(const Core::Http::Request& request) const;
40 std::shared_ptr<Credentials::NamedKeyCredential> m_credential;
41 };
42
43}}}}} // namespace Azure::Data::Tables::_detail::Policies