XmlLicenseManager

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

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

public class XmlLicenseManager : ICreateCustomRestriction, ICreateCustomSignatureProvider

Inheritance

objectXmlLicenseManager

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

XmlLicenseManager()

public XmlLicenseManager()

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 XML string is a valid license.

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

Parameters

NameDescription

xml string

The XML 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 XML 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 XmlLicenseManager 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 XML license.

public XmlLicense Validate(string xml, Type type = null, object instance = null)

Parameters

NameDescription

xml string

The XML license string.

type Type

The type associated with the license.

instance object

The object instance associated with the license.

Returns

NameDescription

An XmlLicense 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 XmlLicenseManager 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