Configuring the Activation
The license is represented by the Activation
object, and there should be only a single instance of the Activation
class created for every seat in your application. The state of the Activation
can be accessed through the Activation.State
property.
Configure Activation instance
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.
var activation = new Activation(options =>
{ // configure the options by following the instructions below });
There are the following configuration options available:
Tenant ID - ID of the tenant. Can be retrieved from the API Credentials page.
options.WithTenantId(tenantId)
Product ID - the product for which we are implementing the licensing.
options.WithProductId(productId)
Seat ID - represents the machine, the user, or some other element which the license should be linked with. Because the seat ID usually depends on the 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.
options.WithSeatId(() => YourSeatIdFunction())
Storage - stores licensing data that must be persisted on the machine where your application runs. For desktop applications, file-based storage is the common choice.
We recommend using the SecureActivationStorage provided in our SDK, which securely stores license data using the Zentitle2Core library.
options.WithStorage( Client.Zentitle2Core.SecureActivationStorage.WithFile("pathToTheFile") )
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:
Licensing API URL - Licensing API base URL
HTTP Client Factory - HttpClient callback providing an HTTP Client for executing the Licensing API calls. The factory method enables the implementation of the proper HTTP Client's lifetime management, depending on your app's type. See the Guidelines for using HttpClient for more details.
options.WithOnlineActivationSupport(online => online.UseLicensingApi(new Uri(licensingApiUrl)) .UseHttpClientFactory(() => httpClientFactory.CreateClient()))
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.
Logging - to have access to the SDK's logs, your logger factory implementing the ILoggerFactory interface can be plugged in.
options.UseLoggerFactory(new YourLoggerFactory())
State Transition Callback - if you want to "hook your own code" into the activation's state transition logic, you can define a callback, which is executed after the state has been changed.
options.UseStateTransitionCallback((oldState, updatedActivation) => { Console.WriteLine($"Activation state changed from {oldState} to {updatedActivation.State}"); return Task.CompletedTask; });
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:
var activation = new Activation(options =>
{
options
.WithTenant(ZentitleOptions.TenantId)
.WithProduct(ZentitleOptions.ProductId)
.WithSeatId(Zentitle2Core.DeviceFingerprint.GenerateForCurrentMachine);
.WithOnlineActivationSupport(online => online
.UseLicensingApi(new Uri(ZentitleOptions.ZentitleUrl))
.UseHttpClientFactory(() => _httpClient))
.UseStorage(
Zentitle2Core.SecureActivationStorage.WithFile("pathToTheFile")
));
});
Last updated
Was this helpful?