StringLicenseBuilder
Namespace: Babel.Licensing Assembly: Babel.Licensing.dll
This class is used to generate encoded license strings. This class cannot be inherited.
Inheritance
Implements
ILicenseBuilder, ICreateCustomRestriction, ICreateCustomSignatureProvider, IReadableLicenseString
Inherited Members
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Extension Methods
Licenseable.AddLicense<StringLicenseBuilder>(StringLicenseBuilder, ILicense), Licenseable.Load(ILicenseBuilder, string), Licenseable.RemoveLicense<StringLicenseBuilder>(StringLicenseBuilder, ILicense), Licenseable.Save<StringLicenseBuilder>(StringLicenseBuilder, string), Licenseable.SignWith(ILicenseBuilder, ISignatureProvider), Licenseable.SignWithKeys(ILicenseBuilder, string, string), Licenseable.ToReadableString(ILicenseBuilder, string), Licenseable.ValidateSignature(ILicenseBuilder)
Constructors
StringLicenseBuilder()
Create a new instance of class.
Examples
StringLicenseBuilder(ISignatureProvider)
Create a new instance of class with the given signature provider.
Parameters
The license signature provider .
Exceptions
Thrown when one or more required arguments are null.
Properties
Format
Gets or sets the used to generate the license.
Property Value
SignatureProvider
Gets or sets the signature provider. The signature provider is used to sign and verify the integrity of the license data.
Property Value
Examples
Methods
AddOrUpdate(ILicense)
Adds a with a given key to the if the license does not already exists, or updates the if the key already exists.
Parameters
The object.
Exceptions
Thrown when the license argument is null.
Load(Stream)
Loads the license from the specified file.
Parameters
Specify the input license stream.
Exceptions
Thrown when the fileName argument is null.
Thrown when the file contains bad data.
Load(TextReader)
Loads the license from the given text reader.
Parameters
The used to read the license.
Exceptions
Thrown when the reader argument is null.
Thrown when the reads bad data.
Parse(string)
Parse the input license string. If the string is not a valid encoded license string, it throws a .
Parameters
The encoded license string to parse.
Remove(ILicense)
Removes a with a given key from the .
Parameters
The object to be removed.
Returns
true
if the license is successfully removed, false
if it fails to remove the license.
Exceptions
Thrown when the license argument is null.
Save(Stream)
Saves the current license state to the specified file.
Parameters
The output license stream.
Examples
This sample shows how to generate and save an encoded license string to a file.
Exceptions
Thrown when the fileName argument is null.
Save(TextWriter)
Saves the current license using the given .
Parameters
The object used to save the license.
Exceptions
Thrown when the writer argument is null.
SetMask(byte[])
Sets the mask used to generate the license.
Parameters
An array of bytes.
Exceptions
Thrown when one or more required arguments are null.
SetMaskSize(int)
Sets the mask size used to randomize the generated license.
Parameters
The size represent the number of bytes used to randomize the license.
Examples
Exceptions
Thrown when the size argument is a negative number.
Sign()
Add a signature to the current license object.
Exceptions
Thrown if there is the signature cannot be generated.
ToLicenses()
Converts this object to a object.
Returns
This object as a .
ToReadableString(string)
Converts the current license state to a readable string.
Parameters
Describes the format to use.
Returns
The current license state as a string.
ToString(string)
Returns an encoded license string according to the format specified.
Parameters
Describes the format to use. This can be ASCII or Base32.
Returns
A string that represents the current license in the given format.
Exceptions
Thrown if the format parameter is null.
Thrown when the format parameter specified is not valid.
ToString()
Returns an encoded string that represents the current license.
Returns
A string that represents the current license in the format specified for .
Validate()
Validates the current license signature. This method doesn't validate license restrictions. Is not meant to be used to validate the license in client applications. To validate the license in client applications use the class.
Returns
true if the signature id valid, false if the signature is not present or not valid.
CreateCustomRestriction
Event queue for all listeners interested in CreateCustomRestriction events.
Event Type
EventHandler<CreateCustomRestrictionEventArgs>
CreateCustomSignatureProvider
Event queue for all listeners interested in CreateCustomSignatureProvider events.
Event Type
EventHandler<CreateCustomSignatureProviderEventArgs>
Examples
This example shows how to implement a custom MD5 signature provider.
The MD5 signature can be used to create and validate the license key.
Last updated