10Duke Enterprise C++ SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
DynamicJWKSSignatureValidator.h
1
#ifndef TENDUKE_JWK_DYNAMICJWKSVALIDATOR_H
2
#define TENDUKE_JWK_DYNAMICJWKSVALIDATOR_H
3
4
#include "./JWKS.h"
5
#include "./JWKSDownloader.h"
6
#include "./JWKSSignatureValidator.h"
7
#include "../crypto/msgauthn/HashAlgorithm.h"
8
#include "../time/Clock.h"
9
10
#include <cstdint>
11
#include <mutex>
12
13
namespace
tenduke
{
namespace
jwk
{
14
28
class
DynamicJWKSSignatureValidator
:
public
tenduke::jwk::JWKSSignatureValidator
29
{
30
public
:
32
static
const
std::int64_t
DEFAULT_MIN_REFRESH_INTERVAL_S
= 300;
33
46
DynamicJWKSSignatureValidator
(
47
const
std::shared_ptr<tenduke::jwk::JWKS> &keySet,
48
const
std::shared_ptr<const tenduke::jwk::JWKSDownloader> &jwksDownloader,
49
std::string jwksUrl,
50
const
std::shared_ptr<const tenduke::time::Clock> &clock,
51
::tenduke::crypto::HashAlgorithm
validationAlgorithm = ::tenduke::crypto::HashAlgorithm::NONE,
52
std::int64_t minRefreshIntervalS =
DEFAULT_MIN_REFRESH_INTERVAL_S
53
);
54
55
protected
:
65
std::unique_ptr<tenduke::jwk::JWK>
findJWK
(
const
std::string &keyId)
const override
;
66
74
std::unique_ptr<tenduke::jwk::JWK>
findRotatedJWK
(
const
tenduke::jwk::JWK
&rejectedKey)
const override
;
75
76
private
:
83
bool
refreshKeys()
const
;
84
85
const
std::shared_ptr<const tenduke::jwk::JWKSDownloader> downloadJWKS;
86
const
std::string jwksURL;
87
const
std::shared_ptr<const tenduke::time::Clock> clock;
88
const
std::int64_t minRefreshIntervalS;
89
91
mutable
std::mutex refreshMutex;
93
mutable
bool
hasRefreshed =
false
;
95
mutable
std::int64_t lastRefreshAt = 0;
96
};
97
98
}}
99
100
#endif
//TENDUKE_JWK_DYNAMICJWKSVALIDATOR_H
tenduke::jwk::DynamicJWKSSignatureValidator::DynamicJWKSSignatureValidator
DynamicJWKSSignatureValidator(const std::shared_ptr< tenduke::jwk::JWKS > &keySet, const std::shared_ptr< const tenduke::jwk::JWKSDownloader > &jwksDownloader, std::string jwksUrl, const std::shared_ptr< const tenduke::time::Clock > &clock, ::tenduke::crypto::HashAlgorithm validationAlgorithm=::tenduke::crypto::HashAlgorithm::NONE, std::int64_t minRefreshIntervalS=DEFAULT_MIN_REFRESH_INTERVAL_S)
Constructs new instance.
Definition
DynamicJWKSSignatureValidator.cpp:109
tenduke::jwk::DynamicJWKSSignatureValidator::DEFAULT_MIN_REFRESH_INTERVAL_S
static const std::int64_t DEFAULT_MIN_REFRESH_INTERVAL_S
Default minimum interval in seconds between key set refreshes.
Definition
DynamicJWKSSignatureValidator.h:32
tenduke::jwk::DynamicJWKSSignatureValidator::findJWK
std::unique_ptr< tenduke::jwk::JWK > findJWK(const std::string &keyId) const override
Locates the key from cache by id.
Definition
DynamicJWKSSignatureValidator.cpp:21
tenduke::jwk::DynamicJWKSSignatureValidator::findRotatedJWK
std::unique_ptr< tenduke::jwk::JWK > findRotatedJWK(const tenduke::jwk::JWK &rejectedKey) const override
Refreshes the cache (unless refreshed within minRefreshIntervalS) and returns the only cached key usa...
Definition
DynamicJWKSSignatureValidator.cpp:52
tenduke::jwk::JWKSSignatureValidator
A tenduke::jwt::JWTSignatureValidator, which determines the validation key and algorithm based on the...
Definition
JWKSSignatureValidator.h:30
tenduke::jwk::JWK
Describes a JWK, Json Web Key.
Definition
JWK.h:17
tenduke::crypto::HashAlgorithm
HashAlgorithm
Currently supported hash algorithms.
Definition
HashAlgorithm.h:13
tenduke::jwk
Support for JSON Web Keys.
Definition
DynamicJWKSSignatureValidator.h:13
tenduke
Root for classes, functions and globals of 10Duke C++ Client.
Definition
APIRequest.h:4
core
core
src
jwk
DynamicJWKSSignatureValidator.h
Generated by
1.17.0