Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

INFO: How to validate serials from your software

 
Subscribe to the RSS feed for this forum  Forum Index -> CryptoLicensing For .Net
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Thu May 28, 2009 8:37 am    Post subject: INFO: How to validate serials from your software

Serials are short cryptographically secure codes in the following form: "63RTV-VCEUD-04CU1-NPU5P-MDHVS-HAVXU-V"

The only reason to use serial codes instead of license codes is because they are short and this can be easily entered by the user. However, a serial code cannot be validated on its own, so using a serial code requires a one time communication with a license service to retrieve a license code against that serial.

To use serials in your software, you must use the CryptoLicense.GetLicenseFromSerial method which connects with the license service to retrieve the license against that serial. If this method succeeds, you can proceed to validate the license using the CryptoLicense.Status property.

Normally, your licensing scheme will use either serials or licenses, however you can also give serials to some users and licenses to others; in this case, you will need to differentiate between them. The following code shows how to do this:

[C#]
Code:
string licOrSerial = "<<serial or license>>"; // may be entered by user
CryptoLicense lic = new CryptoLicense("<<validation key for your project>>");
lic.LicenseServiceURL = "<<URL of your license service>>";

// Try to validate serial and retrieve license against the serial
SerialValidationResult result = lic.GetLicenseFromSerial(licOrSerial);
if (result == SerialValidationResult.Failed)
{
// 'licOrSerial' is in serial form but validation of serial failed
MessageBox.Show("Serial Validation Failed");
return;
}
else if (result == SerialValidationResult.NotASerial)
{
// 'licOrSerial' is not a serial but may be a license, set lic.LicenseCode and validate it
lic.LicenseCode = licOrSerial;
}
else //if (result == SerialValidationResult.Success)
{
// CryptoLicense.GetLicenseFromSerial set the lic.LicenseCode with the retrieved license code
// validate it
}
// Validate license by querying Status property
if (lic.Status != LicenseStatus.Valid)
{
MessageBox.Show("License Validation Failed");
return;
}


[VB.Net]
Code:
Dim licOrSerial As String = "<<serial or license>>" ' may be entered by user
Dim lic As CryptoLicense = New CryptoLicense("<<validation key for your project>>")
lic.LicenseServiceURL = "<<URL of your license service>>"

' Try to validate serial and retrieve license against the serial
Dim result As SerialValidationResult = lic.GetLicenseFromSerial(licOrSerial)

If (result = SerialValidationResult.Failed) Then
    ' 'licOrSerial' is in serial form but validation of serial failed
    MessageBox.Show("Serial Validation Failed")
    Return
ElseIf (result = SerialValidationResult.NotASerial) Then
    ' 'licOrSerial' is not a serial but may be a license, set lic.LicenseCode and validate it
    lic.LicenseCode = licOrSerial
Else 'If (result = SerialValidationResult.Success) Then
    ' CryptoLicense.GetLicenseFromSerial set the lic.LicenseCode with the retrieved license code
    ' validate it
End If

' Validate license by querying Status property
If (lic.Status <> LicenseStatus.Valid) Then
    MessageBox.Show("License Validation Failed")
    Return
End If


See the following topics in the help file for more details:
"Using Serial Codes"
"Licenses Versus Serials"

Back to top
Display posts from previous:   
Forum Index -> CryptoLicensing For .Net All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group