|
10Duke Enterprise C++ SDK
|
#include <KeyListSignatureValidator.h>
A tenduke::jwt::JWTSignatureValidator, which accepts the signature if any of the pre-configured keys verifies it.
The keys are tried in order. The JWT header is ignored: the keys and the algorithm are fixed at construction, so a token cannot choose them. The token does not need a "kid"-claim, because every key is tried. Use only with keys, which are all trusted equally, e.g. the current and the previous signing key of the backend.
Public Member Functions | |
| KeyListSignatureValidator (std::vector< std::shared_ptr< const tenduke::crypto::PublicKey > > keys, ::tenduke::crypto::HashAlgorithm algorithm) | |
| Constructs new instance. | |
| 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. | |
| std::vector< std::shared_ptr< const tenduke::crypto::PublicKey > > | getVerificationKeys () const override |
| Returns the public keys, which the validator currently trusts for verifying signatures. | |
| tenduke::ee::licensing::impl::KeyListSignatureValidator::KeyListSignatureValidator | ( | std::vector< std::shared_ptr< const tenduke::crypto::PublicKey > > | keys, |
| ::tenduke::crypto::HashAlgorithm | algorithm ) |
Constructs new instance.
| keys | the keys for verifying the signatures. If empty, no signature validates. |
| algorithm | - |
|
overridevirtual |
Returns the public keys, which the validator currently trusts for verifying signatures.
The keys can be stored to verify the signatures later, e.g. when there is no network connection. The keys come from memory: this method never loads keys over the network.
The default implementation returns no keys, for validators which cannot provide them.
Reimplemented from tenduke::jwt::JWTSignatureValidator.
|
overridevirtual |
Validates JWT signature.
| jwtHeader | JWT-header, can be e.g. used to determine the key and digestAlgorithm used |
| payload | JWT-payload to verify |
| payloadLength | length of the payload |
| signatureBytes | the signature |
| signatureLengthB | the signature length |
| tenduke::crypto::CryptoException | if there are are cryptographic issues |
Implements tenduke::jwt::JWTSignatureValidator.