question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LicenseType is not validated

See original GitHub issue

A license is returned as valid despite the different license types, e.g. if License.LicenseType = LicneseType.Trail and one tries to use the following example from your documentation and using the following code:

var passPhrase = "TestPassword101";
var keyGenerator = Standard.Licensing.Security.Cryptography.KeyGenerator.Create();
var keyPair = keyGenerator.GenerateKeyPair();
var privateKey = keyPair.ToEncryptedPrivateKeyString (passPhrase);
var publicKey = keyPair.ToPublicKeyString();

var license = License.New()
    .WithUniqueIdentifier (Guid.NewGuid())
    .As (LicenseType.Trial)
    .ExpiresAt (DateTime.Now.AddDays (30))
    .WithMaximumUtilization (5)
    .WithProductFeatures (new Dictionary<string, string>
        {
            {"Sales Module", "yes"},
            {"Purchase Module", "yes"},
            {"Maximum Transactions", "10000"}
        })
    .LicensedTo ("John Doe", "john.doe@example.com")
    .CreateAndSignWithPrivateKey (privateKey, passPhrase);

var savedLicense = license.ToString();

var licenseToVerify = License.Load (savedLicense);

var validationFailures = license.Validate()
                                .ExpirationDate()
                                .When (lic => lic.Type == LicenseType.Standard)
                                .And()
                                .Signature (publicKey)
                                .AssertValidLicense();

if (validationFailures.Any())
{
    foreach (var failure in validationFailures)
        Console.WriteLine (failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);
}
else
    Console.WriteLine ("License valid!");


var errors = license.Validate()
       .AssertThat (lic => lic.Type == LicenseType.Standard,
                    new GeneralValidationFailure ("License type wrong!"))
       .AssertValidLicense().ToList();

Console.WriteLine ($"\nErrors found: {errors.Any ()}");

if (errors.Any())
{
    foreach (var failure in errors)
        Console.WriteLine (failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);
}
else
    Console.WriteLine ("License valid!");

then no validationFailures.Any() == true! but should be false.

When using the Assert.That then the error is detected as can be seen if the above code is run.

Either I did not understand the purpose of the When clause or it is an error.

In the former case, I’d be happy to learn the purpose and in the later to learn about the correction.

Cheers,

Peter

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
RFC1920commented, Mar 25, 2022

Seems that I can also modify the signature and ID randomly and the license still validates as Trial with the expiration of 12/31/9999 😦

0reactions
AntiGuideAkquinetcommented, Feb 24, 2023

The issue you describe does indeed seem like a bug:

Seems that I can also modify the signature and ID randomly and the license still validates as Trial with the expiration of 12/31/9999 😦

The example code provides an IEnumerable<IValidationFailure> which seems to return an error like it should the first time it is enumerated. Sadly a second enumeration provides no failures.

grafik

I opened issue #28 to track this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error "This license type is not a valid software type for your ...
Error "This license type is not a valid software type for your installation" when trying to activate a small-molecule license in UNIFI - ......
Read more >
License type validation in variation and variation type forms ...
There's two options. 1. Leaving allowed license types in the product variation type form means all types are allowed. 2. Enforce selection of...
Read more >
No valid user license type provision that is currently effective
When i upgrade arcgis portal 10.7 to 10.8 in an offline environment, i downloaded new license from my esri that matches the previous...
Read more >
SSIS Runtime error - License type [SSIS_PP_TRIAL] not found
There can be multiple reasons for this error but in nutshell, this error occurs when no valid license found for the feature you...
Read more >
NX> 500 ERROR: license type APS is not valid
When trying to activate an AVC codec.lic I am getting the following: [shingler@shingler6324] Downloads $ sudo /usr/NX/bin/nxserver –activate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found