12 #include <azure/core/credentials/credentials.hpp>
18 #include <shared_mutex>
22 namespace Azure {
namespace Identity {
namespace _detail {
28 #if !defined(TESTING_BUILD)
32 #if !defined(TESTING_BUILD)
38 virtual void OnBeforeCacheWriteLock()
const {};
41 virtual void OnBeforeItemWriteLock()
const {};
49 struct CacheKeyComparator
51 bool operator()(CacheKey
const& lhs, CacheKey
const& rhs)
const
53 return std::tie(lhs.Scope, lhs.TenantId) < std::tie(rhs.Scope, rhs.TenantId);
59 Core::Credentials::AccessToken AccessToken;
60 std::shared_timed_mutex ElementMutex;
63 mutable std::map<CacheKey, std::shared_ptr<CacheValue>, CacheKeyComparator> m_cache;
64 mutable std::shared_timed_mutex m_cacheMutex;
67 TokenCache(TokenCache
const&) =
delete;
68 TokenCache& operator=(TokenCache
const&) =
delete;
72 std::shared_ptr<CacheValue>
const& item,
73 DateTime::duration minimumExpiration,
74 std::chrono::system_clock::time_point now);
77 std::shared_ptr<CacheValue> GetOrCreateValue(
79 DateTime::duration minimumExpiration)
const;
82 TokenCache() =
default;
83 ~TokenCache() =
default;
98 Core::Credentials::AccessToken GetToken(
99 std::string
const& scopeString,
100 std::string
const& tenantId,
101 DateTime::duration minimumExpiration,
102 std::function<Core::Credentials::AccessToken()>
const& getNewToken)
const;
Azure SDK abstractions.
Definition: azure_cli_credential.hpp:22