10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
DefaultLicenseTokens Class Reference

#include <DefaultLicenseTokens.h>

Detailed Description

Default implementation of tenduke::ee::licensing::LicenseTokens.

Serializes the leases with the keys, which verify the license tokens (format version 2). The keys are looked up from the known keys: the current keys of the signature validator, and the keys of the previously serialized leases deserialized with this instance. This way leases signed with a previous key are still serialized after the backend has rotated the signing key. Leases, which none of the known keys verifies, are not serialized.

Deserializes both version 1 (single key) and version 2 (list of keys). A license token, which does not parse or validate, is skipped: the other leases are still deserialized.

Inheritance diagram for DefaultLicenseTokens:
tenduke::ee::licensing::LicenseTokens

Public Member Functions

 DefaultLicenseTokens (const std::shared_ptr< const tenduke::jwt::JWTParserFactory > &newJwtParser, const std::shared_ptr< const tenduke::crypto::PublicKeyFactory > &newKey, const std::shared_ptr< const tenduke::json::JSONParser > &parseJson, const std::shared_ptr< const tenduke::jwt::JWTSignatureValidator > &signatureValidator, ::tenduke::crypto::HashAlgorithm algorithm=::tenduke::crypto::HashAlgorithm::SHA256)
 Constructs new instance.
std::string serialize (const std::vector< tenduke::ee::licensing::Lease > &leases) const override
std::string serialize (const std::map< std::string, tenduke::ee::licensing::Lease > &leases) const override
std::vector< tenduke::ee::licensing::Lease > deserialize (const std::string &serializedLeases) const override
 De-serializes given JSON string into leases.
Public Member Functions inherited from tenduke::ee::licensing::LicenseTokens
virtual std::string serialize (const std::vector< tenduke::ee::licensing::Lease > &leases) const =0
 Serializes given leases to a JSON-string.
virtual std::string serialize (const std::map< std::string, tenduke::ee::licensing::Lease > &leases) const =0
 Serializes given leases in map to a JSON-string.

Constructor & Destructor Documentation

◆ DefaultLicenseTokens()

tenduke::ee::licensing::impl::DefaultLicenseTokens::DefaultLicenseTokens ( const std::shared_ptr< const tenduke::jwt::JWTParserFactory > & newJwtParser,
const std::shared_ptr< const tenduke::crypto::PublicKeyFactory > & newKey,
const std::shared_ptr< const tenduke::json::JSONParser > & parseJson,
const std::shared_ptr< const tenduke::jwt::JWTSignatureValidator > & signatureValidator,
::tenduke::crypto::HashAlgorithm algorithm = ::tenduke::crypto::HashAlgorithm::SHA256 )

Constructs new instance.

Parameters
newJwtParser-
newKey-
parseJson-
signatureValidatorvalidator, which provides the current keys for serializing the leases. Can be nullptr if the instance is only used for deserializing.
algorithmsignature algorithm of the license tokens. NONE and UNKNOWN mean the default, SHA256 (RS256).

Member Function Documentation

◆ deserialize()

std::vector< xdlic::Lease > tenduke::ee::licensing::impl::DefaultLicenseTokens::deserialize ( const std::string & serializedLeases) const
overridevirtual

De-serializes given JSON string into leases.

JSON serialized by earlier client versions is supported. A lease, whose license token does not parse or validate, is skipped and logged as a warning: the other leases are still returned.

IMPORTANT: The license tokens are validated with the keys stored in the same JSON. Deserialize only JSON, which your application has decrypted and authenticated, see serialize(): the returned leases are only as trustworthy as the storage of the JSON.

Parameters
serializedLeases-
Returns
-
Exceptions
tenduke::ee::licensing::LicensingExceptionif the JSON is not a JSON object, or has unsupported format version

Implements tenduke::ee::licensing::LicenseTokens.


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