LicenseType is not validated
See original GitHub issueA 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:
- Created a year ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 issue you describe does indeed seem like a bug:
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.I opened issue #28 to track this.