pdcomm::License
Class
Installs and inspects the PDComm license of the SECS/GEM library.
class LicenseStarting new SECS/GEM communication (creating or starting an HSMS or SECS-I endpoint, configuring a GEM300 capability catalog) requires a license that grants the module; otherwise the call fails with PDCOMM_LICENSE_REQUIRED. Endpoints that are already running are never stopped.
Licenses are read from text installed with install(), the PDCOMM_LICENSE (text) and PDCOMM_LICENSE_FILE (path) environment variables, a pdcomm.license file next to the executable or the library, and the user and system configuration directories. All sources are merged.
std::ifstream file("pdcomm.license");
std::string text((std::istreambuf_iterator<char>(file)), {});
pdcomm::License::install(text);
std::cout << pdcomm::License::hostId() << '\n' << pdcomm::License::status() << '\n';Notes
- All members are static and thread-safe. Failures throw
std::runtime_error, not pdcomm::Error.
Members
hostId
Method
Returns this host id, PDH1-XXXX-XXXX-XXXX-XXXX.
static std::string hostId()SECS/GEM runtime and developer licenses list the host ids they may run on.
Returns
The host id.
Notes
- Throws
std::runtime_error: when the machine id cannot be read.
install
Method
Installs license text, replacing text installed earlier.
static void install(const std::string &text)The text holds one or more -----BEGIN PDCOMM LICENSE----- blocks. It is accepted when at least one block has a valid signature; an empty string removes the installed text.
Parameters
| Name | Description |
|---|---|
text | UTF-8 license text of at most 1048576 bytes. |
Notes
- Throws
std::runtime_error: when the text is too large, not UTF-8, or holds no block with a valid signature (the earlier installation is kept).
status
Method
Returns the license status of the SECS/GEM library as a JSON object.
static std::string status()The object reports build_date, host_id, program, the license sources found, every license block in licenses with its verification result, and for each module in modules its state (for example licensed, evaluation, missing, expired or host-mismatch), granted and days_left.
Returns
The status JSON text.
Notes
- Throws
std::runtime_error: when the native call fails.