Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Portable.Licensing how to validate the attribute hardware Id

Tags:

c#

licensing

I am working on certain project. All i need is to provide the license of the product to only one computer so i added an additional attribute hardware Id as shown in fig .How can i validate it. help me out in this regard. Thanks..

var license = Portable.Licensing.License.New()
                   .WithUniqueIdentifier(Guid.NewGuid())
                   .As(Portable.Licensing.LicenseType.Trial)
                   .ExpiresAt(DateTime.Now.AddDays(5))
                   .WithMaximumUtilization(Int32.Parse(User.Text))
                   .WithAdditionalAttributes(new Dictionary<String,String>{
                                               {"Hardware ID","12343"}
                                                })
                   .LicensedTo(name.Text, email.Text)
                   .CreateAndSignWithPrivateKey(privateKey, "212555555");
like image 941
Srikanth Mudale Avatar asked Feb 17 '16 07:02

Srikanth Mudale


1 Answers

Well I found the answer for this very simple one.

  1. Using AssertThat() method provided by Portable.Licencing. ex:-

            var validationFailures = licenseContent.Validate()
            .ExpirationDate()
            .When(lic => lic.Type == Portable.Licensing.LicenseType.Trial)
            .And()
            .AssertThat(lic => lic.Quantity >= 3, failure1)
            .And()
            .AssertThat(lic => lic.ProductFeatures.Get("HardwareID") == "133456", failure1)
            .When(lic => lic.ProductFeatures.Contains("HardwareID"))
            .And()
            .Signature(publicKey)
            .AssertValidLicense().ToList();
    
  2. Write your own validation case.

like image 99
Srikanth Mudale Avatar answered Oct 10 '22 02:10

Srikanth Mudale