← Click here to go back to the list of articles

Getting Started - Secure License Manager

STEP 1 Creating a License Configuration

After installing Secure License Manager, you can get started with generating, validating and activating/unlocking license keys. To get started with Secure License Manager, you have to first create a license configuration. To create a license configuration, select the "File -> New License Configuration" menu option on the main window (shown in Figure 2. below). This menu option will open the "New License Configuration" dialog (shown in Figure 1. below). In this dialog, you can specify the name and the key size for your license configuration or you can or you can enter an existing public/private key. Note that larger key sizes will result in larger license keys.

New License Configuration
Figure 1. New license configuration dialog.

STEP 2 Specifying License Settings and Generating License Keys

After creating a license configuration or selecting an existing license configuration, you can select your license settings and generate license keys. The main window is where you will select your license settings for the license keys that you will be generating for the selected license configuration. The different options of the main window are described below.


Figure 2. Secure License Manager Main Window.

  1. Flags / Features
    Allows you to set the flags or features setting. These flags can be checked from within your application using the SecureLicense.IsFlagEnabled(int flagIndex)method.

  2. Time Limit
    You can set the number of days time limit or the exact expiry date time limits. The number of days expiry time limit is counted as the number of days since the license activation. The exact expiry date time limit is the date on or after which the license will indefinitely become invalid or expired. You can check license time limits using the SecureLicense.HasExpiryLimit, SecureLicense.HasDateExpiryLimit, SecureLicense.HasDaysExpiryLimit, SecureLicense.ExpiryDays and SecureLicense.ExpiryDate properties.

  3. System Identifier / Machine Identifier Lock
    You can lock your license to only work on a specific machine. To lock a license to a particular system, from within your application you will use the the ecureLicense.GetSystemID(SystemIdentifierOptions sysIdentifierOptions) method to get the system identifier of the system where your application is running. Your application's end user will provide this system identifier to you and you will enter this in the "System Identifier" text input box located on the main dialog.

    In addition, on the main dialog you also have to select the same set of system identifier options that are used to get the system identifier from your application using the SecureLicense.GetSystemID method. This will make sure that the generated license will only be valid on a machine that has the same system identifier as the system id that is specified in the "System Identifier" text put inbox using the selected system identifier options.

    Further more, using the tolerance number, you can set the number of system identifier parts that can be different before deeming a license key invalid. For example, if you select the tolerance number to be two(2), your license key will be identified as valid even when there are one or two system identifier parts that are different from their original values specified when the license key was generated.

  4. Additional Data
    You can also embed a text or text encoded data in your license keys. The text or text encoded additional data that you specify during license generation will be embedded in your license key and you can access them in your application using the SecureLicense.AdditionalData property.

  5. License Format and License Type
    Before generating your license keys, you should select the appropriate license type and license format. The license format is used to determine the type of encoding that will be used for your license keys. The license type is used to determine how the license key will be activated.

    Unlock keys will do not need a license web service while activation keys are checked against an license web service during activation. If the SecureLicense.LicenseChecks property is specified to any other value than LicenseChecks.None, the license will be checked against a license web service when it is loaded after activations. The SecureLicense.LicenseKeyType property can be used to determine the license type for the currently loaded license or the currently activated license key.

  6. Group Separator and Group Length
    The group separator and group length settings do not impact the license information stored in the license key. However, they determine how the license key will look like when generated. The license separator will be inserted for every group of characters specified by the group length.

  7. Number of Licenses
    This specifies the number of licenses to generate.

  8. "Generate" button
    The license keys will be generated when clicking the "Generate" button. The generated license keys will be displayed in the list box located at the bottom of the main dialog/form.

  9. "Validate" button
    The "Validate" button is used to validate a license using the currently selected license configuration. If you have selected a generated license key, this license key will be used by default in the "License Validation Result" dialog. Otherwise, the "License Key" input text box will be empty and you can type in your existing license key for validation. (see Figure 3 Below)


Figure 3. License Validation Dialog.

STEP 3 Using Secure License Manager in your application

To validate a license key in your application, you create an instance of the SecureLicense class by specifying the validation key for your license configuration. Then you will use the Activate method if you would like to register the license key or the Load method if you would like to load the license for a previously activate license key. After activating or loading your license, you can use the "IsValid" property and other properties of the SecureLicense class to further validate the license.

Note, after activating an activation license key for the first time, you must save the license using the "Save" method in order to be able to load the license in the future. In the case of unlock license keys, saving the activated license is optional. The listing below shows the basic steps for implementing licensing using Secure License Manager.

                    private bool CheckLicense()
                    {
                        string validationKey = "BgIAAACkAABSU....."; 

                        SecureLicense license = new SecureLicense(validationKey);

                        //Specify license store location (can be a file or registry)
                        license.LicenseFilePath = 
                        Path.Combine(Environment.GetFolderPath(
                            Environment.SpecialFolder.CommonApplicationData), 
                            "my test license.lic");

                        //Attempt to load an existing license if you have previously saved an activated/unlocked license key
                        if (!license.Load())
                        {
                            //When your application runs the very first time, 
                            //license.Load() will fail because there is no existing
                            //license. You can specify an evaluation/trial 
                            //license key to register an evaluation/trial license.
                            //Alternatively, you can also specify and register your
                            //evaluation/trial license key using a setup program.
                            license.Activate("B7KEP-NLPAP-6RJ9T-...");

                            //Save the license for future use if it is valid. Saving the license is optional for "Unlock keys".
                            if(license.IsValid)
                            {
                                license.Save();
                            }
                        }

                        //If license is not valid, request for a valid license 
                        //or terminate the application.
                        if (!license.IsValid)
                        {
                            //Request for a valid license.
                            //If no valid license is provided, 
                            //then terminate the application.
                            //or show some other failure message.
                        }

                        return license.IsValid;

                    }
                    
                    Private Function CheckLicense() As Boolean
                        
                        Dim validationKey As String = "BgIAAACkAABSU....."
                        Dim license As SecureLicense = New SecureLicense(validationKey)
                        
                        'Specify license store location (can be a file or registry)
                        license.LicenseFilePath = Path.Combine(
                            Environment.GetFolderPath(
                                Environment.SpecialFolder.CommonApplicationData), "my test license.lic")
                        
                        'Attempt to load an existing license if you have previously saved an activated/unlocked license key.
                        If Not license.Load Then
                            
                            'When your application runs the very first time, 
                            'license.Load() will fail because there is no existing
                            'license. You can specify an evaluation/trial 
                            'license key to register an evaluation/trial license.
                            'Alternatively, you can also specify and register your
                            'evaluation/trial license key using a setup program.
                            license.Activate("B7KEP-NLPAP-6RJ9T-...")
                            
                            'Save the license for future use if it is valid. Saving the license is optional for "Unlock keys".
                            If license.IsValid Then
                                license.Save()
                            End If

                        End If

                        'If license is not valid, request for a valid license 
                        'or terminate the application.
                        If Not license.IsValid Then

                            'Request for a valid license.
                            'If no valid license is provided, 
                            'then terminate the application.
                            'or show some other failure message.

                        End If

                        Return license.IsValid

                    End Function
                    
                    
← Click here to go back to the list of articles