Public classPackageLicenseDefinition
A package license key definition
Public classPackageLicenseHelper
This class contains methods for handling package licenses


Here is an example of how a pacakge could validat if there is a valid license installed for the pacakge. This code should be compiled into the pacakge itself to prevent spoofing.
Guid productId = ...; // A package should have this compiled into its assembly.
string publicKeyXml = ...; // A package should have this compiled into its assembly.

PackageLicenseDefinition licenseDefinition = PackageLicenseHelper.GetLicenseDefinition(productId);
Guid installationId = licenseDefinition.InstallationId; 
bool isPermanent = licenseDefinition.Permanent;
DateTime expiresTime = licenseDefinition.Expires;

byte[] signedSignature = licenseDefinition.LicenseKeyBytes;

// Create the signature string
string signatureString;
if (isPermanent)
    signatureString = string.Format("{0}#{1}#{2}", installationId, productId, isPermanent);
    signatureString = string.Format("{0}#{1}#{2}#{3}", installationId, productId, isPermanent, new XAttribute("date", expiresTime).Value);
byte[] signature = PackageLicenseHelper.CreateSignatureBytes(signatureString);

// Create the provider to verify the signature string
RSACryptoServiceProvider provider = new RSACryptoServiceProvider();

object hashAlgorithm = PackageLicenseHelper.CreateSignatureHashAlgorithm(publicKeyXml);

// isValidKey tells if the package license xml file has been tampered with
bool isValidKey = provider.VerifyData(signature, hashAlgorithm, signedSignature);

// isExpried tells if a trail license is expired, false if its a permanent license
bool isExpired = !isPermanent < expiresTime < DateTime.Now;

// isLicenseValid is a combination of isValidKey and isExpired and is only true if the package license xml file has not been tampered with and the license is not expired
bool isLicenseValid = isValidKey & !isExpired;
Public classPackageUtils
This class contains helper methods for handling packages