|
10Duke Enterprise C++ SDK
|
#include <LicenseTokenParser.h>
Parses license token into tenduke::ee::licensing::Lease (or into tenduke::ee::licensing::LicensingError).
Public Member Functions | |
| LicenseTokenParser (const std::shared_ptr< const tenduke::jwt::JWTParser > &parseJwt) | |
| Constructs new instance. | |
| virtual LeaseOrError | from (const std::string &licenseToken) const |
| Parses the token. | |
Protected Member Functions | |
| virtual bool | isLicensedItemName (const std::string &claimName, const std::string &claimValue) const |
| Checks if given claim names the licensed item, e.g. | |
|
explicit |
Constructs new instance.
| parseJwt | - |
|
virtual |
Parses the token.
A token with error claims (<item>_errorCode etc.) is an error. Otherwise the token is a lease, if exactly one claim names the licensed item (see isLicensedItemName()) and the token has the lease id (jti). The backend signs also other tokens, e.g. ID-tokens and license release responses, with the same key, so a valid signature alone does not make a token a license token.
The numeric claims (exp, iat, ibb, ibe and rfr) can be integers or decimal numbers, a decimal number is truncated towards zero.
| licenseToken | - |
| tenduke::ee::licensing::InvalidLicenseToken | if the token is neither an error nor a lease: no claim or several claims name the licensed item, or the lease id (jti) is missing. Also if a numeric claim is not a number or is out of the range of std::int64_t. |
| tenduke::jwt::JWTParsingException | if the license token is not a proper JWT |
|
protectedvirtual |
Checks if given claim names the licensed item, e.g.
"item-1": true.
This implementation guesses: any claim with value true, which is not a well-known claim or an error claim, can be the licensed item name. Subclasses check against known licensed item names.
| claimName | - |
| claimValue | - |
Reimplemented in KnownNameLicenseTokenParser, KnownNamesLicenseTokenParser, tenduke::ee::licensing::impl::KnownNameLicenseTokenParser, and tenduke::ee::licensing::impl::KnownNamesLicenseTokenParser.