### Install NodeJS Dependencies Source: https://www.softactivate.com/doc Run 'npm install' in the respective subfolders of the SDK to install required dependency packages for the NodeJS licensing server. ```bash npm install ``` -------------------------------- ### Trial License Implementation Source: https://www.softactivate.com/doc Example demonstrating how to implement trial versions with grace periods and expiration handling. ```APIDOC ## Trial License Implementation ### Description This example demonstrates how to implement trial versions with grace periods and expiration handling using the SoftActivate SDK. ### Method N/A (Code Example) ### Endpoint N/A ### Parameters N/A ### Request Example ```csharp using SoftActivate.Licensing; public class TrialManager { private LicenseTemplate template; private KeyValidator validator; public bool IsTrialValid() { // Check if trial period has expired validator = new KeyValidator(template); validator.SetKey(GetStoredTrialKey()); if (!validator.IsValid()) return false; // Check expiration date DateTime expiryDate = validator.GetValidationDataDateTime("ExpiryDate"); if (DateTime.Now > expiryDate) { // Grace period check TimeSpan gracePeriod = TimeSpan.FromDays(7); if (DateTime.Now > expiryDate.Add(gracePeriod)) return false; // Show grace period warning ShowGracePeriodWarning(expiryDate.Add(gracePeriod) - DateTime.Now); } return true; } public int GetRemainingTrialDays() { DateTime expiryDate = validator.GetValidationDataDateTime("ExpiryDate"); TimeSpan remaining = expiryDate - DateTime.Now; return Math.Max(0, remaining.Days); } } ``` ### Response N/A (This is a client-side code example) ``` -------------------------------- ### Run NodeJS Licensing Server Source: https://www.softactivate.com/doc Execute 'node index.js' in the lms folder to start the SoftActivate Licensing Server. It defaults to listening on port 3001. ```bash node index.js ``` -------------------------------- ### Basic License Key Validation (C#) Source: https://www.softactivate.com/doc Example demonstrating how to perform basic license key validation using the SoftActivate SDK in C#. ```APIDOC ## Basic License Key Validation (C#) ### Description This example demonstrates how to implement basic license key validation in your C# application using the SoftActivate SDK. ### Method N/A (Code Example) ### Endpoint N/A ### Parameters N/A ### Request Example ```csharp using SoftActivate.Licensing; // Create a license template (use your own keys in production) LicenseTemplate template = new LicenseTemplate(); template.LoadXml("..."); // Validate a license key KeyValidator validator = new KeyValidator(template); validator.SetKey("YOUR-LICENSE-KEY-HERE"); if (validator.IsValid()) { Console.WriteLine("License is valid!"); // Get validation data string productName = validator.GetValidationDataString("ProductName"); int version = validator.GetValidationDataInteger("Version"); Console.WriteLine($"Product: {productName}, Version: {version}"); } else { Console.WriteLine("Invalid license key"); } ``` ### Response N/A (This is a client-side code example) ``` -------------------------------- ### Basic License Key Validation (C++) Source: https://www.softactivate.com/doc Example demonstrating how to perform basic license key validation using the SoftActivate SDK in C++. ```APIDOC ## Basic License Key Validation (C++) ### Description This example demonstrates how to implement basic license key validation in your C++ application using the SoftActivate SDK. ### Method N/A (Code Example) ### Endpoint N/A ### Parameters N/A ### Request Example ```cpp #include "licensing.h" // Create template and validator LicenseTemplate* pTemplate = CreateLicenseTemplate(); pTemplate->LoadXml("..."); KeyValidator* pValidator = CreateKeyValidator(pTemplate); pValidator->SetKey("YOUR-LICENSE-KEY-HERE"); if (pValidator->IsValid()) { printf("License is valid!\n"); // Get validation data const char* productName = pValidator->GetValidationDataString("ProductName"); int version = pValidator->GetValidationDataInteger("Version"); printf("Product: %s, Version: %d\n", productName, version); } else { printf("Invalid license key\n"); } // Clean up pValidator->Release(); pTemplate->Release(); ``` ### Response N/A (This is a client-side code example) ``` -------------------------------- ### LicenseTemplate::GetHeader Source: https://www.softactivate.com/doc Gets the current license key header. ```APIDOC ## GET LicenseTemplate::GetHeader ### Description Gets the license key header. ### Return Values - **string** - The license key header. ``` -------------------------------- ### Online License Activation Source: https://www.softactivate.com/doc Implement online activation using LicensingClient. This involves getting the hardware ID, creating the client with server details, and initiating the activation process. ```csharp using SoftActivate.Licensing; public class OnlineActivation { private LicensingClient client; private string hardwareId; public async Task ActivateLicense(string licenseKey) { try { // Get hardware ID hardwareId = KeyHelper.GetHardwareId(); // Create licensing client LicenseTemplate template = LoadTemplate(); client = new LicensingClient( "https://your-server.com/activate", template, licenseKey, null, hardwareId ); // Set up event handlers client.LicensingComplete += OnActivationComplete; client.LicensingException += OnActivationError; // Start activation process client.BeginAcquireLicense(); return true; } catch (Exception ex) { HandleActivationError(ex); return false; } } private void OnActivationComplete() { // Store activation data SaveActivationData(client.ActivationKey, client.HardwareId); MessageBox.Show("License activated successfully!"); } private void OnActivationError(Exception ex) { MessageBox.Show($"Activation failed: {ex.Message}"); } } ``` -------------------------------- ### LicenseTemplate::GetFooter Source: https://www.softactivate.com/doc Gets the current license key footer. ```APIDOC ## GET LicenseTemplate::GetFooter ### Description Gets the license key footer. ### Return Values - **string** - The license key footer. ``` -------------------------------- ### LicenseTemplate::GetEncoding Source: https://www.softactivate.com/doc Gets the current encoding used for license keys. ```APIDOC ## GET LicenseTemplate::GetEncoding ### Description Gets the encoding used for the license keys. ### Return Values - **encoding** (LICENSE_KEY_ENCODING) - The encoding used (ENCODING_BASE32X or ENCODING_BASE64X). ``` -------------------------------- ### Registering the SDK with a License Key Source: https://www.softactivate.com/doc Use this method to initialize the SDK for license key or key pair generation. Do not use this in end-user applications. ```cpp SDKRegistration::SetLicenseKey() ``` -------------------------------- ### Initialize UI License Manager Source: https://www.softactivate.com/doc Use UILicenseManager for easy UI integration. Load the license template from resources and check license validity on startup, showing the dialog if invalid. ```csharp using SoftActivate.Licensing.UI; public partial class MainForm : Form { private UILicenseManager licenseManager; public MainForm() { InitializeComponent(); InitializeLicensing(); } private void InitializeLicensing() { // Create license template LicenseTemplate template = new LicenseTemplate(); template.LoadXml(GetEmbeddedTemplate()); // Load from resources // Initialize UI license manager licenseManager = new UILicenseManager(template); licenseManager.LicenseAcquired += OnLicenseAcquired; licenseManager.LicenseExpired += OnLicenseExpired; // Check license on startup if (!licenseManager.IsLicenseValid()) { licenseManager.ShowLicenseDialog(); } } private void OnLicenseAcquired(object sender, EventArgs e) { // License successfully acquired/validated EnableFullFeatures(); } private void OnLicenseExpired(object sender, EventArgs e) { // Handle license expiration ShowExpirationDialog(); } } ``` -------------------------------- ### Trial License Management (C#) Source: https://www.softactivate.com/doc Implement trial functionality with grace periods using this C# class. It checks for expiration and manages remaining trial days. ```csharp using SoftActivate.Licensing; public class TrialManager { private LicenseTemplate template; private KeyValidator validator; public bool IsTrialValid() { // Check if trial period has expired validator = new KeyValidator(template); validator.SetKey(GetStoredTrialKey()); if (!validator.IsValid()) return false; // Check expiration date DateTime expiryDate = validator.GetValidationDataDateTime("ExpiryDate"); if (DateTime.Now > expiryDate) { // Grace period check TimeSpan gracePeriod = TimeSpan.FromDays(7); if (DateTime.Now > expiryDate.Add(gracePeriod)) return false; // Show grace period warning ShowGracePeriodWarning(expiryDate.Add(gracePeriod) - DateTime.Now); } return true; } public int GetRemainingTrialDays() { DateTime expiryDate = validator.GetValidationDataDateTime("ExpiryDate"); TimeSpan remaining = expiryDate - DateTime.Now; return Math.Max(0, remaining.Days); } } ``` -------------------------------- ### SDKRegistration::SetLicenseKey Source: https://www.softactivate.com/doc Initializes the SDK with a purchased license key. This method is crucial for license key generation and public/private key pair generation. If not called, the SDK operates in DEMO mode. ```APIDOC ## SDKRegistration::SetLicenseKey ### Description Initializes the SDK by entering the purchased SDK license key. This method must NOT be called if the SDK will only be used for license key validation or client-side software activation. This should be the first method called before using the SDK for license key generation or public/private key pair generation. If this method is not called when the SDK will be used for license key generation or public/private key pair generation, the SDK will function in DEMO mode. ### Method `static void` (C++), `static void` (C#) ### Endpoint N/A (This is a static method within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // C++ SDKRegistration::SetLicenseKey("YOUR-LICENSE-KEY-HERE"); ``` ```csharp // C# SDKRegistration.SetLicenseKey("YOUR-LICENSE-KEY-HERE"); ``` ### Response #### Success Response (void) None. #### Response Example N/A ``` -------------------------------- ### LicensingClient::AcquireLicense Source: https://www.softactivate.com/doc Sends the product key and hardware ID to the licensing service to acquire an activation key. ```APIDOC ## void LicensingClient::AcquireLicense() ### Description Contacts the licensing service over the internet to validate the license and obtain a signed activation key. ``` -------------------------------- ### Basic License Key Validation (C++) Source: https://www.softactivate.com/doc This C++ snippet demonstrates how to validate a license key using the SDK. Remember to release resources after use. ```cpp #include "licensing.h" // Create template and validator LicenseTemplate* pTemplate = CreateLicenseTemplate(); pTemplate->LoadXml("..."); KeyValidator* pValidator = CreateKeyValidator(pTemplate); pValidator->SetKey("YOUR-LICENSE-KEY-HERE"); if (pValidator->IsValid()) { printf("License is valid!\n"); // Get validation data const char* productName = pValidator->GetValidationDataString("ProductName"); int version = pValidator->GetValidationDataInteger("Version"); printf("Product: %s, Version: %d\n", productName, version); } else { printf("Invalid license key\n"); } // Clean up pValidator->Release(); pTemplate->Release(); ``` -------------------------------- ### Running the UILicenseManager Source: https://www.softactivate.com/doc Invokes the registration logic and HTML-based UI for .NET applications using the LicensingUI.Net.dll assembly. ```csharp UILicenseManager.Run() ``` -------------------------------- ### KeyHelper Methods Source: https://www.softactivate.com/doc Methods for device identification and security checks. ```APIDOC ## KeyHelper::GetCurrentHardwareId ### Description Returns a string which uniquely identifies the device (computer) on which the method is called. ### Response - **Return Value** (string) - The hardware id string. --- ## KeyHelper::MatchCurrentHardwareId ### Description Checks if the supplied hardware id string matches this computer. ### Parameters #### Request Body - **hardwareId** (string) - Required - The hardware id to be matched to the current hardware state. ### Response - **Return Value** (bool) - Specifies if the computer matches the supplied hardware id. ``` -------------------------------- ### ShareIt Integration Source: https://www.softactivate.com/doc Configures the SoftActivate Licensing Server to automatically generate license keys for ShareIt products. ```APIDOC ## POST /ShareIt.ashx ### Description Handles remote license generation requests from ShareIt. Configure this URL in the ShareIt control panel as the remote CGI license generator. ### Method POST ### Endpoint /ShareIt.ashx ``` -------------------------------- ### RegNow Integration Source: https://www.softactivate.com/doc Configures the SoftActivate Licensing Server to automatically generate license keys for RegNow products. ```APIDOC ## POST /RegNow.ashx ### Description Handles remote license generation requests from RegNow. Configure this URL in the RegNow control panel as the remote CGI license generator. ### Method POST ### Endpoint /RegNow.ashx ``` -------------------------------- ### LicensingClient Methods Source: https://www.softactivate.com/doc Methods for managing license validation, status, and configuration. ```APIDOC ## LicensingClient::SetLicenseTemplateId ### Description Sets the template ID string that identifies the license configuration. ### Parameters #### Request Body - **templateId** (const char*) - Required - The template ID string that identifies the license configuration. ## LicensingClient::ValidateLicense ### Description Validates a license using the provided validation arguments and returns detailed validation results. ### Parameters #### Request Body - **args** (LicenseValidationArgs*) - Required - Pointer to a LicenseValidationArgs object containing the license key and validation data. ### Response - **Result** (LicenseValidationResult*) - Returns a pointer to a LicenseValidationResult object or NULL if validation fails. ## LicensingClient::IsLicenseValid ### Description Checks if the activation key signature is valid and if the hardware ID matches the computer. ### Response - **Result** (bool) - true if valid, false otherwise. ## LicensingClient::GetLicenseActivationStatus ### Description Retrieves the activation status after a call to IsLicenseValid(). ### Response - **Result** (int) - A LICENSE_STATUS value (0: Valid, 1: Invalid, 12: InvalidHardwareId, 13: Expired, 14: InvalidActivationKey, 15: PaymentRequired). ## LicensingClient::GetLicenseExpirationDate ### Description Retrieves the expiration date of the license. ### Parameters #### Request Body - **year** (int*) - Required - Pointer to an integer receiving the expiration year. - **month** (int*) - Required - Pointer to an integer receiving the expiration month (1-12). - **day** (int*) - Required - Pointer to an integer receiving the expiration day (1-31). ## LicensingClient::SetTimeValidationMethod ### Description Sets how the SDK should validate time-based license restrictions. ### Parameters #### Request Body - **method** (int) - Required - Time validation method: 0 (PREFER_INTERNET_TIME), 1 (USE_INTERNET_TIME), or 2 (USE_LOCAL_TIME). ``` -------------------------------- ### Implement Hardware Locking Source: https://www.softactivate.com/doc Use this class to validate if a license key is tied to the current hardware. If the hardware has changed, it attempts to validate the change with a server. ```csharp public class HardwareLockingManager { public bool ValidateHardwareLock(string licenseKey, string storedHardwareId) { // Get current hardware ID string currentHardwareId = KeyHelper.GetHardwareId(); // Compare with stored hardware ID if (storedHardwareId != currentHardwareId) { // Hardware has changed - validate with server return ValidateHardwareChange(licenseKey, currentHardwareId); } return true; } private bool ValidateHardwareChange(string licenseKey, string newHardwareId) { try { // Contact server to validate hardware change LicensingClient client = new LicensingClient( serverUrl, template, licenseKey, null, newHardwareId ); // Server will decide if hardware change is allowed client.AcquireLicense(); // Update stored hardware ID UpdateStoredHardwareId(newHardwareId); return true; } catch (Exception ex) { // Hardware change not allowed or server error ShowHardwareChangeError(ex.Message); return false; } } } ``` -------------------------------- ### LicenseTemplate Class Methods Source: https://www.softactivate.com/doc Methods for configuring the structure of license keys. ```APIDOC ## LicenseTemplate::SetNumberOfGroups ### Description Sets the number of character groups a license key contains. ### Parameters #### Request Body - **numGroups** (unsigned) - Required - The number of character groups. ## LicenseTemplate::GetNumberOfGroups ### Description Gets the number of character groups contained by a license key. ### Response - **Result** (unsigned) - The number of groups. ## LicenseTemplate::SetCharactersPerGroup ### Description Sets the number of characters in each license key character group. ### Parameters #### Request Body - **charsPerGroup** (unsigned) - Required - The number of characters per group. ## LicenseTemplate::GetCharactersPerGroup ### Description Gets the number of characters in each license key character group. ### Response - **Result** (unsigned) - The number of characters per group. ## LicenseTemplate::SetVersion ### Description Sets the license key template version. ### Parameters #### Request Body - **version** (unsigned) - Required - The template version. ``` -------------------------------- ### LicenseTemplate Methods Source: https://www.softactivate.com/doc Methods for managing license template configuration, including JSON serialization, key management, and service URL settings. ```APIDOC ## LicenseTemplate::LoadJson ### Description Loads the template parameters from a JSON string. ### Parameters #### Request Body - **jsonTemplate** (const char*) - Required - A JSON string containing the template parameters. ### Remarks This method throws an exception if the JSON template string is invalid. --- ## LicenseTemplate::SaveJson ### Description Saves the JSON representation of the template into a string. ### Parameters #### Query Parameters - **savePrivateKey** (bool) - Optional - Whether to include the private key in the JSON output. ### Response - **Return Value** (const char*) - Pointer to a string containing a UTF-8 encoded JSON representation. Statically allocated, do not free. --- ## LicenseTemplate::SetPublicKeyCertificate ### Description Sets the public key certificate used for license key validation. ### Parameters #### Request Body - **base64Certificate** (const char*) - Required - Base64-encoded public key certificate string. --- ## LicenseTemplate::SetPrivateKey ### Description Sets the private key used for license key generation and signing. ### Parameters #### Request Body - **base64PrivateKey** (const char*) - Required - Base64-encoded private key string. ``` -------------------------------- ### LicenseTemplate::LoadXml Source: https://www.softactivate.com/doc Loads license key template parameters from an XML string. ```APIDOC ## LicenseTemplate::LoadXml ### Description Loads license key template parameters from an XML string. ### Method `void LicenseTemplate::LoadXml(char * xmlString);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **xmlString** (char *) - Required - The XML template representation string, UTF-8 encoded. ### Request Example ```json { "xmlString": "128" } ``` ### Response #### Success Response (200) None #### Response Example None ### Remarks This method throws an exception if the template string is invalid. ``` -------------------------------- ### LicenseTemplate::GetVersion Source: https://www.softactivate.com/doc Retrieves the current version of the license key template. ```APIDOC ## GET LicenseTemplate::GetVersion ### Description Retrieves the license key template version. ### Return Values The license key template version. Currently, a value of 1 is returned. ``` -------------------------------- ### LicenseTemplate::SetFooter Source: https://www.softactivate.com/doc Sets an optional line of text following the license key. ```APIDOC ## POST LicenseTemplate::SetFooter ### Description Sets the contents of an optional line following the license key. ### Parameters #### Request Body - **header** (string) - Required - The footer string. ``` -------------------------------- ### LicenseTemplate::SetHeader Source: https://www.softactivate.com/doc Sets an optional line of text preceding the license key. ```APIDOC ## POST LicenseTemplate::SetHeader ### Description Sets the contents of an optional line of text preceding the license key. ### Parameters #### Request Body - **header** (string) - Required - The header string. ``` -------------------------------- ### Validate License with Error Handling Source: https://www.softactivate.com/doc This class provides a comprehensive license validation process, checking format, expiration, and hardware ID. It includes detailed error handling for various licensing exceptions. ```csharp public class LicenseValidator { public ValidationResult ValidateLicense(string licenseKey) { ValidationResult result = new ValidationResult(); try { KeyValidator validator = new KeyValidator(template); validator.SetKey(licenseKey); if (!validator.IsValid()) { result.IsValid = false; result.ErrorCode = "INVALID_KEY"; result.Message = "The license key format is invalid"; return result; } // Check expiration if (validator.HasValidationData("ExpiryDate")) { DateTime expiry = validator.GetValidationDataDateTime("ExpiryDate"); if (DateTime.Now > expiry) { result.IsValid = false; result.ErrorCode = "EXPIRED"; result.Message = $"License expired on {expiry:yyyy-MM-dd}"; return result; } } // Check hardware lock if (validator.HasValidationData("HardwareId")) { string expectedHw = validator.GetValidationDataString("HardwareId"); string currentHw = KeyHelper.GetHardwareId(); if (expectedHw != currentHw) { result.IsValid = false; result.ErrorCode = "HARDWARE_MISMATCH"; result.Message = "License is locked to different hardware"; return result; } } result.IsValid = true; result.Message = "License is valid"; } catch (LicensingException ex) { result.IsValid = false; result.ErrorCode = "LICENSING_ERROR"; result.Message = ex.Message; } catch (Exception ex) { result.IsValid = false; result.ErrorCode = "UNEXPECTED_ERROR"; result.Message = "An unexpected error occurred during validation"; } return result; } } ``` -------------------------------- ### License Class Methods Source: https://www.softactivate.com/doc Methods for loading and saving license data in XML or JSON formats. ```APIDOC ## License::LoadXml ### Description Loads license information from an XML string. ## License::SaveXml ### Description Saves the license information to an XML string. ## License::LoadJson ### Description Loads license information from a JSON string. ## License::SaveJson ### Description Saves the license information to a JSON string. ``` -------------------------------- ### Basic License Key Validation (C#) Source: https://www.softactivate.com/doc Use this snippet to validate a license key in your C# application. Ensure you have a valid LicenseTemplate loaded. ```csharp using SoftActivate.Licensing; // Create a license template (use your own keys in production) LicenseTemplate template = new LicenseTemplate(); template.LoadXml("..."); // Validate a license key KeyValidator validator = new KeyValidator(template); validator.SetKey("YOUR-LICENSE-KEY-HERE"); if (validator.IsValid()) { Console.WriteLine("License is valid!"); // Get validation data string productName = validator.GetValidationDataString("ProductName"); int version = validator.GetValidationDataInteger("Version"); Console.WriteLine($"Product: {productName}, Version: {version}"); } else { Console.WriteLine("Invalid license key"); } ``` -------------------------------- ### LicensingClient Class Source: https://www.softactivate.com/doc The LicensingClient class handles communication with the licensing service for activation and validation. ```APIDOC ## LicensingClient Class ### Description Manages the client-side interaction with the SoftActivate Licensing Server for license acquisition and activation status checks. ### Methods - **AcquireLicense()**: Requests a license from the server. - **ValidateLicense()**: Performs a validation check against the server. - **GetLicenseActivationStatus()**: Returns the current activation status of the license. ``` -------------------------------- ### LicensingClient::GetActivationKey Source: https://www.softactivate.com/doc Retrieves the activation key returned by the licensing service. ```APIDOC ## const char * LicensingClient::GetActivationKey() ### Description Retrieves the activation key after a successful license acquisition. ### Response - **Return Value** (const char *) - Pointer to the activation key string, or NULL if not acquired. ``` -------------------------------- ### LicenseValidationArgs Class Methods Source: https://www.softactivate.com/doc Methods for setting validation data for a license key. ```APIDOC ## LicenseValidationArgs::SetIntLicenseKeyValidationData ### Description Sets integer validation data for the license key. ## LicenseValidationArgs::SetStringLicenseKeyValidationData ### Description Sets string validation data for the license key. ## LicenseValidationArgs::SetDateLicenseKeyValidationData ### Description Sets date validation data for the license key. ## LicenseValidationArgs::SetLicenseKeyValidationData ### Description Sets raw binary validation data for the license key. ``` -------------------------------- ### LicenseTemplate::EnumDataFields Source: https://www.softactivate.com/doc Enumerates license key data fields. ```APIDOC ## GET LicenseTemplate::EnumDataFields ### Description Enumerates license key data fields. ### Return Values - **bool** - Returns true if a field was retrieved, false otherwise. ``` -------------------------------- ### LicenseTemplate::SetSignatureSize Source: https://www.softactivate.com/doc Sets the license key signature size. ```APIDOC ## LicenseTemplate::SetSignatureSize ### Description Sets the license key signature size. ### Method `void LicenseTemplate::SetSignatureSize(unsigned size);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **size** (unsigned) - Required - The desired size for the license key signature. The size must be in the 76-322 range. ### Request Example ```json { "size": 128 } ``` ### Response #### Success Response (200) None #### Response Example None ### Remarks The license key signature size governs license key security. Care must be taken when choosing the signature size. ``` -------------------------------- ### LicensingClient::SetLicenseTemplate Source: https://www.softactivate.com/doc Sets the license template for the licensing client. ```APIDOC ## void LicensingClient::SetLicenseTemplate(LicenseTemplate * tmpl) ### Description Sets the license template which defines the license key format, validation parameters, and cryptographic settings. ### Parameters - **tmpl** (LicenseTemplate *) - Required - Pointer to the license template object. ``` -------------------------------- ### LicenseTemplate::GetDataSize Source: https://www.softactivate.com/doc Retrieves the size of data embedded in the license key. ```APIDOC ## GET LicenseTemplate::GetDataSize ### Description Retrieves the size of data embedded in the license key. ### Return Values - **unsigned** - The size in bits of the embedded license key data. ``` -------------------------------- ### LicenseTemplate::SetEncoding Source: https://www.softactivate.com/doc Sets the character encoding for the license key. ```APIDOC ## POST LicenseTemplate::SetEncoding ### Description Sets the character encoding for the license key. ### Parameters #### Request Body - **encoding** (LICENSE_KEY_ENCODING) - Required - The character encoding (ENCODING_BASE32X or ENCODING_BASE64X). ``` -------------------------------- ### SDKRegistration::IsRegistered Source: https://www.softactivate.com/doc Checks if the SDK has been registered with a valid license key. Returns true if registered, false otherwise. ```APIDOC ## SDKRegistration::IsRegistered ### Description Checks if the SDK has been registered with a valid license key. ### Method `static bool` (C++), `static bool` (C#) ### Endpoint N/A (This is a static method within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // C++ if (SDKRegistration::IsRegistered()) { // SDK is registered } ``` ```csharp // C# if (SDKRegistration.IsRegistered()) { // SDK is registered } ``` ### Response #### Success Response (bool) - **true** (bool) - The SDK has been successfully registered with a valid license key. - **false** (bool) - The SDK has not been registered or the license key is invalid. #### Response Example ```json true ``` ```json false ``` ``` -------------------------------- ### LicenseTemplate::EnumDataFields Source: https://www.softactivate.com/doc Enumerates the fields of data used for license key validation. ```APIDOC ## LicenseTemplate::EnumDataFields ### Description Enumerates the fields of data used for license key validation. ### Method `bool EnumValidationFields(void **enumHandle, char_t * fieldName, unsigned * fieldNameSize, FIELD_TYPE * fieldType, unsigned * fieldSize, unsigned * startPos);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **enumHandle** (void **) - Input/Output - Pointer to a pointer used to store a handle to the enumeration state. A pointer to a NULL handle must be passed at the first call. * **fieldName** (char_t *) - Input/Output - Pointer to a buffer which will be filled with the field name. * **fieldNameSize** (unsigned *) - Input/Output - Pointer to an unsigned which will receive the size of the field name string. At input this must contain the size of the buffer. * **fieldType** (FIELD_TYPE *) - Output - Pointer who will receive the type of the field. * **fieldSize** (unsigned *) - Output - Pointer to an unsigned who will receive the field size in bits. * **startPos** (unsigned *) - Output - Pointer to an unsigned who will receive the field start position in license key data. ### Request Example None ### Response #### Success Response (200) * **return_value** (bool) - If the enumeration is over, returns false and the output parameters are not filled. Otherwise returns true. ### Remarks None. ``` -------------------------------- ### KeyHelper::DetectClockManipulation Source: https://www.softactivate.com/doc Checks for evidence of system clock manipulation. ```APIDOC ## KeyHelper::DetectClockManipulation ### Description Searches for evidence that the system time was once set after the threshold date. ### Parameters #### Path Parameters - **thresholdDate** (DateTime) - Required - The date to check against. ### Response - **Return Value** (bool) - Indicates if evidence was found that the system clock was deliberately turned back. ``` -------------------------------- ### KeyGenerator Class Reference Source: https://www.softactivate.com/doc Reference for the KeyGenerator class used in the SoftActivate Licensing SDK. ```APIDOC ## KeyGenerator::KeyGenerator ### Description Initializes a new instance of the KeyGenerator object. ### Prototype KeyGenerator::KeyGenerator(); ### Parameters None. ``` -------------------------------- ### LicenseTemplate::GetValidationDataSize Source: https://www.softactivate.com/doc Retrieves the size of the data used to validate the license key. ```APIDOC ## LicenseTemplate::GetValidationDataSize ### Description Retrieves the size of the data used to validate the license key. ### Method `unsigned LicenseTemplate::GetValidationDataSize();` ### Endpoint None ### Parameters None ### Request Example None ### Response #### Success Response (200) * **return_value** (unsigned) - The size in bits of the validation data. ### Remarks None. ``` -------------------------------- ### LicenseTemplate::SetDataSize Source: https://www.softactivate.com/doc Sets the size of data embedded in the license key. ```APIDOC ## POST LicenseTemplate::SetDataSize ### Description Sets the size of data embedded in the license key. ### Parameters #### Request Body - **dataSize** (unsigned) - Required - The size of data in bits. ``` -------------------------------- ### LicenseTemplate::GetSignatureSize Source: https://www.softactivate.com/doc Retrieves the size of the data used to validate the license key. ```APIDOC ## LicenseTemplate::GetSignatureSize ### Description Retrieves the size of the data used to validate the license key. ### Method `unsigned LicenseTemplate::GetSignatureSize();` ### Endpoint None ### Parameters None ### Request Example None ### Response #### Success Response (200) * **return_value** (unsigned) - The signature size in bits. ### Remarks None. ``` -------------------------------- ### KeyGenerator Class Source: https://www.softactivate.com/doc The KeyGenerator class is used for creating and managing license keys. ```APIDOC ## KeyGenerator::~KeyGenerator ### Description Destroys a KeyGenerator object, freeing all associated resources. ### Prototype _KeyGenerator::~KeyGenerator();_ ### Parameters None. ### Return Values None. ``` ```APIDOC ## KeyGenerator::SetKeyTemplate ### Description Sets the template used to generate license keys. ### Prototype _void KeyGenerator::SetKeyTemplate(LicenseTemplate & keyTemplate);_ ### Parameters #### Path Parameters - **keyTemplate** (LicenseTemplate&) - Required - The template used to generate license keys. ### Return Values None. ``` ```APIDOC ## KeyGenerator::SetKeyData ### Description Sets the contents of a data field. ### Prototype _void KeyGenerator::SetKeyData(const char_t * fieldName, const void * rawData, unsigned len); void KeyGenerator::SetKeyData(const char_t * fieldName, unsigned intData); void KeyGenerator::SetKeyData(const char_t * fieldName, const char_t * stringData);_ ### Parameters #### Path Parameters - **fieldName** (const char_t *) - Required - The name of the field for which to set the data. - **rawData** (const void *) - Required - Pointer to a buffer containing the field data. - **len** (unsigned) - Required - Length of the rawData buffer. - **intData** (unsigned) - Required - An int value to set for the field. - **stringData** (const char_t *) - Required - A string value to set for the field. ### Return Values None. ### Remarks If the field size (as specified in the template) is smaller than the data size, the data is truncated to fit the field. ``` ```APIDOC ## KeyGenerator::SetValidationData ### Description Sets the contents of a validation field. ### Prototype _void KeyGenerator::SetValidationData(const char_t * fieldName, const void * rawData, unsigned len); void KeyGenerator::SetValidationData(const char_t * fieldName, unsigned intData); void KeyGenerator::SetValidationData(const char_t * fieldName, const char_t * stringData);_ ### Parameters #### Path Parameters - **fieldName** (const char_t *) - Required - The name of the field for which to set the data. - **rawData** (const void *) - Required - Pointer to a buffer containing the field data. - **len** (unsigned) - Required - Length of the rawData buffer. - **intData** (unsigned) - Required - An int value to set for the field. - **stringData** (const char_t *) - Required - A string value to set for the field. ### Return Values None. ### Remarks If the field size (as specified in the template) is smaller than the data size, the data is truncated to fit the field. ``` ```APIDOC ## KeyGenerator::GenerateKey ### Description Generates a license key. ### Prototype _const char_t * LicenseTemplate::GenerateKey();_ ### Parameters None. ### Return Values Pointer to a NULL-terminated string containing the license key. This string is statically allocated, do not attempt to free it. ``` -------------------------------- ### LicenseValidationResult Class Methods Source: https://www.softactivate.com/doc Methods for retrieving validation results and license status. ```APIDOC ## LicenseValidationResult::IsLicenseExpired ### Description Checks if the license has expired. ## LicenseValidationResult::IsPaymentRequired ### Description Checks if payment is required for this license. ## LicenseValidationResult::GetLicenseValidityDays ### Description Gets the number of days the license remains valid. ``` -------------------------------- ### LicensingClient::SetLicensingServiceUrl Source: https://www.softactivate.com/doc Sets the URL of the licensing service. ```APIDOC ## void LicensingClient::SetLicensingServiceUrl(const char * url) ### Description Sets the URL of the licensing service. ### Parameters - **url** (const char *) - Required - The URL of the licensing service. ``` -------------------------------- ### LicenseTemplate::GetGroupSeparator Source: https://www.softactivate.com/doc Retrieves the current group separator string. ```APIDOC ## GET LicenseTemplate::GetGroupSeparator ### Description Retrieves the string or character that separates license key character groups. ### Return Values - **string** - Pointer to a string containing the license key group separator string. ``` -------------------------------- ### LicenseTemplate::SaveXml Source: https://www.softactivate.com/doc Saves the XML representation of the template into a string. ```APIDOC ## LicenseTemplate::SaveXml ### Description Saves the XML representation of the template into a string. ### Method `const char * LicenseTemplate::SaveXml(bool savePrivateKey = true);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **savePrivateKey** (bool) - Optional - Whether to include the private key in the XML output. Defaults to true. ### Request Example ```json { "savePrivateKey": false } ``` ### Response #### Success Response (200) * **return_value** (const char *) - Pointer to a string containing an UTF-8 encoded XML representation of the template parameters. ### Remarks None. ``` -------------------------------- ### Subscription License Renewal Check Source: https://www.softactivate.com/doc Handle subscription licenses with automatic renewal checks using a Timer. This method validates the current license against the server periodically. ```csharp using SoftActivate.Licensing; using System.Timers; public class SubscriptionManager { private Timer renewalTimer; private LicensingClient client; public void StartSubscriptionMonitoring() { // Check renewal every 24 hours renewalTimer = new Timer(24 * 60 * 60 * 1000); renewalTimer.Elapsed += CheckRenewal; renewalTimer.Start(); } private void CheckRenewal(object sender, ElapsedEventArgs e) { try { // Validate current license LicenseValidationArgs args = new LicenseValidationArgs { LicenseKey = GetStoredLicenseKey(), ValidateExpiration = true, ConnectToServer = true }; LicenseValidationResult result = client.ValidateLicense(args); if (!result.IsValid) { if (result.Status == LICENSE_STATUS.EXPIRED) { HandleSubscriptionExpired(); } else if (result.Status == LICENSE_STATUS.SERVER_ERROR) { // Retry later on server errors ScheduleRetry(); } } else { // Update local license data UpdateLocalLicenseData(result); } } catch (Exception ex) { LogError($"Subscription check failed: {ex.Message}"); } } } ``` -------------------------------- ### LicenseTemplate::AddDataField Source: https://www.softactivate.com/doc Adds a new data field to the license key template. ```APIDOC ## POST LicenseTemplate::AddDataField ### Description Adds a field of data which will be included in the license key. ### Parameters #### Request Body - **fieldName** (string) - Required - The name of the data field. - **fieldType** (FIELD_TYPE) - Required - The type of the data field (FIELD_TYPE_INTEGER, FIELD_TYPE_STRING, FIELD_TYPE_RAW). - **sizeInBits** (unsigned) - Required - The size of the data field in bits. - **startPos** (unsigned) - Optional - The starting position of the field. ``` -------------------------------- ### KeyValidator Class Source: https://www.softactivate.com/doc The KeyValidator class provides functionality to verify the authenticity and validity of license keys. ```APIDOC ## KeyValidator Class ### Description Used to validate license keys against templates and specific validation data. ### Methods - **SetKey(key)**: Sets the license key string to be validated. - **IsKeyValid()**: Returns a boolean indicating if the provided key is valid. - **QueryKeyData()**: Retrieves data stored within the validated license key. ``` -------------------------------- ### LicenseTemplate::SetValidationDataSize Source: https://www.softactivate.com/doc Sets the size of the data used to validate the license key. ```APIDOC ## LicenseTemplate::SetValidationDataSize ### Description Sets the size of the data used to validate the license key. ### Method `void LicenseTemplate::SetValidationDataSize(unsigned sizeInBits);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **sizeInBits** (unsigned) - Required - The size of validation data in bits. ### Request Example ```json { "sizeInBits": 128 } ``` ### Response #### Success Response (200) None #### Response Example None ### Remarks None. ``` -------------------------------- ### KeyValidator Class Source: https://www.softactivate.com/doc The KeyValidator class is used for validating and querying data from license keys. ```APIDOC ## KeyValidator::KeyValidator ### Description Initializes a KeyValidator object. ### Prototype _KeyValidator::KeyValidator();_ ### Parameters None. ### Return Values None. ``` ```APIDOC ## KeyValidator::~KeyValidator ### Description Destroys a KeyValidator object, freeing all associated resources. ### Prototype _KeyValidator::~KeyValidator();_ ### Parameters None. ### Return Values None. ``` ```APIDOC ## KeyValidator::SetKeyTemplate ### Description Sets the template used to generate license keys. ### Prototype _void KeyValidator::SetKeyTemplate(LicenseTemplate & keyTemplate);_ ### Parameters #### Path Parameters - **keyTemplate** (LicenseTemplate&) - Required - The template used to generate license keys. ### Return Values None. ``` ```APIDOC ## KeyValidator::SetValidationData ### Description Sets the contents of a validation field. ### Prototype _void KeyValidator::SetValidationData(const char_t * fieldName, const void * rawData, unsigned len); void KeyValidator::SetValidationData(const char_t * fieldName, unsigned intData); void KeyValidator::SetValidationData(const char_t * fieldName, const char_t * stringData);_ ### Parameters #### Path Parameters - **fieldName** (const char_t *) - Required - The name of the field for which to set the data. - **rawData** (const void *) - Required - Pointer to a buffer containing the field data. - **len** (unsigned) - Required - Length of the rawData buffer. - **intData** (unsigned) - Required - An int value to set for the field. - **stringData** (const char_t *) - Required - A string value to set for the field. ### Return Values None. ### Remarks If the field size (as specified in the template) is smaller than the data size, the data is truncated to fit the field. ``` ```APIDOC ## KeyValidator::SetKey ### Description Sets the license key to validate and to query data from. ### Prototype _void KeyValidator::SetKey(const char_t * licenseKey);_ ### Parameters #### Path Parameters - **licenseKey** (const char_t *) - Required - A NULL-terminated string containing the license key. ### Return Values None. ``` ```APIDOC ## KeyValidator::IsKeyValid ### Description Validates the license key set using KeyValidator::SetKey(). ### Prototype _bool KeyValidator::IsKeyValid();_ ### Parameters None. ### Return Values Returns true if the license key is valid, false if not. ``` ```APIDOC ## KeyValidator::QueryKeyData ### Description Obtains data from the license key. ### Prototype _void KeyValidator::QueryKeyData(const char_t * fieldName, void * buf, unsigned * len);_ ### Parameters #### Path Parameters - **fieldName** (const char_t *) - Required - The name of the field for which to query data. - **buf** (void *) - Required - A buffer to store the retrieved data. - **len** (unsigned *) - Required - Pointer to a variable that contains the size of the buffer and receives the actual size of the data written. ``` -------------------------------- ### KeyGenerator Class Source: https://www.softactivate.com/doc The KeyGenerator class is used to generate license keys based on defined templates and validation data. ```APIDOC ## KeyGenerator Class ### Description Provides methods to configure license templates and generate secure license keys. ### Methods - **SetKeyTemplate(template)**: Sets the license template to be used for generation. - **SetKeyData(data)**: Sets the data to be embedded in the license key. - **SetValidationData(data)**: Sets the validation data required for the key. - **GenerateKey()**: Generates the license key string based on the current configuration. ``` -------------------------------- ### LicenseTemplate::SetGroupSeparator Source: https://www.softactivate.com/doc Sets the character or string used to separate groups within a license key. ```APIDOC ## POST LicenseTemplate::SetGroupSeparator ### Description Sets the string or character that separates license key character groups. ### Parameters #### Request Body - **groupSeparator** (string) - Required - The group separator string. ``` -------------------------------- ### LicenseTemplate::AddValidationDataField Source: https://www.softactivate.com/doc Adds a field of data used for license key validation. ```APIDOC ## LicenseTemplate::AddValidationDataField ### Description Adds a field of data used for license key validation. Validation fields are not included in the license key, but they are used for validation. ### Method `void LicenseTemplate::AddValidationDataField(const char_t * fieldName, FIELD_TYPE fieldType, unsigned sizeInBits, unsigned startPos = -1);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **fieldName** (const char_t *) - Required - The name of the data field. * **fieldType** (FIELD_TYPE) - Required - The type of the field. It can be one of FIELD_TYPE_INTEGER, FIELD_TYPE_STRING, FIELD_TYPE_RAW. * **sizeInBits** (unsigned) - Required - The size of the field in bits. * **startPos** (unsigned) - Optional - The starting position (relative to bit 0) of the field in the license key validation data. Omitting this value adds the field to the next available position. Defaults to -1. ### Request Example ```json { "fieldName": "user_id", "fieldType": "FIELD_TYPE_INTEGER", "sizeInBits": 32, "startPos": 0 } ``` ### Response #### Success Response (200) None #### Response Example None ### Remarks This method could throw an exception if the field size is too big for the chosen validation data size. ```