|
10Duke Enterprise C++ SDK
|
#include <DefaultLicenseTokens.h>
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.
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. | |
| 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.
| newJwtParser | - |
| newKey | - |
| parseJson | - |
| signatureValidator | validator, which provides the current keys for serializing the leases. Can be nullptr if the instance is only used for deserializing. |
| algorithm | signature algorithm of the license tokens. NONE and UNKNOWN mean the default, SHA256 (RS256). |
|
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.
| serializedLeases | - |
| tenduke::ee::licensing::LicensingException | if the JSON is not a JSON object, or has unsupported format version |
Implements tenduke::ee::licensing::LicenseTokens.