KEYZY C++ Client Library 1.10.2
To develop software that is compiled with a C++ compiler and utilizes the KEYZY service (www.keyzy.io)
Loading...
Searching...
No Matches
Keyzy::KeyzyLicenseActivator Class Reference

Activates and deactivates licenses — online, semi-online, offline, trial, and upgrade flows. The main entry point for most integrations. More...

#include <KeyzyLicenseActivator.h>

Public Member Functions

 KeyzyLicenseActivator (const ProductData &productData)
LicenseStatus activateOnline (const std::string &serialNumber)
LicenseStatus deactivateOnline ()
LicenseStatus activateSemiOnline (const std::string &serialNumber)
LicenseStatus activateSemiOnline ()
LicenseStatus deactivateSemiOnline ()
LicenseStatus activateOffline (const std::string &licenseFilePath)
bool deactivateOffline ()
LicenseStatus activateClientTrial (const std::tm &endTime)
bool deactivateClientTrial ()
HostIdMigrationResult migrateHostIdV1toV2 (HostIdMigrationMode mode)
LicenseStatus upgradeLicense (const std::string &targetSerial)
LicenseStatus upgradeLicense (const std::string &sourceSerial, const std::string &targetSerial)
std::shared_ptr< KeyzyLicenseValidator > getLicenseValidator ()
std::shared_ptr< LicenseDepositHandler > getLicenseDepositHandler ()

Detailed Description

Activates and deactivates licenses — online, semi-online, offline, trial, and upgrade flows. The main entry point for most integrations.

Constructor & Destructor Documentation

◆ KeyzyLicenseActivator()

Keyzy::KeyzyLicenseActivator::KeyzyLicenseActivator ( const ProductData & productData)

Create an instance of KeyzyLicenseActivator that will activate / deactivate licenses for a product defined in ProductData structure

Parameters
productDataStructure that describes a product for which going to set/delete licenses

Member Function Documentation

◆ activateOnline()

LicenseStatus Keyzy::KeyzyLicenseActivator::activateOnline ( const std::string & serialNumber)

Sets the serial number to the device and validate it with KEYZY service If the validation fails, it deletes the serial number from the device only when the serial itself cannot be used (for example LicenseStatus::SERIAL_INVALID).

◆ deactivateOnline()

LicenseStatus Keyzy::KeyzyLicenseActivator::deactivateOnline ( )

Deactivate the license with KEYZY service and delete the serial number from the device

◆ activateSemiOnline() [1/2]

LicenseStatus Keyzy::KeyzyLicenseActivator::activateSemiOnline ( const std::string & serialNumber)

Downloads the license file from KEYZY service with given serial number, validate the license file and keep the license file and serial number in the device. If there is a license file or serial number in the device before, they will be overwriten. If the activation fails, it deletes the license file and the serial number from the device only when the serial itself cannot be used (for example LicenseStatus::SERIAL_INVALID).

Parameters
std::stringserialNumber the license serial number

◆ activateSemiOnline() [2/2]

LicenseStatus Keyzy::KeyzyLicenseActivator::activateSemiOnline ( )

Downloads the license file from KEYZY service with the serial number which was kept before, validate the license file and keep it in the device If the activation fails, it deletes the license file and the serial number from the device only when the serial itself cannot be used (for example LicenseStatus::SERIAL_INVALID).

Parameters
std::stringserialNumber the license serial number

◆ deactivateSemiOnline()

LicenseStatus Keyzy::KeyzyLicenseActivator::deactivateSemiOnline ( )

Checks if the device can reach KEYZY service. Delete the license file. Deactivate the license with KEYZY service.

◆ activateOffline()

LicenseStatus Keyzy::KeyzyLicenseActivator::activateOffline ( const std::string & licenseFilePath)

This is not a real activation, it doesn't connected to KEYZY service. Your user should download the license file on the internet first and that is the activation for KEYZY service. We strongly recommend to set Offline License Life for offline licenses in KEYZY app even they are perpetual licenses.

◆ deactivateOffline()

bool Keyzy::KeyzyLicenseActivator::deactivateOffline ( )

This is not a real deactivation, it doesn't connected to KEYZY service. Deletes the license file form the device only.

◆ activateClientTrial()

LicenseStatus Keyzy::KeyzyLicenseActivator::activateClientTrial ( const std::tm & endTime)

Creates a local (client-only) trial license stored on the device. The expiration is checked locally against the system clock.

For server-side trial licenses, obtain a trial serial either via LicenseDepositHandler::registerTrial() or from your own distribution channel (e.g. your website), then activate it using any of the standard methods: activateOnline(), activateSemiOnline() or activateOffline(). The same applies for validation and deactivation — server-side trials follow the same flow as perpetual and subscription licenses.

Parameters
endTimeDue date of trial license
Returns
LicenseStatus::VALID, LicenseStatus::EXPIRED, LicenseStatus::INVALID
Deprecated
Client-only trials are validated purely against the local clock and have no server-side protection. Use server-side trials (LicenseDepositHandler::registerTrial()) instead. This method will be removed in a future release.

◆ deactivateClientTrial()

bool Keyzy::KeyzyLicenseActivator::deactivateClientTrial ( )

Deletes local (client-only) trial license from the device. Does not affect server-side trial licenses.

Returns
true if it's success, false if it's failed.
Deprecated
Part of the deprecated client-only trial feature. Use server-side trials (LicenseDepositHandler::registerTrial()) instead.

◆ migrateHostIdV1toV2()

HostIdMigrationResult Keyzy::KeyzyLicenseActivator::migrateHostIdV1toV2 ( HostIdMigrationMode mode)

Moves a product released with HostIdScheme::V1 to HostIdScheme::V2 on the end user's device. Construct the activator with HostIdScheme::V2 (the default) and call this on every start, in place of the first step of your start-up flow. A V1 license moves to V2 without user input, also when its license file on the device has run out, as long as the serial is still stored.

Offline activation (activateOffline()) is not supported. Keep a product sold with offline licenses on HostIdScheme::V1, or send each user a new license file made for their V2 host id.

Parameters
modeHow the product activates its licenses.
Returns
status: whether the user can use the product now; handle it as in your start-up flow (e.g. LicenseStatus::VALID continue, LicenseStatus::CLIENT_SERIAL_DOES_NOT_EXIST show the serial form). state: what happened to the move, see HostIdMigrationState. A VALID status does not mean the move has finished.

◆ upgradeLicense() [1/2]

LicenseStatus Keyzy::KeyzyLicenseActivator::upgradeLicense ( const std::string & targetSerial)

Upgrade a license using the stored serial as the source. Reads the currently stored serial number from the device.

Note
This method only performs the upgrade on the KEYZY server. It does not activate or validate the new license, and does not store the target serial on the device. To activate the target serial afterward, use one of the activation methods (e.g. activateOnline, activateSemiOnline).
Parameters
targetSerialTarget serial number to upgrade to
Returns
LicenseStatus::VALID on success, LicenseStatus::CLIENT_SERIAL_DOES_NOT_EXIST if no source serial is stored

◆ upgradeLicense() [2/2]

LicenseStatus Keyzy::KeyzyLicenseActivator::upgradeLicense ( const std::string & sourceSerial,
const std::string & targetSerial )

Upgrade a license by providing both source and target serials explicitly.

Note
This method only performs the upgrade on the KEYZY server. It does not activate or validate the new license, and does not store the target serial on the device. To activate the target serial afterward, use one of the activation methods (e.g. activateOnline, activateSemiOnline).
Parameters
sourceSerialSource serial number (current license)
targetSerialTarget serial number to upgrade to
Returns
LicenseStatus