Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
jose_jwks.h
1#ifndef SOURCEMETA_CORE_JOSE_JWKS_H_
2#define SOURCEMETA_CORE_JOSE_JWKS_H_
3
4#ifndef SOURCEMETA_CORE_JOSE_EXPORT
5#include <sourcemeta/core/jose_export.h>
6#endif
7
8// NOLINTBEGIN(misc-include-cleaner)
9#include <sourcemeta/core/jose_error.h>
10// NOLINTEND(misc-include-cleaner)
11
12#include <sourcemeta/core/jose_jwk.h>
13#include <sourcemeta/core/json.h>
14
15#include <cstddef> // std::size_t
16#include <optional> // std::optional
17#include <string_view> // std::string_view
18#include <vector> // std::vector
19
20namespace sourcemeta::core {
21
40class SOURCEMETA_CORE_JOSE_EXPORT JWKS {
41public:
44 explicit JWKS(const JSON &value);
47 explicit JWKS(JSON &&value);
48
50 JWKS(JWKS &&other) noexcept = default;
51 auto operator=(JWKS &&other) noexcept -> JWKS & = default;
52 JWKS(const JWKS &) = delete;
53 auto operator=(const JWKS &) -> JWKS & = delete;
54
57 [[nodiscard]] static auto from(const JSON &value) -> std::optional<JWKS>;
60 [[nodiscard]] static auto from(JSON &&value) -> std::optional<JWKS>;
61
64 [[nodiscard]] auto find(const std::string_view key_id) const noexcept
65 -> const JWK *;
66
68 [[nodiscard]] auto size() const noexcept -> std::size_t {
69 return this->keys_.size();
70 }
71
73 [[nodiscard]] auto empty() const noexcept -> bool {
74 return this->keys_.empty();
75 }
76
77 [[nodiscard]] auto begin() const noexcept { return this->keys_.begin(); }
78 [[nodiscard]] auto end() const noexcept { return this->keys_.end(); }
79
80private:
81 JWKS() = default;
82 static auto parse(const JSON &value, JWKS &result) -> bool;
83
84#if defined(_MSC_VER)
85#pragma warning(disable : 4251)
86#endif
87 std::vector<JWK> keys_;
88#if defined(_MSC_VER)
89#pragma warning(default : 4251)
90#endif
91};
92
93} // namespace sourcemeta::core
94
95#endif
static auto from(JSON &&value) -> std::optional< JWKS >
JWKS(const JSON &value)
auto find(const std::string_view key_id) const noexcept -> const JWK *
auto empty() const noexcept -> bool
Whether the set holds no keys.
Definition jose_jwks.h:73
JWKS(JWKS &&other) noexcept=default
A key set exclusively owns its keys, so it is move-only.
static auto from(const JSON &value) -> std::optional< JWKS >
auto size() const noexcept -> std::size_t
The number of keys in the set.
Definition jose_jwks.h:68
Definition jose_jwk.h:40
Definition json_value.h:39