public void Before_each_test() { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); smallKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); license = new ClientLicense(); generationOptions = new LicenseGenerationOptions(); license.UniqueId = Guid.NewGuid(); license.Product = new Product(); license.Product.Name = "My Great Uber Cool Product, with new juice!"; license.Product.ProductId = 1; license.LicenseSets = new NotifyList <LicenseSet>(); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.First().SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets.First().SupportedLicenseTypes |= LicenseKeyTypeFlag.Enterprise; license.LicenseSets.First().SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; generationOptions.LicenseKeyType = LicenseKeyTypes.Enterprise; string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); placeholders = smallKeyGenerator.CreateLicensePlaceholders(license, generationOptions); placeholdersInTemplate = KeyGenerator.FindAllPlaceholdersInTemplate(KeyGenerator.licenseKeyTemplate, placeholders); key = smallKeyGenerator.GenerateLicenseKey("TEST", license, generationOptions); }
public void SetupTests() { license = new ClientLicense(); license.UniqueId = Guid.NewGuid(); license.LicenseSets = new NotifyList <LicenseSet>(); LicenseSet ls = new LicenseSet(); ls.SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; ls.Name = "Standard License Set"; ls.UniquePad = new Guid(); license.LicenseSets.Add(ls); generationOptions = new LicenseGenerationOptions(); license.Product = new Product(); license.Product.Name = "My Great Uber Cool Product, with new juice!"; license.Product.ProductId = 1; packingService = new PackingService(numberDataGenerationProvider); clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider); clientLicenseService = new ClientLicenseService(clientLicenseRepository); string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); LicenseActiviationProvider licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider); staticKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); staticKeyGeneratorLarge = new Scutex.Generators.StaticKeyGeneratorLarge.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService); licenseKeyService = new LicenseKeyService(staticKeyGenerator, staticKeyGeneratorLarge, packingService, clientLicenseService); }
public void Before_each_test() { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); smallKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); license = new ClientLicense(); generationOptions = new LicenseGenerationOptions(); license.UniqueId = Guid.NewGuid(); license.Product = new Product(); license.Product.Name = "My Great Uber Cool Product, with new juice!"; license.Product.ProductId = 1; license.LicenseSets = new NotifyList<LicenseSet>(); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.First().SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets.First().SupportedLicenseTypes |= LicenseKeyTypeFlag.Enterprise; license.LicenseSets.First().SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; generationOptions.LicenseKeyType = LicenseKeyTypes.Enterprise; string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); placeholders = smallKeyGenerator.CreateLicensePlaceholders(license, generationOptions); placeholdersInTemplate = KeyGenerator.FindAllPlaceholdersInTemplate(KeyGenerator.licenseKeyTemplate, placeholders); key = smallKeyGenerator.GenerateLicenseKey("TEST", license, generationOptions); }
public void Checksum32LargeDataSet() { uint checksum = provider.Checksum32(testLargeChecksumData); string hex = checksum.ToString("X"); }
public void Before_each_test() { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); var mock = new Mock<IHardwareFingerprintService>(); mock.Setup(foo => foo.GetHardwareFingerprint(FingerprintTypes.Default)).Returns("JustATestFingerprint1050"); _hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), hashingProvider); largeKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, mock.Object); license = new ClientLicense(); generationOptions = new List<LicenseGenerationOptions>(); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); license.UniqueId = Guid.NewGuid(); license.Product = new Product(); license.Product.Name = "My Great Uber Cool Product, with new juice!"; license.Product.ProductId = 1; license.LicenseSets = new NotifyList<LicenseSet>(); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets[0].LicenseSetId = 1; license.LicenseSets[0].Name = "Standard Edition"; license.LicenseSets[0].MaxUsers = 5; license.LicenseSets[0].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[0].SupportedLicenseTypes |= LicenseKeyTypeFlag.MultiUser; license.LicenseSets[0].SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; license.LicenseSets[1].LicenseSetId = 2; license.LicenseSets[1].Name = "Professional Edition"; license.LicenseSets[1].MaxUsers = 5; license.LicenseSets[1].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[1].SupportedLicenseTypes |= LicenseKeyTypeFlag.MultiUser; license.LicenseSets[1].SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; license.LicenseSets[2].LicenseSetId = 3; license.LicenseSets[2].Name = "Enterprise Edition"; license.LicenseSets[2].MaxUsers = 5; license.LicenseSets[2].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[2].SupportedLicenseTypes |= LicenseKeyTypeFlag.MultiUser; license.LicenseSets[2].SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; license.LicenseSets[2].SupportedLicenseTypes |= LicenseKeyTypeFlag.Enterprise; license.LicenseSets[3].LicenseSetId = 4; license.LicenseSets[3].Name = "Upgrade Edition"; license.LicenseSets[3].MaxUsers = 0; license.LicenseSets[3].IsUpgradeOnly = true; license.LicenseSets[3].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[4].LicenseSetId = 5; license.LicenseSets[4].Name = "Hardware Edition"; license.LicenseSets[4].MaxUsers = 0; license.LicenseSets[4].IsUpgradeOnly = false; license.LicenseSets[4].SupportedLicenseTypes = LicenseKeyTypeFlag.HardwareLock; generationOptions[0].LicenseKeyType = LicenseKeyTypes.SingleUser; generationOptions[0].LicenseSetId = 1; generationOptions[1].LicenseKeyType = LicenseKeyTypes.Enterprise; generationOptions[1].LicenseSetId = 2; generationOptions[2].LicenseKeyType = LicenseKeyTypes.Enterprise; generationOptions[2].LicenseSetId = 3; generationOptions[3].LicenseKeyType = LicenseKeyTypes.Enterprise; generationOptions[3].LicenseSetId = 4; generationOptions[4].LicenseKeyType = LicenseKeyTypes.HardwareLock; generationOptions[4].HardwareFingerprint = "JustATestFingerprint1050"; generationOptions[4].LicenseSetId = 5; generationOptions[5].LicenseKeyType = LicenseKeyTypes.HardwareLockLocal; generationOptions[5].HardwareFingerprint = "JustATestFingerprint1050"; generationOptions[5].LicenseSetId = 5; string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); placeholders = largeKeyGenerator.CreateLicensePlaceholders(license, generationOptions[0]); placeholdersInTemplate = KeyGenerator.FindAllPlaceholdersInTemplate(KeyGenerator.licenseKeyTemplate, placeholders); key = largeKeyGenerator.GenerateLicenseKey("TEST", license, generationOptions[0]); }
public void Before_each_test() { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); var mock = new Mock <IHardwareFingerprintService>(); mock.Setup(foo => foo.GetHardwareFingerprint(FingerprintTypes.Default)).Returns("JustATestFingerprint1050"); _hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), hashingProvider); largeKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, mock.Object); license = new ClientLicense(); generationOptions = new List <LicenseGenerationOptions>(); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); generationOptions.Add(new LicenseGenerationOptions()); license.UniqueId = Guid.NewGuid(); license.Product = new Product(); license.Product.Name = "My Great Uber Cool Product, with new juice!"; license.Product.ProductId = 1; license.LicenseSets = new NotifyList <LicenseSet>(); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets.Add(new LicenseSet()); license.LicenseSets[0].LicenseSetId = 1; license.LicenseSets[0].Name = "Standard Edition"; license.LicenseSets[0].MaxUsers = 5; license.LicenseSets[0].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[0].SupportedLicenseTypes |= LicenseKeyTypeFlag.MultiUser; license.LicenseSets[0].SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; license.LicenseSets[1].LicenseSetId = 2; license.LicenseSets[1].Name = "Professional Edition"; license.LicenseSets[1].MaxUsers = 5; license.LicenseSets[1].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[1].SupportedLicenseTypes |= LicenseKeyTypeFlag.MultiUser; license.LicenseSets[1].SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; license.LicenseSets[2].LicenseSetId = 3; license.LicenseSets[2].Name = "Enterprise Edition"; license.LicenseSets[2].MaxUsers = 5; license.LicenseSets[2].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[2].SupportedLicenseTypes |= LicenseKeyTypeFlag.MultiUser; license.LicenseSets[2].SupportedLicenseTypes |= LicenseKeyTypeFlag.Unlimited; license.LicenseSets[2].SupportedLicenseTypes |= LicenseKeyTypeFlag.Enterprise; license.LicenseSets[3].LicenseSetId = 4; license.LicenseSets[3].Name = "Upgrade Edition"; license.LicenseSets[3].MaxUsers = 0; license.LicenseSets[3].IsUpgradeOnly = true; license.LicenseSets[3].SupportedLicenseTypes = LicenseKeyTypeFlag.SingleUser; license.LicenseSets[4].LicenseSetId = 5; license.LicenseSets[4].Name = "Hardware Edition"; license.LicenseSets[4].MaxUsers = 0; license.LicenseSets[4].IsUpgradeOnly = false; license.LicenseSets[4].SupportedLicenseTypes = LicenseKeyTypeFlag.HardwareLock; generationOptions[0].LicenseKeyType = LicenseKeyTypes.SingleUser; generationOptions[0].LicenseSetId = 1; generationOptions[1].LicenseKeyType = LicenseKeyTypes.Enterprise; generationOptions[1].LicenseSetId = 2; generationOptions[2].LicenseKeyType = LicenseKeyTypes.Enterprise; generationOptions[2].LicenseSetId = 3; generationOptions[3].LicenseKeyType = LicenseKeyTypes.Enterprise; generationOptions[3].LicenseSetId = 4; generationOptions[4].LicenseKeyType = LicenseKeyTypes.HardwareLock; generationOptions[4].HardwareFingerprint = "JustATestFingerprint1050"; generationOptions[4].LicenseSetId = 5; generationOptions[5].LicenseKeyType = LicenseKeyTypes.HardwareLockLocal; generationOptions[5].HardwareFingerprint = "JustATestFingerprint1050"; generationOptions[5].LicenseSetId = 5; string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); placeholders = largeKeyGenerator.CreateLicensePlaceholders(license, generationOptions[0]); placeholdersInTemplate = KeyGenerator.FindAllPlaceholdersInTemplate(KeyGenerator.licenseKeyTemplate, placeholders); key = largeKeyGenerator.GenerateLicenseKey("TEST", license, generationOptions[0]); }