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
Name | Description |
---|---|
| The license signature provider . |
Exceptions
Name | Description |
---|---|
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
Name | Description |
---|---|
| The object. |
Exceptions
Name | Description |
---|---|
Thrown when the license argument is null. |
Load(Stream)
Loads the license from the specified file.
Parameters
Name | Description |
---|---|
| Specify the input license stream. |
Exceptions
Name | Description |
---|---|
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
Name | Description |
---|---|
| The used to read the license. |
Exceptions
Name | Description |
---|---|
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
Name | Description |
---|---|
| The encoded license string to parse. |
Remove(ILicense)
Removes a with a given key from the .
Parameters
Name | Description |
---|---|
| The object to be removed. |
Returns
Name | Description |
---|---|
|
Exceptions
Name | Description |
---|---|
Thrown when the license argument is null. |
Save(Stream)
Saves the current license state to the specified file.
Parameters
Name | Description |
---|---|
| The output license stream. |
Examples
This sample shows how to generate and save an encoded license string to a file.
Exceptions
Name | Description |
---|---|
Thrown when the fileName argument is null. |
Save(TextWriter)
Saves the current license using the given .
Parameters
Name | Description |
---|---|
| The object used to save the license. |
Exceptions
Name | Description |
---|---|
Thrown when the writer argument is null. |
SetMask(byte[])
Sets the mask used to generate the license.
Parameters
Name | Description |
---|---|
| An array of bytes. |
Exceptions
Name | Description |
---|---|
Thrown when one or more required arguments are null. |
SetMaskSize(int)
Sets the mask size used to randomize the generated license.
Parameters
Name | Description |
---|---|
| The size represent the number of bytes used to randomize the license. |
Examples
Exceptions
Name | Description |
---|---|
Thrown when the size argument is a negative number. |
Sign()
Add a signature to the current license object.
Exceptions
Name | Description |
---|---|
Thrown if there is the signature cannot be generated. |
ToLicenses()
Converts this object to a object.
Returns
Name | Description |
---|---|
This object as a . |
ToReadableString(string)
Converts the current license state to a readable string.
Parameters
Name | Description |
---|---|
| Describes the format to use. |
Returns
Name | Description |
---|---|
The current license state as a string. |
ToString(string)
Returns an encoded license string according to the format specified.
Parameters
Name | Description |
---|---|
| Describes the format to use. This can be ASCII or Base32. |
Returns
Name | Description |
---|---|
A string that represents the current license in the given format. |
Exceptions
Name | Description |
---|---|
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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