PLUSManaged: Activating and Getting a License File (Online Method)

Online activation is one option for activating an application and retrieving a license file from SOLO Server. Obtaining a license file from SOLO Server is required when working with read-only license files, since only SOLO Server has the encryption key data necessary to encrypt and digitally sign a read-only license file. Although it is possible to create a self-signed writable license file without using SOLO Server, it is often more convenient to obtain the base license file from SOLO Server that can then be modified as necessary. Either way, the procedure is largely the same. The only difference being the class from which your license implementation class is derived.

Important

Activation is only intended to occur once per system and/or user. DO NOT configure your application to activate automatically every time it is run, as this can cause many problems that affect the reliability of your application, and is considered a misuse of the SOLO Server activation web services. If you wish to validate the status of the license with SOLO Server in your application, use background checking. If you wish to offer a limited number of users an option to check-in/check-out seats for a license, consider using Network Floating Licensing features for this purpose.

The following guide extends on the example license implementation to demonstrate activating an installation, retrieving a license file from SOLO Server, and then saving that license file to disk. For all example code excerpts, [License File Path] should be replaced with the actual path to your license file (which you may store in a constant or property in your license implementation class).

Online Activation

Important

If you are using or planning to use PLUSManagedGui in your application, this content may not be relevant to you since PLUSManagedGui automatically handles common functionality.

PLUSManaged has different ways of calling to the SOLO Server web services. Typically, you will only need to perform activation from your license implementation code, which inherits from License or WritableLicense.  License and WritableLicense both contain methods which simplify calling SOLO Server web services.  The example code excerpt below illustrates how your application's license implementation class may leverage these convenience methods to support activation.

C#
public bool ActivateOnline(Int32 licenseId, string password)
{
//initialize the object used for calling the web service method
XmlActivationService ws = new XmlActivationService();

string lfContent = "";
if (!this.ActivateInstallationLicenseFile(licenseId, password, ws, ref lfContent))
return false;


//try to save the license file to the file system
try
{
File.WriteAllText("[License File Path]", lfContent);
}
catch (Exception ex)
{
this.LastError = new LicenseError(LicenseError.ERROR_COULD_NOT_SAVE_LICENSE, ex);
return false;
}

return true;
}
VB.NET
Public Overloads Function ActivateOnline(ByVal licenseId As Int32, ByVal password As String) As Boolean
'initialize the object used for calling the web service method
Dim ws As New XmlActivationService()

Dim lfContent As String = ""
If Not Me.ActivateInstallationLicenseFile(licenseId, password, ws, lfContent) Then
Return False
End If

'try to save the license file to the file system
Try
File.WriteAllText("[License File Path]", lfContent)
Catch ex As Exception
Me.LastError = New LicenseError(LicenseError.ERROR_COULD_NOT_SAVE_LICENSE, ex)
Return False
End Try

Return True
End Function

Online Activation with Serial Number and Product ID

PLUSManaged allows activating an application using the Product ID and a serial number pre-loaded into SOLO Server. This method can be used instead of activating with a License ID and Activation Password, and it allows the use of your own activation serial numbers. This can be useful if your customers are already familiar with a certain license key format or if you need to import a list of serials from another system.

Adding Serial Numbers to Licenses in SOLO Server

The SOLO Server manual topic Importing and Exporting Product Serial Numbers explains how to load a list of serial numbers in SOLO Server. Each time a new license is created for that Product, the next unused serial number in the list will be associated with the license. To issue a serial number to an existing license after uploading the serials, you can simply view the license in SOLO Server and choose the Issue Serial Number option in the Licenses menu.

You must use the mechanism described above to import serial numbers into SOLO Server. Attempting to manually enter a serial number into the serial number field by editing a License in SOLO Server will result in the activation failing with a Response Code of 100.

Activating with a Serial Number

PLUSManaged has different ways of calling to the SOLO Server web services. Typically, to use the Product ID/Serial Number method of activation, you will need to perform the activation using the ActivateInstallation or ActivateInstallationLicenseFile class.

When the license is retrieved from SOLO Server through activating or other means, the serial number can be read from the local license file using the PLUSManaged License.SerialNumber property.

The example code excerpt below illustrates how your application's license implementation class may leverage these convenience methods to support activation.

C#
public bool ActivateOnlineSerialNumber(string serialNumber)
{
//Initialize the objects used for calling the web service method
XmlActivationService ws = new XmlActivationService();
ActivateInstallationLicenseFile activate = new ActivateInstallationLicenseFile(ws, this.GetEncryptionKey());
activate.ProductID = this.ThisProductID;
activate.SerialNumber = serialNumber;
activate.LicenseID = 0;
activate.Password = string.Empty;
activate.ProductVersion = this.ProductVersion;

//Add the Current System Identifiers to the request
if (this.CurrentIdentifiers.Count > 0)
{
activate.ActivationData = SystemIdentifier.GenerateActivationDataXml(this.CurrentIdentifiers);
}

//Encrypt the activation request
if (string.IsNullOrEmpty(activate.GenerateEncryptedRequest()))
{
return false;
}

//Call the web service
if (false == activate.CallWebService())
{
return false;
}

if (0 != activate.ResultCode)
{
return false;
}

//Try to save the license file to the file system
try
{
File.WriteAllText("[License File Path]", activate.LicenseFileContents);
}
catch (Exception ex)
{
this.LastError = new LicenseError(LicenseError.ERROR_COULD_NOT_SAVE_LICENSE, ex);
return false;
}

return true;
}
VB.NET
Public Overloads Function ActivateOnlineSerialNumber(ByVal serialNumber As String) As Boolean
'Initialize the objects used for calling the web service method
Dim ws As XmlActivationService = New XmlActivationService()
Dim activate As ActivateInstallationLicenseFile = New ActivateInstallationLicenseFile(ws, Me.GetEncryptionKey())
activate.ProductID = Me.ThisProductID
activate.SerialNumber = SerialNumber
activate.LicenseID = 0
activate.Password = String.Empty
activate.ProductVersion = Me.ProductVersion

'Add the Current System Identifiers to the request
If Me.CurrentIdentifiers.Count > 0 Then
activate.ActivationData = SystemIdentifier.GenerateActivationDataXml(Me.CurrentIdentifiers)
End If

'Encrypt the activation request
If String.IsNullOrEmpty(activate.GenerateEncryptedRequest()) Then
Return False
End If

'Call the web service
If False = activate.CallWebService() Then
Return False
End If

If 0 <> activate.ResultCode Then
Return False
End If

'Try to save the license file to the file system
Try
File.WriteAllText("[License File Path]", activate.LicenseFileContents)
Catch ex As Exception
Me.LastError = New LicenseError(LicenseError.ERROR_COULD_NOT_SAVE_LICENSE, ex)
Return False
End Try

Return True
End Function