License Management

Revulytics Usage Intelligence allows you to maintain your own license key registry on the Revulytics Usage Intelligence server in order to track license key usage and verify the status/validity of license keys used on your clients.

There are multiple ways by which the key registry is populated with license keys.

  1. Keys are collected automatically from your clients whenever you call the tbKeyChanged() function.
  2. You can add/edit keys manually via the Revulytics Usage Intelligence web UI.
  3. You can upload keys in bulk using CSV files from the Revulytics Usage Intelligence web UI.
  4. You can add/edit keys directly from your CRM by using the Revulytics Usage Intelligence Web API.

Please check out this KBase article to learn about the correct file format when uploading keys to the Revulytics Usage Intelligence Key Registry: http://helpdesk.revulytics.com/knowledgebase.php?article=41.

Client vs. Server Managed Licensing

Revulytics Usage Intelligence gives you the option to choose between managing your license key status (i.e. Blacklisted, Whitelisted, Expired or Activated) and key type on the server (server managed) or managing this status through the application (client managed). Applications can individually set whether each license status or license type is either Sever Managed or Client Managed by visiting the License Key Management Settings page on the Revulytics Usage Intelligence web UI. The major difference is outlined below:

1- Client managed: The server licensing mechanism works in reporting-only mode and your application is expected to notify the server that the license status has changed through the use of tbSetLicense().

When to use: You have implemented your own licensing module/mechanism within your application that can identify whether the license key used by this client is blacklisted, whitelisted, expired or activated. In this case you do not need to query the Revulytics Usage Intelligence server to get this license status. However you can simply use this function to passively inform Revulytics Usage Intelligence about the license status used by the client. In this case:

  1. Revulytics Usage Intelligence will use this info filter and report the different key types and statuses and their activity.
  2. Revulytics Usage Intelligence licensing server will operate in passive mode (i.e. reporting only).
  3. Calling tbKeyCheck() will return TB_FUNCTION_NOT_AVAIL since the key status is client managed.

2- Server managed: You manage the key status on the server side and your application queries the server to determine the status of a particular license key by calling tbKeyCheck() or tbKeyChanged().

When to use: If you do not have your own licensing module/mechanism within your application and thus you have no way to identify the license status at the client side. In this mode, whenever a client changes their license key your application can call tbKeyChanged() to register the new license key. In reply to this API call, the server will check if the license key exists on the key register and in the reply it will specify to your application whether this key is flagged as blacklisted, whitelisted, expired or activated, along with the type of key submitted. If you want to verify a key without actually registering a key change for this client you can use tbKeyCheck() which returns the same values but does not register this key with the server. In this case:

  1. The key register is maintained manually on the server by the software owner
  2. Revulytics Usage Intelligence licensing server will operate in active mode so apart from using this key info for filtering and reporting, it will also report back the key status (validity) to the SDK whenever requested through the API.
  3. Calling tbKeyCheck() or tbKeyChanged() will return the 4 status flags denoting whether a registered key is: Blacklisted, Whitelisted, Expired and Activated and the key type.
  4. If the key does not exist on the server, all 4 status flags will be returned as false (0).

TBRESULT tbKeyCheck(TBINSTANCE *tbInstance, const char *licKey, int *&tbLicenseArray)

By using this function, your software can validate a license key (entered by your client) with the key registry stored on the Revulytics Usage Intelligence server. The function accepts a char* parameter that is the license key itself and an int array of length 5 which it fills with the returned result. You may use the following constants to refer to the required value by its index:

* TB_KEY_ACTIVE_INDEX (0)
* TB_KEY_BLACKLIST_INDEX (1)
* TB_KEY_EXPIRED_INDEX (2)
* TB_KEY_WHITELIST_INDEX (3)
* TB_KEY_TYPE_INDEX (4)

Each of the first 4 values will be set to either 0 or 1 that refers to false or true respectively. The 5th value will be set to a number between 0 and 7 (both included) that refers to the 8 possible license types listed below. The values may also be -1 that means “Function not available”.

The following are the possible license types

* TB_KEYTYPE_EVALUATION (0)
* TB_KEYTYPE_PURCHASED (1)
* TB_KEYTYPE_FREEWARE (2)
* TB_KEYTYPE_UNKNOWN (3)
* TB_KEYTYPE_NFR (4)
* TB_KEYTYPE_CUSTOM1 (5)
* TB_KEYTYPE_CUSTOM2 (6)
* TB_KEYTYPE_CUSTOM3 (7)

Parameters:

tbInstance (TBINSTANCE*) - The Revulytics Usage Intelligence SDK instance returned in call to tbCreateInstance()

licKey (char*) - The license key to be tested.

tbLicenseArray (int array of length 5) - The array that will be filled to contain the license status flags.

Returns:One of the return status constants below.
* TB_OK (1)
* TB_FUNCTION_NOT_AVAIL (-1)
* TB_CONN_ERROR (-2)
* TB_AUTH_FAILURE (-3)
* TB_SERVER_ERROR (-4)
* TB_APP_CONFIG_NOT_LOADED (-7)
* TB_INVALID_PARAMETER (-9)
* TB_APP_STOPPED (-14)
* TB_INTERNAL_ERROR (-99)

Note: Whenever a license key is sent to the server using this function, the key is automatically encrypted by the Revulytics Usage Intelligence SDK before being sent to the server.

Code Example:

//Test a license key
        TBINSTANCE* tbInstance; //...; //Creation and initialization shown in other snippets.
char* prod_key= "xyz";
int* license_result;
if(tbKeyCheck(tbInstance, prod_key, license_result)==TB_OK)
{
            if (license_result[TB_KEY_TYPE_INDEX] == TB_FUNCTION_NOT_AVAIL) {
        wprintf("License key information is unavailable\n");
    }
            else {
        wprintf("License key type is %d\n", license_result[TB_KEY_TYPE_INDEX]);
    }
    //Check if the license is activated
    if (license_result[TB_KEY_ACTIVE_INDEX] == TB_KEY_STATUS_YES){
        printf("License Active\n");
    } else if (license_result[TB_KEY_ACTIVE_INDEX] == TB_KEY_STATUS_NO) {
        printf("License Inactive\n");
    } else {
                        printf("License status unknown\n");
                }

    //check if key is black listed
    if (license_result[TB_KEY_BLACKLIST_INDEX] == TB_KEY_STATUS_YES){
        printf("Key is blacklisted\n");
    }
     else if (license_result[TB_KEY_BLACKLIST_INDEX] == TB_KEY_STATUS_NO) {
        printf("License is NOT blacklisted\n");
    } else {
                        printf("License blacklist status unknown\n");
                }

    //Check if key is expired
    if (license_result[TB_KEY_EXPIRED_INDEX] == TB_KEY_STATUS_YES){
        printf("Key is expired\n");
    }
     else if (license_result[TB_KEY_EXPIRED_INDEX] == TB_KEY_STATUS_NO) {
        printf("Key is NOT expired\n");
    } else {
                        printf("Key expiration status unknown\n");
                }

    //Check if key is white listed
    if (license_result[TB_KEY_WHITELIST_INDEX] == TB_KEY_STATUS_YES){
        printf("Key is white listed\n");
    } else if (license_result[TB_KEY_WHITELIST_INDEX] == TB_KEY_STATUS_NO) {
        printf("Key is NOT white listed\n");
    } else {
                        printf("Key white list status unknown\n");
                }
} else {
    printf("Failed to invoke function tbKeyCheck\n");
}
tbFree(license_result);

TBRESULT tbKeyChanged(TBINSTANCE *tbInstance, const char *newKey, int *&tbLicenseArray)

This function should be called when an end user is trying to enter a new license key into your application and you would like to confirm that the key is in fact valid (i.e. blacklisted or whitelisted), active, or expired. The function is very similar to the tbKeyCheck() function, however rather than just being a passive license check, it also registers the new key with the server and associates it with this particular client installation. The function accepts a char* parameter that the application should use to pass the key and the address of a . You may use the following constants to refer to the required value by its index:

* TB_KEY_ACTIVE_INDEX (0)
* TB_KEY_BLACKLIST_INDEX (1)
* TB_KEY_EXPIRED_INDEX (2)
* TB_KEY_WHITELIST_INDEX (3)
* TB_KEY_TYPE_INDEX (4)

Each of the first 4 values will be set to either 0 or 1, which refer to false or true respectively. The 5th value will be set to a number between 0 and 7 (both included) which refer to the 8 possible license types listed below. The values may also be -1 which refers to “Function not available”.

The following are the possible license types

* TB_KEYTYPE_EVALUATION (0)
* TB_KEYTYPE_PURCHASED (1)
* TB_KEYTYPE_FREEWARE (2)
* TB_KEYTYPE_UNKNOWN (3)
* TB_KEYTYPE_NFR (4)
* TB_KEYTYPE_CUSTOM1 (5)
* TB_KEYTYPE_CUSTOM2 (6)
* TB_KEYTYPE_CUSTOM3 (7)

Parameters:

tbInstance (TBINSTANCE*) - The Revulytics Usage Intelligence SDK instance returned in call to tbCreateInstance()

newKey (char*) - The new license key to be set.

tbLicenseArray (int array of length 5) - The array that will be filled to contain the license status flags.

Returns:One of the return status constants below.
* TB_OK (1)
* TB_FUNCTION_NOT_AVAIL (-1)
* TB_CONN_ERROR (-2)
* TB_AUTH_FAILURE (-3)
* TB_SERVER_ERROR (-4)
* TB_APP_CONFIG_NOT_LOADED (-7)
* TB_INVALID_PARAMETER (-9)
* TB_APP_STOPPED (-14)
* TB_INTERNAL_ERROR (-99)

Note: Whenever a license key is sent to the server using this function, the key is automatically encrypted by the Revulytics Usage Intelligence SDK before being sent to the server.

Code Example:

//Register a new license key
        TBINSTANCE* tbInstance; //...; //Creation and initialization shown in other snippets.
char* new_key= "xyz";
int* license_result;
if(tbKeyChanged(tbInstance, new_key, license_result)==TB_OK)
{
            if (license_result[TBC_KEY_TYPE_INDEX] == TBC_FUNCTION_NOT_AVAIL) {
        printf("License key information is unavailable\n");
    } else {
        printf("License key type is %d\n", license_result[TBC_KEY_ACTIVE_INDEX]);
    }
    //Check if the license is activated
    if (license_result[TB_KEY_ACTIVE_INDEX] == TB_KEY_STATUS_YES){
        printf("License Active\n");
    } else if (license_result[TB_KEY_ACTIVE_INDEX] == TB_KEY_STATUS_NO) {
        printf("License Inactive\n");
    } else {
                        printf("License status unknown\n");
                }

    //check if key is black listed
    if (license_result[TB_KEY_BLACKLIST_INDEX] == TB_KEY_STATUS_YES){
        printf("Key is blacklisted\n");
    }
     else if (license_result[TB_KEY_BLACKLIST_INDEX] == TB_KEY_STATUS_NO) {
        printf("License is NOT blacklisted\n");
    } else {
                        printf("License blacklist status unknown\n");
                }

    //Check if key is expired
    if (license_result[TB_KEY_EXPIRED_INDEX] == TB_KEY_STATUS_YES){
        printf("Key is expired\n");
    }
     else if (license_result[TB_KEY_EXPIRED_INDEX] == TB_KEY_STATUS_NO) {
        printf("Key is NOT expired\n");
    } else {
                        printf("Key expiration status unknown\n");
                }

    //Check if key is white listed
    if (license_result[TB_KEY_WHITELIST_INDEX] == TB_KEY_STATUS_YES){
        printf("Key is white listed\n");
    } else if (license_result[TB_KEY_WHITELIST_INDEX] == TB_KEY_STATUS_NO) {
        printf("Key is NOT white listed\n");
    } else {
                        printf("Key white list status unknown\n");
                }
}
else
{
    printf("Failed to invoke function tbKeyChanged\n");
}
tbFree(license_result);