azure-core-amqp
Loading...
Searching...
No Matches
claims_based_security.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include "azure/core/amqp/internal/session.hpp"
7
8#include <azure/core/context.hpp>
9
10namespace Azure { namespace Core { namespace Amqp { namespace _detail {
11 class ClaimsBasedSecurityImpl;
12
13 enum class CbsOperationResult
14 {
15 Invalid,
16 Ok,
17 Error,
18 Failed,
19 InstanceClosed,
20 Cancelled,
21 };
22 std::ostream& operator<<(std::ostream& os, CbsOperationResult operationResult);
23
24 enum class CbsOpenResult
25 {
26 Invalid,
27 Ok,
28 Error,
29 Cancelled,
30 };
31 std::ostream& operator<<(std::ostream& os, CbsOpenResult operationResult);
32
33 enum class CbsTokenType
34 {
35 Invalid,
36 Sas,
37 Jwt,
38 };
39
40#if defined(_azure_TESTING_BUILD)
51 class ClaimsBasedSecurity final {
52 public:
58 ClaimsBasedSecurity(Azure::Core::Amqp::_internal::Session const& session);
59 ~ClaimsBasedSecurity() noexcept;
60
61 ClaimsBasedSecurity(ClaimsBasedSecurity const&) = default;
62 ClaimsBasedSecurity& operator=(ClaimsBasedSecurity const&) = default;
63 ClaimsBasedSecurity(ClaimsBasedSecurity&&) noexcept = default;
64 ClaimsBasedSecurity& operator=(ClaimsBasedSecurity&&) noexcept = default;
65
66 CbsOpenResult Open(Context const& context = {});
67 void Close(Context const& context = {});
68 std::tuple<CbsOperationResult, uint32_t, std::string> PutToken(
69 CbsTokenType type,
70 std::string const& audience,
71 std::string const& token,
72 Context const& context = {});
73
74 private:
75 std::shared_ptr<ClaimsBasedSecurityImpl> m_impl;
76 };
77#endif // _azure_TESTING_BUILD
78}}}} // namespace Azure::Core::Amqp::_detail