HardwareRestriction

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

Defines an hardware object. The hardware restriction tie the license to a particular hardware represented by a key string. This class cannot be inherited.

public class HardwareRestriction : Restriction, IObservableObject

Inheritance

objectRestrictionHardwareRestriction

Implements

IObservableObject

Inherited Members

Restriction.Validate(ILicenseContext, Type, object), Restriction.Attach(IObjectListener), Restriction.Detach(IObjectListener), Restriction.Notify(params object[]), Restriction.Name, Restriction.License, Restriction.Listeners, Restriction.Id, Restriction.ExpireDate, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

// Creates an XML license for a specific hardware 
var license = new XmlLicense();

// Add the hardware key
// The hardware key can be generated using the 
// Babel.Licensing.HardwareId class
HardwareRestriction hardware = new HardwareRestriction();
hardware.HardwareKey = "EFP76-XAJXI-655MU-JAQVX-LGYL6";

license.Restrictions.Add(hardware);

var signer = XmlDigitalSignature.CreateFromKeyFile("Keys.snk");

string licenseXML = license.SignWith(signer)
                           .ToReadableString();

// The same license can be generated using fluent API
var signer = XmlDigitalSignature.CreateFromKeyFile("Keys.snk");

string licenseXML = new XmlLicense().WithHardwareKey("EFP76-XAJXI-655MU-JAQVX-LGYL6")
                                    .SignWith(signer)
                                    .ToReadableString();

//<Licenses xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
//  <License>
//    <Restrictions>
//      <Restriction xsi:type="Hardware">
//        <HardwareKey>EFP76-XAJXI-655MU-JAQVX-LGYL6</HardwareKey>
//      </Restriction>
//    </Restrictions>
//  </License>
//  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
//    <SignedInfo>
//      <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
//      <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
//      <Reference URI="">
//        <Transforms>
//          <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
//        </Transforms>
//        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
//        <DigestValue>vBCBlHCwDoJuU8+hZ5k9b2jRKfk=</DigestValue>
//      </Reference>
//    </SignedInfo>
//    <SignatureValue>CnSM...</SignatureValue>
//  </Signature>
//</Licenses>

Constructors

HardwareRestriction()

Initializes a new instance of the class.

public HardwareRestriction()

Properties

Data

Gets additional hardware information.

public byte[] Data { get; set; }

Property Value

byte[]

HardwareKey

Gets the hardware key.

public string HardwareKey { get; set; }

Property Value

string

Name

Gets the restriction name.

public override string Name { get; }

Property Value

string

Methods

Validate(ILicenseContext, Type, object)

Validates the current hardware restriction.

public override ValidationResult Validate(ILicenseContext context, Type type, object instance)

Parameters

NameDescription

The license context.

type Type

The for which the restriction is validated.

instance object

The object instance for which the restriction is validated.

Returns

NameDescription

The validation result code .

Last updated