пятница, 14 февраля 2014 г.

How to use the evaluation Unlock Key

In the past we had several discussions with our customers about how they control distribution of the evaluation license on “1 customer – 1 evaluation license” basis. Most common licensing schema supposes that evaluation license is included into the product distribution. But in this case when somebody wants to evaluate the product it is not enough to simple download and run it. Client should contact with developer and obtain evaluation license.

It was possible with previous versions of the Manco .NET Licensing System product but it required distribution of the license file. This method made some additional problems with subsequent distribution of the retail license, especially when “Unlock Key with Activation” licensing schema is used.

We significantly simplified this process in the version 8.1 of the Manco .NET Licensing System by introducing so-called “Evaluation Unlock Key”. Using this new feature you can distribute license file with your application just as it is for “Unlock Key” or “Unlock Key with Activation” licensing schemas. When customer ask for the evaluation license you send an Evaluation Unlock Key which can be bound to the PC hardware (activated) the same way as it works with “Unlock Key with Activation” licensing schema. When customer asks for Retail license you simple send another Unlock Key which replace evaluation one.

In this article I’ll describe how the “Evaluation Unlock Key” licensing schema can be implemented. I suppose that you have read “Quick Start” and “Using of the online product activation” sections in our documentation, because this document describes differences for this approach.

First of all you should add {T} format string into the Unlock Key format:


The {T} format indicates that type of the Unlock Key (Evaluation or Retail), type of the evaluation rule (“Expiration Days”, “Expiration Date” or “Expiration Runs”), value of the expiration rule, and value of the “Override ID” rule will be included to the Unlock Key (will be encrypted).

Now you should create License Type that will allow your application operate as you desire: application will request Unlock Key on start. Depends on the Unlock Key type (Evaluation or Retail) application will run on evaluation or fully functional mode.

This is good known license type which we call “Unlock Key”. To create new license type click expand button on the “Add License Type” toolbar button. You will see list of the predefined license types:



Select “Unlock Key with Activation + Evaluation Unlock Key” license type. New license type will be created. It includes following rules:



Activation Key – indicates that activation key created using PC system info and unlock key (ether in automatic or manual mode) should be entered to get product fully functional.

AWS Allow Deactivation – AWS check whether this rule is included to the license type when     customer’s application calls "DeactivateProduct" web-method. If it is so, then Deactivate method works.

Expiration Days – set number of days during which your product will work in evaluation mode. This license rule can be used to create evaluation. When someone attempts use licensed product after given number of days it will give “Your license has been expired” exception.

Is Evaluation – indicates, that license is in evaluation mode. Allows you limit some functionality in your product using evaluation status of license.

Unlock Key – including of this validation rule to the base license file allows you using of the “Unlock Key” schema to activate product.  It informs protection library that Unlock Key provided by customer should be validated.

Use evaluation key – indicates whether the protection library must check availability of the Unlock Key and test it state (Evaluation or Retail).

Write Key To File – indicates whether the “Unlock Key” should be written to the protected storage after validation. If you don’t use this rule, then customer will be asked for Unlock Key every time when your application starts.

As usual now you should create license file. Pay attention, with this approach license doesn’t operate as evaluation license, but just contains set of the rules which handle behavior of the protection library. Here it is screenshot of the sale window for the license file:



Pay attention, the “Is Evaluation” checkbox must be unchecked, and “Expiration Days” and “Unlock Key” fields must be empty.

The code for this licensing schema isn’t different much from one is used for the “Unlock Key with Activation” licensing schema. You just should keep in mind that old Unlock and Activation keys can be cleaned from the protected storage when new ones have been entered only:

C#


private bool RequestKeys()
{
       // Check if the current license is evaluation license or not valid
       if (!this.licenseState.IsValid || this.licenseState.IsEvaluation)
       {
             // This is evaluation or not valid license,
             // so we should show evaluation dialog
             EvaluationWindow evaluationWindow = new EvaluationWindow(this.license);
             evaluationWindow.Owner = this;
             if (evaluationWindow.ShowDialog() == true
                    && evaluationWindow.UnlockKey.Trim() != string.Empty
                    && evaluationWindow.ActivationKey.Trim() != string.Empty)
             {
                    // Check whether license REQUIRE the calling of the AWS
                    // and it has been called from the license form.
                    if (evaluationWindow.IsAwsCalled
                    || !this.licenseProperties.DoForceValidation)
                    {
                           // License information have been entered.
                           // Pass it to the license object for the
                           // following validation.
                           this.license.ClearUnlockKeys();
                           this.license.UnlockKey = evaluationWindow.UnlockKey;
                           this.license.ActivationKey = evaluationWindow.ActivationKey;
                    }
                    else
                    {
                           MessageBox.Show("You must click 'Activate' button on the evaluation form"
                                  + "to activate your copy of the product on this PC.");
                    }
             }
       } 

       return this.licenseState.IsValid
             && !(this.licenseState.IsEvaluation
&& this.licenseState.IsEvaluationExpired);
}


VB.NET


Private Function RequestKeys() As Boolean
       ' Check if the current license is evaluation license or not valid
If Not Me.licenseState.IsValid _
OrElse Me.licenseState.IsEvaluation Then
' This is evaluation or not valid license,
' so we should show evaluation dialog
Dim evaluationWindow As New EvaluationWindow(Me.license)
evaluationWindow.Owner = Me
If evaluationWindow.ShowDialog() = True _
AndAlso evaluationWindow.UnlockKey.Trim() <> String.Empty _
AndAlso evaluationWindow.ActivationKey.Trim() <> String.Empty Then
' Check whether license REQUIRE the calling of the AWS
' and it has been called from the license form.
If evaluationWindow.IsAwsCalled _
OrElse Not Me.licenseProperties.DoForceValidation Then
' License information have been entered.
' Pass it to the license object for the
' following validation.
Me.license.ClearUnlockKeys()
Me.license.UnlockKey = evaluationWindow.UnlockKey
Me.license.ActivationKey = evaluationWindow.ActivationKey
Else
MessageBox.Show("You must click 'Activate' button on the evaluation form" _
& "to activate your copy of the product on this PC.")
End If
End If
        End If 

        Return Me.licenseState.IsValid _
            AndAlso Not (Me.licenseState.IsEvaluation _
                         AndAlso Me.licenseState.IsEvaluationExpired)
End Function


Finally here are the screenshots of the sale records for the evaluation and retail Unlock Keys.

Evaluation



When customer asks you for the evaluation license you create new sale records, check “Is Evaluation” check box, set number of the expiration days and then generate Unlock Key. Send new key to the customer for activation. After activation customer will be able to evaluate your product during specified time frame. Pay attention, you must check “Is Evaluation” and set value for the “Expiration Days” field before Unlock Key generation.
Retail



Pay attention, for the retail license you must uncheck “Is Evaluation” checkbox and left “Expiration Days” field empty.

You can find sample solution which demonstrates using of the Evaluation Unlock Key on our official site at http://www.mancosoftware.com/licensing/download.htm