10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
DefaultLicenseTokens.h
1#ifndef TENDUKE_EE_LICENSING_IMPL_DEFAULTLEASESTORE_H
2#define TENDUKE_EE_LICENSING_IMPL_DEFAULTLEASESTORE_H
3
4#include "../LicenseTokens.h"
5#include "crypto/asymmetric/PublicKey.h"
6#include "crypto/asymmetric/PublicKeyFactory.h"
7#include "crypto/msgauthn/HashAlgorithm.h"
8#include "json/JSONObject.h"
9#include "json/JSONParser.h"
10#include "jwt/JWTParser.h"
11#include "jwt/JWTParserFactory.h"
12#include "jwt/JWTSignatureValidator.h"
13
14#include <map>
15#include <memory>
16#include <mutex>
17#include <string>
18#include <vector>
19
20
21namespace tenduke { namespace ee { namespace licensing { namespace impl {
22
35{
36public:
48 const std::shared_ptr<const tenduke::jwt::JWTParserFactory> &newJwtParser,
49 const std::shared_ptr<const tenduke::crypto::PublicKeyFactory> &newKey,
50 const std::shared_ptr<const tenduke::json::JSONParser> &parseJson,
51 const std::shared_ptr<const tenduke::jwt::JWTSignatureValidator> &signatureValidator,
52 ::tenduke::crypto::HashAlgorithm algorithm = ::tenduke::crypto::HashAlgorithm::SHA256
53 );
54
55 // `tenduke::ee::licensing::LicenseTokens` implementation
56public:
57 std::string serialize(const std::vector<tenduke::ee::licensing::Lease> &leases) const override;
58 std::string serialize(const std::map<std::string, tenduke::ee::licensing::Lease> &leases) const override;
59 std::vector<tenduke::ee::licensing::Lease> deserialize(const std::string &serializedLeases) const override;
60
61private:
63 std::shared_ptr<const tenduke::jwt::JWTParser> createVersion1Parser(const tenduke::json::JSONObject *document) const;
64
66 std::shared_ptr<const tenduke::jwt::JWTParser> createVersion2Parser(const tenduke::json::JSONObject *document) const;
67
69 std::vector<std::shared_ptr<const tenduke::crypto::PublicKey>> rememberKeys(
70 const std::vector<std::shared_ptr<const tenduke::crypto::PublicKey>> &keys
71 ) const;
72
73private:
74 const std::shared_ptr<const tenduke::jwt::JWTParserFactory> newJWTParser;
75 const std::shared_ptr<const tenduke::crypto::PublicKeyFactory> newKey;
76 const std::shared_ptr<const tenduke::json::JSONParser> parseJSON;
77 const std::shared_ptr<const tenduke::jwt::JWTSignatureValidator> signatureValidator;
78 const ::tenduke::crypto::HashAlgorithm algorithm;
79
81 mutable std::mutex knownKeysMutex;
83 mutable std::vector<std::shared_ptr<const tenduke::crypto::PublicKey>> knownKeys;
85 mutable std::vector<std::string> knownKeyPEMs;
86};
87
88}}}}
89
90#endif //TENDUKE_EE_LICENSING_IMPL_DEFAULTLEASESTORE_H
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.
Definition DefaultLicenseTokens.cpp:254
Service for managing licenses tokens.
Definition LicenseTokens.h:17
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.
Definition DefaultLicenseTokens.cpp:254
std::string serialize(const std::map< std::string, tenduke::ee::licensing::Lease > &leases) const override
Serializes given leases in map to a JSON-string.
std::vector< tenduke::ee::licensing::Lease > deserialize(const std::string &serializedLeases) const override
De-serializes given JSON string into leases.
Definition DefaultLicenseTokens.cpp:35
std::string serialize(const std::vector< tenduke::ee::licensing::Lease > &leases) const override
Serializes given leases to a JSON-string.
JSON object element.
Definition JSONObject.h:16
HashAlgorithm
Currently supported hash algorithms.
Definition HashAlgorithm.h:13
Implementations of licensing related services.
Definition DefaultLicenseTokens.h:21
Classes, functions and globals related to 10Duke Enterprise licensing.
Definition AuthzLicensingClient.h:13
Classes, functions and globals of 10Duke Enterprise C++ Client.
Definition APIRequest.h:4
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4