10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::ee::licensing::impl::KeyListSignatureValidator Class Reference

#include <KeyListSignatureValidator.h>

Detailed Description

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.

Inheritance diagram for tenduke::ee::licensing::impl::KeyListSignatureValidator:
tenduke::jwt::JWTSignatureValidator

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.

Constructor & Destructor Documentation

◆ KeyListSignatureValidator()

tenduke::ee::licensing::impl::KeyListSignatureValidator::KeyListSignatureValidator ( std::vector< std::shared_ptr< const tenduke::crypto::PublicKey > > keys,
::tenduke::crypto::HashAlgorithm algorithm )

Constructs new instance.

Parameters
keysthe keys for verifying the signatures. If empty, no signature validates.
algorithm-

Member Function Documentation

◆ getVerificationKeys()

std::vector< std::shared_ptr< const xdcrypto::PublicKey > > tenduke::ee::licensing::impl::KeyListSignatureValidator::getVerificationKeys ( ) const
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.

Returns
the keys, empty if not available

Reimplemented from tenduke::jwt::JWTSignatureValidator.

◆ validate()

bool tenduke::ee::licensing::impl::KeyListSignatureValidator::validate ( const tenduke::json::JSONObject * jwtHeader,
const char * payload,
std::size_t payloadLength,
const unsigned char * signatureBytes,
std::size_t signatureLengthB ) const
overridevirtual

Validates JWT signature.

Parameters
jwtHeaderJWT-header, can be e.g. used to determine the key and digestAlgorithm used
payloadJWT-payload to verify
payloadLengthlength of the payload
signatureBytesthe signature
signatureLengthBthe signature length
Returns
true if the signature is valid, false if not
Exceptions
tenduke::crypto::CryptoExceptionif there are are cryptographic issues

Implements tenduke::jwt::JWTSignatureValidator.


The documentation for this class was generated from the following files:
  • client/enterprise/api/src/licensing/impl/KeyListSignatureValidator.h
  • client/enterprise/api/src/licensing/impl/KeyListSignatureValidator.cpp