public void Before_each_test() { //ServicesRepository servicesRepository = new ServicesRepository(new ScutexEntities()); //CommonRepository commonRepository = new CommonRepository(new ScutexServiceEntities()); AsymmetricEncryptionProvider asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); SymmetricEncryptionProvider symmetricEncryptionProvider = new SymmetricEncryptionProvider(); ObjectSerializationProvider objectSerializationProvider = new ObjectSerializationProvider(); NumberDataGenerator numberDataGenerator = new NumberDataGenerator(); PackingService packingService = new PackingService(numberDataGenerator); MasterService masterService = new MasterService(commonRepository); CommonService commonService = new CommonService(); KeyPairService keyPairService = new KeyPairService(commonService, commonRepository); ServiceStatusProvider serviceStatusProvider = new ServiceStatusProvider(symmetricEncryptionProvider, objectSerializationProvider, asymmetricEncryptionProvider); servicesService = new ServicesService(servicesRepository, serviceStatusProvider, packingService, null, null, null, null, null, null); controlService = new ControlService(symmetricEncryptionProvider, keyPairService, packingService, masterService, objectSerializationProvider, asymmetricEncryptionProvider); service = new Scutex.Model.Service(); service.OutboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); service.InboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); service.ManagementInboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); service.ManagementOutboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); }
public void SetupService(int clientPort, int mgmtPort) { SingleUserSetup(); Service = new Service(); Service.OutboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); Service.InboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); Service.ManagementInboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); Service.ManagementOutboundKeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); Service.Token = Guid.NewGuid().ToString(); StringDataGenerator stringDataGenerator = new StringDataGenerator(); Service.ClientRequestToken = stringDataGenerator.GenerateRandomString(10, 25, true, true); Service.ManagementRequestToken = stringDataGenerator.GenerateRandomString(10, 25, true, true); Service.ClientUrl = string.Format("http://localhost:{0}/", clientPort); Service.ManagementUrl = string.Format("http://localhost:{0}/", mgmtPort); Service.Name = "UnitTest Web Services"; Service.UniquePad = Guid.NewGuid(); Service.Initialized = false; Service.CreatedDate = DateTime.Now; Service.LockToIp = false; wcfPackagingService.WriteClientKeys(Helper.AssemblyDirectory + "\\WebServices\\Client", Service); wcfPackagingService.WriteManagementKeys(Helper.AssemblyDirectory + "\\WebServices\\Mgmt", Service); try { _servicesService = new ServicesService(null, serviceStatusProvider, packingService, licenseActiviationProvider, service, null, null, clientLicenseService, productsProvider); Service.Initialized = _servicesService.InitializeService(Service); _servicesService.AddProductToService(License, License.LicenseSets.ToList(), Service); } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; } License.Service = Service; }
public void SplitDataSouldEqualOriginal() { AsymmetricEncryptionProvider provider = new AsymmetricEncryptionProvider(); KeyPair kp = provider.GenerateKeyPair(BitStrengths.High); string inKey1 = kp.PublicKey.Substring(0, (kp.PublicKey.Length / 2)); string inKey2 = kp.PublicKey.Substring(inKey1.Length, (kp.PublicKey.Length - inKey1.Length)); string outKey1 = kp.PrivateKey.Substring(0, (kp.PrivateKey.Length / 2)); string outKey2 = kp.PrivateKey.Substring(inKey1.Length, (kp.PrivateKey.Length - outKey1.Length)); Assert.AreEqual(kp.PublicKey.Length, inKey1.Length + inKey2.Length); Assert.AreEqual(kp.PrivateKey.Length, outKey1.Length + outKey2.Length); }
public void BrokenTrialSetup() { License.Name = "UnitTest License"; Product p = new Product(); p.Name = "UnitTest Product"; p.Description = "Just a product for unit testing"; License.LicenseId = 1; License.Product = p; License.KeyGeneratorType = KeyGeneratorTypes.StaticSmall; LicenseTrialSettings ts = new LicenseTrialSettings(); ts.ExpirationOptions = TrialExpirationOptions.Days; ts.ExpirationData = "30"; License.TrialSettings = ts; LicenseSet ls = new LicenseSet(); ls.LicenseId = 1; ls.LicenseSetId = 1; ls.Name = "Unit Test License Set"; ls.MaxUsers = 5; ls.SupportedLicenseTypes = LicenseKeyTypeFlag.Enterprise; License.LicenseSets = new NotifyList <LicenseSet>(); License.LicenseSets.Add(ls); License lic = License; AsymmetricEncryptionProvider asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); lic.KeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); ClientLicense lic2 = new ClientLicense(License); lic2.RunCount = 10; lic2.LastRun = DateTime.Now.AddMonths(-12); lic2.FirstRun = DateTime.Now.AddMonths(-24); CreateFile(lic2); }
public LicenseHelper() { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); encodingService = new EncodingService(); objectSerializationProvider = new ObjectSerializationProvider(); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider); clientLicenseService = new ClientLicenseService(clientLicenseRepository); serviceStatusProvider = new ServiceStatusProvider(symmetricEncryptionProvider, objectSerializationProvider, asymmetricEncryptionProvider); numberDataGenerator = new NumberDataGenerator(); packingService = new PackingService(numberDataGenerator); hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), new HashingProvider()); keygen = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); keyGeneratorLarge = new Scutex.Generators.StaticKeyGeneratorLarge.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService); licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider); service = new LicenseKeyService(keygen, keyGeneratorLarge, packingService, clientLicenseService); productsProvider = new ProductsProvider(symmetricEncryptionProvider, objectSerializationProvider, asymmetricEncryptionProvider); zipCompressionProvider = new ZipCompressionProvider(); wcfPackagingService = new WcfPackagingService(zipCompressionProvider); //licenseSetsRepository = new LicenseSetsRepository(); //licenseSetService = new LicenseSetService(); //licenseService = new LicenseService(); License = new License(); License.Name = "UnitTest License"; License.UniqueId = Guid.NewGuid(); License.KeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High); //string path = System.Reflection.Assembly.GetAssembly(typeof(LicenseHelper)).Location; string path = Helper.AssemblyDirectory; DllHash = encodingService.Encode(hashingProvider.HashFile(path + "\\WaveTech.Scutex.Licensing.dll")); PublicKey = encodingService.Encode(License.KeyPair.PublicKey); }