Configuring the Activation

In the C++ SDK, the license is represented by the Activation object. A single instance should be created per license seat — in most cases, one per application run. Your application may manage multiple instances separately if it supports numerous products or configurations.

The Activation class encapsulates license state, communication with the Zentitle2 Licensing API, and persistent local storage. It supports both online and offline activation flows.

Configure the Activation instance.

To initialize activation, construct and configure an ActivationOptions object. This includes your API credentials, product and tenant identifiers, and settings for secure license storage.

The following command will create a new instance of the Activation object in Uninitialized state. Before configuring the activation, collect the Tenant ID and Licensing API URL from the Account -> API Credentials page in the UI.

std::shared_ptr<Activation> activation = Activation::create(
// configure the options by following the instructions below }
);

The following configuration options are available:

  • Tenant ID - ID of the tenant. Can be retrieved from the API Credentials page.

onlineOptions.tenantId = config.TenantId;
  • Product ID - the product for which we are implementing the licensing.

onlineOptions.productId = config.ProductId;

Remember that each "product" has its unique ID. You will need to use different IDs for every product you release.

  • Seat ID - represents the machine, the user, or some other element with which the license should be linked. Because the seat ID usually depends on information that is only available at runtime, it is configured as a function. We recommend using the Device Fingerprint functionality for the machine-specific seat ID.

onlineOptions.seatId = seatId;
  • Storage - stores licensing data that must persist on your application's machine. File-based storage is the common choice for desktop applications.

We recommend using the SecureActivationStorage provided in our SDK, which securely stores license data using the Zentitle2Core library.

options.setActivationStorage(LicenseStorage::Initialize(
    config.UseCoreLibrary, 
    "pathToTheDirectory", 
    "libraryName")
);

This implementation encrypts and protects your license data while storing it in the specified file location.

  • Online Activation - allows the license activation when there is a network connection to the Licensing server. For the online activation, the following options need to be configured:

ZentitleLicensingClient::OnlineActivationOptions onlineOptions;
onlineOptions.licensingApiUrl = config.licensingApiUrl;

options.onlineActivationOptionsOpt = onlineOptions;

licensingApiUrl - Licensing API base URL

  • Offline Activation - In rare cases when a machine lacks a network connection but the license needs to be activated anyway, offline activation can be configured in your application.

  • CoreLibraryManagerConfigProvider - is a lightweight configuration holder used by the Zentitle C++ SDK to specify the location and name of the native Zentitle2Core library (typically a .dll, .so, or .dylib). This library is dynamically loaded at runtime to enable advanced licensing features, such as:

    • Device fingerprinting

    • Secure activation storage

    • Offline activation token handling

CoreLibraryManagerConfigProvider configProvider(libraryDirectory, libraryName);
  • Configuration example

The following example shows how to set up online activation using device fingerprinting and secure storage to ensure a secure and reliable activation process:

	// Setup Activation Options
	ZentitleLicensingClient::ActivationOptions options;
	ZentitleLicensingClient::OnlineActivationOptions onlineOptions;

	onlineOptions.licensingApiUrl = config.ApiUrl;
	onlineOptions.productId = config.ProductId;
	onlineOptions.seatId = seatId;
	onlineOptions.tenantId = config.TenantId;

	ZentitleLicensingClient::OfflineActivationOptions offlineOptions;
	offlineOptions.tenantRsaKeyModulus = config.TenantRsaKeyModulus;

	options.onlineActivationOptionsOpt = onlineOptions;
	options.offlineActivationOptionsOpt = offlineOptions;

	// Get the core library path from the configuration
	std::filesystem::path coreLibraryPath = config.CoreLibPath;
	std::string libraryDirectory = coreLibraryPath.parent_path().string() + "/";
	std::string libraryName = coreLibraryPath.filename().string();

	// Set LicenseStorage
	options.setActivationStorage(LicenseStorage::Initialize(config.UseCoreLibrary, libraryDirectory, libraryName));

	// Create Activation Instance
	CoreLibraryManagerConfigProvider configProvider(libraryDirectory, libraryName);
	std::shared_ptr<Activation> activation = Activation::create(options, configProvider);

Last updated

Was this helpful?