StringLicenseManager

Namespace: Babel.Licensing Assembly: Babel.Licensing.dll

This class is used to validate string licenses and get object from license string.

public class StringLicenseManager : ICreateCustomRestriction, ICreateCustomSignatureProvider

Inheritance

objectStringLicenseManager

Implements

ICreateCustomRestriction, ICreateCustomSignatureProvider

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

StringLicenseManager()

public StringLicenseManager()

Properties

CurrentContext

Gets or sets the license context.

public ILicenseContext CurrentContext { get; set; }

Property Value

ILicenseContext

LicenseFactory

Gets or sets the license factory.

public ILicenseFactory LicenseFactory { get; set; }

Property Value

ILicenseFactory

SignatureProvider

Gets or sets the signature provider.

public ISignatureProvider SignatureProvider { get; set; }

Property Value

ISignatureProvider

Methods

IsValid(string, Type, object)

Determines whether the given string is a valid license.

public bool IsValid(string license, Type type = null, object instance = null)

Parameters

NameDescription

license string

The license string.

type Type

The type associated with the license.

instance object

The object instance associated with the license.

Returns

NameDescription

true if the given string license is valid; otherwise, false.

Remarks

To successfully validate a license, the license must be signed and the signature must carry enough information to reconstruct the object valid for validating signatures. For instance, if you have signed the license with an object, the signature must include the public key. If the public key is not available inside the signature element, it will be extracted from the assembly strong name information. If the assembly is not signed and the public key is not embedded into the signature element the validation will fails. For signature generated by the provider, the public key cannot be extracted from the assembly strong name as ECDsa signatures are not based on RSA algorithm used to strong name the assembly. In this scenario the ECDsa signature must carry the public key information to validate the signature. If the signature does not embed the public key information, you should provide the StringLicenseManager with an instance of the provider generated from the ECDsa public key before calling any validation method. To embed into the signature the key information required for the validation, the signature provider must implement the interface and the property must be set to true.

OnCreateCustomRestriction(CreateCustomRestrictionEventArgs)

Raises the CreateCustomRestriction event.

protected virtual void OnCreateCustomRestriction(CreateCustomRestrictionEventArgs ea)

Parameters

NameDescription

Event information to send to registered event handlers.

OnCreateCustomSignatureProvider(CreateCustomSignatureProviderEventArgs)

Raises the CreateCustomSignatureProvider event.

protected virtual void OnCreateCustomSignatureProvider(CreateCustomSignatureProviderEventArgs ea)

Parameters

NameDescription

Event information to send to registered event handlers.

Validate(string, Type, object)

Validates the string license.

public StringLicense Validate(string licenseKey, Type type = null, object instance = null)

Parameters

NameDescription

licenseKey string

The string license string.

type Type

The type associated with the license.

instance object

The object instance associated with the license.

Returns

NameDescription

An object that has been validated.

Remarks

To successfully validate a license, the license must be signed and the signature must carry enough information to reconstruct the object valid for validating signatures. For instance, if you have signed the license with an object, the signature must include the public key. If the public key is not available inside the signature element, it will be extracted from the assembly strong name information. If the assembly is not signed and the public key is not embedded into the signature element the validation will fails. For signature generated by the provider, the public key cannot be extracted from the assembly strong name as ECDsa signatures are not based on RSA algorithm used to strong name the assembly. In this scenario the ECDsa signature must carry the public key information to validate the signature. If the signature does not embed the public key information, you should provide the StringLicenseManager with an instance of the provider generated from the ECDsa public key before calling any validation method. To embed into the signature the key information required for the validation, the signature provider must implement the interface and the property must be set to true.

Exceptions

NameDescription

Thrown when one or more required arguments are null.

Thrown when a Babel License error condition occurs.

CreateCustomRestriction

Event queue for all listeners interested in CreateCustomRestriction events.

public event EventHandler<CreateCustomRestrictionEventArgs> CreateCustomRestriction

Event Type

EventHandler<CreateCustomRestrictionEventArgs>

CreateCustomSignatureProvider

Event queue for all listeners interested in CreateCustomSignatureProvider events.

public event EventHandler<CreateCustomSignatureProviderEventArgs> CreateCustomSignatureProvider

Event Type

EventHandler<CreateCustomSignatureProviderEventArgs>

Last updated