Synergex.SynergyDE.DeviceLicensing.DeviceLicensing

 

WNSupported in Synergy .NET on Windows

 

 

namespace Synergex.SynergyDE.DeviceLicensing
public class DeviceLicensing

Synergex provides a DeviceLicensing namespace that contains the functionality needed to implement device licensing in your applications. See Device licensing (.NET) for instructions. Also see Synergex.SynergyDE.DeviceLicensing.ISynergyDeviceCallback.

Methods

DeviceLicensing.Activate

public static async DeviceLicensing.Activate(token, password, descrip), 
&  @Task<LicenseError> 

Activates a device. Your application should prompt the user for the token, password, and device description, or obtain that information in some other manner. This method must be called by your ISynergyDeviceCallback.ActivationDialog() method.

token

The token passed from the ActivationDialog() method. (string)

password

The password passed from the ActivationDialog() method. (string)

descrip

The unique device description passed from the ActivationDialog() method. Must be unique within the license block. (string)

If the activation is successful, Activate() returns a completed task with LicenseError.None. If activation is not successful, Activate() returns one of the following: DeviceMismatch, Unauthorized, Expired, Revoked, NoSlots, DuplicateDevice, NotFound, Timeout, Connectivity, MiscError, InternalLicensingServerError. See DeviceLicensing errors for details.

DeviceLicensing.Deactivate

public static async DeviceLicensing.Deactivate, @Task<LicenseError>

Deactivates the device and clears all license information stored on the device. You can use this routine to provide an application option that allows the device end user to deactivate a device that is being replaced. This application option might also be invoked under the direction of Synergex to assist in problem solving.

If deactivation is successful, Deactivate() returns a completed task with LicenseError.None. If deactivation is not successful, Deactivate() returns one of the following: NotActivated, NotTransferable, DeviceMismatch, NotFound, Timeout, Connectivity, MiscError, InternalLicensingServerError. If Deactivate() returns NotActivated, DeviceMismatch, or NotFound, the license information will still be cleared. See DeviceLicensing errors for details on these errors.

DeviceLicensing.Synchronize

public static async DeviceLicensing.Synchronize(auto_reactivate), 
& @Task<LicenseError>

Synchronizes the device license service with the device. This method gets current device license information from the device license service and stores it on the device. It must be called by your ISynergyDeviceCallback.Synchronize() method.

auto_reactivate

Flag that indicates that a “device mismatch” error condition should attempt to activate as a new device. If true, activate on a device mismatch. If false, don’t activate on a device mismatch. (boolean)

If synchronization is successful, Synchronize() returns a completed task with LicenseError.None. If synchronization is not successful, Synchronize() returns one of the following: NotActivated, Expired, Revoked, DeviceMismatch, NoSlots, NotFound, Timeout, Connectivity, MiscError, InternalLicensingServerError. See DeviceLicensing errors for details.

DeviceLicensing.GetDeviceGUID

public static async DeviceLicensing.GetDeviceGUID, @Task<LicenseError>

Generates a unique identifier for the device. This method must be called by your ISynergyDeviceCallback.Init() method.

If the call is successful, GetDeviceGUID() returns a completed task with LicenseError.None. If the call is not successful, GetDeviceGUID() returns one of the following: InvalidAttribute, MultipleInit, Timeout, Connectivity, MiscError, InternalLicensingServerError. See DeviceLicensing errors for details.

DeviceLicensing.GetLicenseInfo

public static DeviceLicensing.GetLicenseInfo, @LicenseInfo

Retrieves local license information that is stored on the device, and then populates the fields in the LicenseInfo class (see below). To ensure the most current server‑side information, call DeviceLicensing.Synchronize() first.

We recommend you use this method to provide an application option that displays the device description, as well as debug information to assist Synergex in problem solving.

The LicenseInfo class contains the following field:

Token

Token for license block. (string)

Description

Device description (unique within license block). (string)

GUID

Unique device identifier. (string)

Transferable

Whether license can be transferred to another device. (boolean)

LicenseStatus

Current device status: Active, NotActive, Grace. (LicenseStatus)
See LicenseStatus enumeration.

Activated

Date device was activated or last synchronized. (datetime)

Expiration

Date device will expire if no connection is made. (datetime)

Userdata

Application‑ or customer‑specific data. (string)

SubscriptionExpiration

Subscription expiration date. (datetime)

DebugInfo

Debug information for Synergex (encrypted). (string)

DeviceLicensing.WaitForLicense

public static DeviceLicensing.WaitForLicense, void

Suspends the application user interface until the device license startup processing is complete. This method is for device‑licensed applications on Windows servers, desktops, laptops, or tablets only.

WaitForLicense() must be called at the beginning of the application, prior to any other device licensing calls unless you are using an application login, in which case you don’t need to do this because you are already suspending the application from proceeding until successful login. (Suspension occurs via the implemented callbacks.)

Enumerations

LicenseStatus enumeration

The status of the license:

Active

Active.

Grace

In a grace period.

NotActive

Inactive (never been activated, deactivated, grace period expired, subscription expired, or revoked).

LicenseError enumeration

LicenseError returns the error as an enumeration. See the table below for a list of errors.

DeviceLicensing errors

The LicenseError enumeration is used to return errors for the methods in the DeviceLicensing class.

Errors Returned by DeviceLicensing Methods

Error

Meaning / additional information

Connectivity

Cannot connect to license server.

DeviceMismatch

Device information does not match information on server.

Returned by DeviceLicensing.Synchronize() only when auto_reactivate is false

DuplicateDevice

Device description is not unique within the license block.

Expired

Device license subscription period has expired.

InternalLicensingServerError

Contact Synergy/DE Developer Support

InvalidAttribute

The AppGUID or the associated public key in your SynergyDeviceLicenseAttribute is invalid.

MiscError

Contact Synergy/DE Developer Support

MultipleInit

A device GUID has already been stored on the device. This can only occur from an explicit call to GetDeviceGUID() from within your application, but outside your ISynergyDeviceCallback.Init() method.

None

Success.

NoSlots

No more device license slots are available. If this is the initial activation, (DeviceLicensing.Activate()), the device is placed into a 7‑day grace period.

Returned by DeviceLicensing.Synchronize() only when auto_reactivate is true

NotActivated

Device has not been activated.

NotFound

The device cannot be found on the server.

NotTransferable

The device license is not allowed to be transfered from one device to another.

Revoked

Device has been deactivated, or the device license has been revoked via the device license management website.

Timeout

The device license request to the license server timed out (2 minutes).

Unauthorized

Token/password combination is invalid or the password has expired.

Examples

The following example is an excerpt from a .NET assembly that imports the DeviceLicensing namespace, adds the SynergyDeviceLicense attribute, and retrieves local licensing information.

import Synergex.SynergyDE.DeviceLicensing
{assembly:SynergyDeviceLicenseAttribute(PublicKey="<RSAKeyValue><Modulus>
snLo26dxGIlGg2/rYVg3Jv579uFKxG9DmZkYyagWNOrssoz09PW4/94T3ZxpVEpN4r+xq3CWh
V6OiQmYiKJ+pP7X7OFx1vgOJTjfFT1XZaiqwMerMJ2aeOe1mQ3Yy+y27rQk8pkuE+nqdVti4t
08+zFsgSu9vJvUsamUQ+zEXCk=</Modulus><Exponent>AQAB</Exponent><P>8BHw5im2B
UPKrMiMvO2JfgQmn4ZO9/YKmz7XXOhEZFGZ7V7Bh1XZWiRf+NEfTaIuNj7VaizJ7JdTlhIZ/8
Bw==</P><Q>vko2QXxRkLVGAUkRUVwEKwfXa7FKhjFujpbuMF1/vOG8r2CeVICZ6jo1zUN7tc
GXgBMIrttrILT02XEzVQ6Tw==</Q><DP>uzcCijtU+14WnA/50QvdAIFSEWjs/MhfpxY+IG6f
2TdVlGLugaI4GZkmfnkn2ZT81+BEeT3qz2+043nPyY0d2Q==</DP><DQ>btTUkwGwnAf7C3l7
LamK4vsNbcgsaB9zksIvyxW6H64u8srIjTmsvRk2DFmJGpvSgwNVlTAA369Gzw72iWtIZaMOw
==</DQ><InverseQ>pBRV6OggGZ7gxV9XCM93NoxIoPsn5o+vXj2oyrVh1gnUgm30qByGnbHg
VWtY2zjuNYtFiV6PZNZmmmfTkRRODGBbw==</InverseQ><D>qK0tptMzeDnqSTt1huJX36gV
jVuPzPZPM9UfNR6JPyQA8RWERjgu0s0cghHjDiXeUUNZsAOl6q1mJtVb3IJul3NYS0qlaQVJf
R8q/2rg/QqdV9szFKBz/+nbnuiZsbtK9EZAdGAE3RJNZzsvOOulcfgy6gYMfHzIyJpfvQ0LE=
</D></RSAKeyValue>", AppGUID="99f6af0c-7030-4106-b629-5cfffce728bc", 
Class=^typeof(ns1.class1))}
main
record
    avar, a10
proc
    data li, @LicenseInfo
    data ls, LicenseStatus
    avar = "hey"
    DeviceLicensing.WaitForLicense()
    li = DeviceLicensing.GetLicenseInfo() 
    if (li != ^null) then
      begin
        console.writeline(li.description)
        ls = li.status
        if (ls == LicenseStatus.Active) then
          begin
            console.write("success: status is ")
            console.writeline(ls)
          end
        else
          begin
            console.write("fail: status is ")
            console.writeline(ls)
          end
      end
    else
      begin
        console.writeline("fail: li is null")
      end