This class contains methods for handling package licenses
Namespace: Composite.Core.PackageSystem
Examples
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.
CopyC#

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); } else { 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(); provider.FromXmlString(publicKeyXml); 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;
Assembly: Composite (in Composite.dll) Version: 5.3.6135.33083
Syntax
C# |
---|
public static class PackageLicenseHelper |
Visual Basic |
---|
Public NotInheritable Class PackageLicenseHelper |
Visual C++ |
---|
public ref class PackageLicenseHelper abstract sealed |