10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
JWKSSignatureValidator.h
1#ifndef TENDUKE_JWK_JWKSVALIDATOR_H
2#define TENDUKE_JWK_JWKSVALIDATOR_H
3
4#include "./JWKS.h"
5#include "./JWKSDownloader.h"
6#include "../crypto/msgauthn/HashAlgorithm.h"
7#include "../jwt/JWTSignatureValidator.h"
8
9#include <memory>
10#include <vector>
11
12namespace tenduke { namespace jwk {
13
30{
31public:
41 const std::shared_ptr<tenduke::jwk::JWKS> &keySet,
42 ::tenduke::crypto::HashAlgorithm validationAlgorithm = ::tenduke::crypto::HashAlgorithm::NONE
43 );
44
45public:
46 bool validate(
47 const tenduke::json::JSONObject *jwtHeader,
48 const char * payload,
49 std::size_t payloadLength,
50 const unsigned char * signatureBytes,
51 std::size_t signatureLengthB
52 ) const override;
53
59 std::vector<std::shared_ptr<const tenduke::crypto::PublicKey>> getVerificationKeys() const override;
60
61protected:
68 virtual std::unique_ptr<tenduke::jwk::JWK> findJWK(const std::string &keyId) const;
69
79 virtual std::unique_ptr<tenduke::jwk::JWK> findRotatedJWK(const tenduke::jwk::JWK &rejectedKey) const;
80
82 virtual void mergeKeys(const tenduke::jwk::JWKS &newKeySet) const;
83
85 virtual void replaceKeys(const tenduke::jwk::JWKS &newKeySet) const;
86
87private:
88 const std::shared_ptr<tenduke::jwk::JWKS> keySet;
91 const tenduke::crypto::HashAlgorithm algorithm;
92};
93
94}}
95
96#endif //TENDUKE_JWK_JWKSVALIDATOR_H
JSON object element.
Definition JSONObject.h:16
virtual std::unique_ptr< tenduke::jwk::JWK > findJWK(const std::string &keyId) const
Locates the key from cache by id.
Definition JWKSSignatureValidator.cpp:110
JWKSSignatureValidator(const std::shared_ptr< tenduke::jwk::JWKS > &keySet, ::tenduke::crypto::HashAlgorithm validationAlgorithm=::tenduke::crypto::HashAlgorithm::NONE)
Constructs new instance.
Definition JWKSSignatureValidator.cpp:155
virtual void mergeKeys(const tenduke::jwk::JWKS &newKeySet) const
Merges keys from newKeySet to the contained keySet.
Definition JWKSSignatureValidator.cpp:141
virtual std::unique_ptr< tenduke::jwk::JWK > findRotatedJWK(const tenduke::jwk::JWK &rejectedKey) const
Locates a replacement for the key, which did not verify the signature of a JWT without "kid"-claim.
Definition JWKSSignatureValidator.cpp:135
virtual void replaceKeys(const tenduke::jwk::JWKS &newKeySet) const
Replaces keys of the contained keySet with the keys from newKeySet.
Definition JWKSSignatureValidator.cpp:148
std::vector< std::shared_ptr< const tenduke::crypto::PublicKey > > getVerificationKeys() const override
Returns the keys in the key set, which are usable for verifying signatures with the validation algori...
Definition JWKSSignatureValidator.cpp:98
bool validate(const tenduke::json::JSONObject *jwtHeader, const char *payload, std::size_t payloadLength, const unsigned char *signatureBytes, std::size_t signatureLengthB) const override
Validates JWT signature.
Definition JWKSSignatureValidator.cpp:19
JSON Web Key Set, a container for one or more tenduke::jwk::JWKs, indexed by the JWK key ID.
Definition JWKS.h:17
Describes a JWK, Json Web Key.
Definition JWK.h:17
Service for validating the JWT-signature.
Definition JWTSignatureValidator.h:18
HashAlgorithm
Currently supported hash algorithms.
Definition HashAlgorithm.h:13
Support for JSON Web Keys.
Definition DynamicJWKSSignatureValidator.h:13
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4