Loading [MathJax]/extensions/tex2jax.js
azure-data-tables
All Classes Files Functions Variables Pages
named_key_credential.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include <azure/core/http/http.hpp>
7
8#include <memory>
9#include <mutex>
10#include <string>
11namespace Azure { namespace Data { namespace Tables { namespace _detail { namespace Policies {
12 class SharedKeyLitePolicy;
13}}}}} // namespace Azure::Data::Tables::_detail::Policies
14
15namespace Azure { namespace Data { namespace Tables { namespace Sas {
16 class AccountSasBuilder;
17 class TablesSasBuilder;
18}}}} // namespace Azure::Data::Tables::Sas
19
20namespace Azure { namespace Data { namespace Tables { namespace Credentials {
21
26 class NamedKeyCredential final {
27 public:
35 explicit NamedKeyCredential(std::string accountName, std::string accountKey)
36 : AccountName{std::move(accountName)}, m_accountKey{std::move(accountKey)}
37 {
38 }
39
46 void Update(std::string accountKey)
47 {
48 std::lock_guard<std::mutex> guard(m_mutex);
49 m_accountKey = std::move(accountKey);
50 }
51
55 const std::string AccountName;
56
57 private:
58 friend class Azure::Data::Tables::_detail::Policies::SharedKeyLitePolicy;
61
62 std::string GetAccountKey() const
63 {
64 std::lock_guard<std::mutex> guard(m_mutex);
65 return m_accountKey;
66 }
67
68 mutable std::mutex m_mutex;
69 std::string m_accountKey;
70 };
71
72 namespace _detail {
73 struct ConnectionStringParts
74 {
75 std::string AccountName;
76 std::string AccountKey;
77 Azure::Core::Url TableServiceUrl;
78 std::shared_ptr<NamedKeyCredential> KeyCredential;
79 };
80
81 ConnectionStringParts ParseConnectionString(const std::string& connectionString);
82 std::string GetDefaultScopeForAudience(const std::string& audience);
83 } // namespace _detail
84
85}}}} // namespace Azure::Data::Tables::Credentials
A NamedKeyCredential is a credential backed by an account's name and one of its access keys.
Definition named_key_credential.hpp:26
NamedKeyCredential(std::string accountName, std::string accountKey)
Initializes a new instance of the NamedKeyCredential.
Definition named_key_credential.hpp:35
void Update(std::string accountKey)
Update the account's access key. This intended to be used when you've regenerated your account's acce...
Definition named_key_credential.hpp:46
const std::string AccountName
The name of the Account.
Definition named_key_credential.hpp:55
AccountSasBuilder is used to generate an account level Shared Access Signature (SAS) for Azure Storag...
Definition account_sas_builder.hpp:134
TableSasBuilder is used to generate a Shared Access Signature (SAS) for an Azure Storage Tables.
Definition tables_sas_builder.hpp:50