SignedLicense IBuilder_Properties.SignAndCreate()
        {
            var license = new SignedLicense(myHardwareIdentifier, mySerialNumber, DateTime.Now, myExpirationDate, myProperties);

            license.Sign(mySigner);
            return(license);
        }
Esempio n. 2
0
        public void TestSerialization()
        {
            var license = new SignedLicense(HardwareIdentifier.NoHardwareIdentifier, "SerialNumber", DateTime.Now, DateTime.Now + TimeSpan.FromDays(10), CreateProperties());

            license.Sign(new LengthSigner());
            var licPlainText = license.SerializeAsPlainText();
            var licEncrypted = license.Serialize();

            var licensePlainText = SignedLicense.Deserialize(licPlainText);
            var licenseEncrypted = SignedLicense.Deserialize(licEncrypted);

            Assert.AreEqual(licensePlainText.SerializeAsPlainText(), licenseEncrypted.SerializeAsPlainText());
            Assert.AreEqual(licensePlainText.Serialize(), licenseEncrypted.Serialize());
        }
Esempio n. 3
0
        public void TestSigning_WithProperties_DifferentCultures()
        {
            var cultureDE = new CultureInfo("de");
            var cultureEN = new CultureInfo("en");


            Thread.CurrentThread.CurrentCulture = cultureDE;
            var file = new SignedLicense("HardwareID", "SerialNumber", DateTime.Now, DateTime.Now + TimeSpan.FromDays(10), CreateProperties());

            file.Sign(new HashCodeSigner());
            var content = file.Serialize();

            Thread.CurrentThread.CurrentCulture = cultureEN;
            var newFile = SignedLicense.Deserialize(content);

            newFile.Verify(new HashCodeSigner());
        }
Esempio n. 4
0
        public void TestSigning_WithProperties()
        {
            var file = new SignedLicense("HardwareID", "SerialNumber", DateTime.Now, DateTime.Now + TimeSpan.FromDays(10), CreateProperties());

            file.Sign(new LengthSigner());
            var content = file.Serialize();
            var newFile = SignedLicense.Deserialize(content);

            AssertDefaultPropertiesAreValid(newFile);
            AssertPropertiesAreValid(file);
            newFile.Verify(new LengthSigner());

            try
            {
                newFile.Verify(new DoubleLengthSigner());
                Assert.Fail("LicenseException expected");
            }
            catch (SignedLicenseException) { }
        }