public bool AddProductToService(License license, List<LicenseSet> licenseSets, Service service) { ServiceProduct sp = new ServiceProduct(); sp.LicenseId = license.LicenseId; sp.LicenseName = license.Name; sp.LicenseSets = new List<ServiceLicenseSet>(); foreach (var ls in licenseSets) { ServiceLicenseSet set = new ServiceLicenseSet(); set.LicenseId = license.LicenseId; set.LicenseSetId = ls.LicenseSetId; set.LicenseSetName = ls.Name; set.LicenseType = ls.SupportedLicenseTypes; set.MaxUsers = ls.MaxUsers; sp.LicenseSets.Add(set); } string mgmtToken = _packingService.PackToken(service.GetManagementToken()); AddProductResult result = _productsProvider.AddProduct(service.ManagementUrl, mgmtToken, GetManagementStandardEncryptionInfo(service), service.GetManagementServiceKeyPair(), sp); if (IsResultValid(result)) return true; return false; }
internal void WriteClientKeys(string path, Service service) { DirectoryInfo dir = new DirectoryInfo(path); List<FileInfo> configFiles = new List<FileInfo>(); configFiles.AddRange(dir.GetFiles("*-IN.config")); configFiles.AddRange(dir.GetFiles("*-OUT.config")); configFiles.AddRange(dir.GetFiles("*-TK.config")); foreach (FileInfo fi in configFiles) { File.Delete(fi.FullName); } using (StreamWriter writer = new StreamWriter(path + string.Format("\\{0}-IN.config", service.Token))) { writer.WriteLine(service.GetClientInboundKeyPart2()); } using (StreamWriter writer = new StreamWriter(path + string.Format("\\{0}-OUT.config", service.Token))) { writer.WriteLine(service.GetClientOutboundKeyPart2()); } using (StreamWriter writer = new StreamWriter(path + string.Format("\\{0}-TK.config", service.Token))) { writer.WriteLine(service.ClientRequestToken); } }
public Service SaveService(Service service) { if (service.ServiceId == 0) return _servicesRepository.InsertService(service).First(); else return _servicesRepository.UpdateService(service).First(); }
public void PackageService(string saveLocation, Service service) { if (File.Exists(saveLocation)) File.Delete(saveLocation); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Replace("file:\\", ""); path = path + @"\lib\Services\"; DirectoryInfo csDir = new DirectoryInfo(path + @"ClientService\"); DirectoryInfo mgmtDir = new DirectoryInfo(path + @"ManagementService\"); List<FileInfo> configFiles = new List<FileInfo>(); configFiles.AddRange(csDir.GetFiles("*-IN.config")); configFiles.AddRange(csDir.GetFiles("*-OUT.config")); configFiles.AddRange(csDir.GetFiles("*-TK.config")); configFiles.AddRange(mgmtDir.GetFiles("*-IN.config")); configFiles.AddRange(mgmtDir.GetFiles("*-OUT.config")); configFiles.AddRange(mgmtDir.GetFiles("*-TK.config")); foreach (FileInfo fi in configFiles) { File.Delete(fi.FullName); } // Write the Client Service KeyPair's using (StreamWriter writer = new StreamWriter(path + @"ClientService\" + string.Format("{0}-IN.config", service.Token))) { writer.WriteLine(service.GetClientInboundKeyPart2()); } using (StreamWriter writer = new StreamWriter(path + @"ClientService\" + string.Format("{0}-OUT.config", service.Token))) { writer.WriteLine(service.GetClientOutboundKeyPart2()); } using (StreamWriter writer = new StreamWriter(path + @"ClientService\" + string.Format("{0}-TK.config", service.Token))) { writer.WriteLine(service.ClientRequestToken); } // Write the Management Service KeyPair's using (StreamWriter writer = new StreamWriter(path + @"ManagementService\" + string.Format("{0}-IN.config", service.Token))) { writer.WriteLine(service.GetManagementInboundKeyPart2()); } using (StreamWriter writer = new StreamWriter(path + @"ManagementService\" + string.Format("{0}-OUT.config", service.Token))) { writer.WriteLine(service.GetManagementOutboundKeyPart2()); } using (StreamWriter writer = new StreamWriter(path + @"ManagementService\" + string.Format("{0}-TK.config", service.Token))) { writer.WriteLine(service.ManagementRequestToken); } _zipCompressionProvider.CreateZip(saveLocation, path); }
public ServiceInitializationWindow(Window parent, Service service) : this() { this.Owner = parent; _service = service; lblServiceName.Text = service.Name; lblServiceClientUrl.Text = service.ClientUrl; lblServiceMgmtUrl.Text = service.ManagementUrl; }
private EncryptionInfo GetManagementStandardEncryptionInfo(Service service) { EncryptionInfo ei = new EncryptionInfo(); ei.HashAlgorithm = "SHA1"; ei.InitVector = Resources.ServicesIV; ei.Iterations = 2; ei.KeySize = 192; ei.PassPhrase = service.GetManagementOutboundKeyPart2(); ei.SaltValue = service.GetManagementInboundKeyPart2(); return ei; }
public List<LicenseActivation> GetAllServiceLicenseActivations(Service service) { string mgmtToken = _packingService.PackToken(service.GetManagementToken()); GetAllLicenseActivationsResult result = _reportingProvider.GetAllServiceLicenseActivations(service.ManagementUrl, mgmtToken, GetManagementStandardEncryptionInfo(service), service.GetManagementServiceKeyPair()); if (IsResultValid(result)) return result.LicenseActivations; return new List<LicenseActivation>(); }
public bool AddLicenseKeysToService(LicenseSet licenseSet, Service service, List<string> keys) { string mgmtToken = _packingService.PackToken(service.GetManagementToken()); AddLicenseKeysForProductData data = new AddLicenseKeysForProductData(); data.LicenseSetId = licenseSet.LicenseSetId; data.Keys = keys; AddLicenseKeysForProductResult result = _productsProvider.AddLicenseKeysForLicenseSet(service.ManagementUrl, mgmtToken, GetManagementStandardEncryptionInfo(service), service.GetManagementServiceKeyPair(), data); if (IsResultValid(result)) return true; return false; }
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; }
internal ClientLicense CreateTestClientLicense(Service service) { ClientLicense cl = new ClientLicense(); cl.ServicesKeys = service.GetClientServiceKeyPair(); cl.Product = new Product(); cl.Product.Name = "Test Product"; cl.LicenseSets = new NotifyList<LicenseSet>(); LicenseSet ls = new LicenseSet(); ls.LicenseId = int.MaxValue; ls.LicenseSetId = int.MaxValue; ls.Name = "Test Product License Set"; ls.MaxUsers = 2; ls.SupportedLicenseTypes = LicenseKeyTypeFlag.MultiUser; cl.LicenseSets.Add(ls); return cl; }
public bool TestService(Service service) { string clientToken = _packingService.PackToken(service.GetClientToken()); string mgmtToken = _packingService.PackToken(service.GetManagementToken()); LicenseActivationPayload payload = new LicenseActivationPayload(); payload.ServiceLicense = new ServiceLicense(CreateTestClientLicense(service)); LicenseGenerationOptions options = new LicenseGenerationOptions(); options.LicenseKeyType = LicenseKeyTypes.MultiUser; payload.LicenseKey = _licenseKeyService.GenerateLicenseKey(null, payload.ServiceLicense, options); SetupTestProductResult result = _serviceStatusProvider.SetupTestProduct(service.ManagementUrl, mgmtToken, payload.LicenseKey, GetManagementStandardEncryptionInfo(service)); if (result.WasRequestValid == false) return false; if (result.WasOperationSuccessful == false) return false; ActivationResult activationResult1 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service), payload, CreateTestClientLicense(service)); ActivationResult activationResult2 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service), payload, CreateTestClientLicense(service)); ActivationResult activationResult3 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service), payload, CreateTestClientLicense(service)); if (activationResult1.WasRequestValid == false || activationResult1.ActivationSuccessful == false) return false; if (activationResult2.WasRequestValid == false || activationResult2.ActivationSuccessful == false) return false; if (activationResult3.WasRequestValid == false || activationResult3.ActivationSuccessful == true) return false; SetupTestProductResult cleanUpResult = _serviceStatusProvider.CleanUpTestProductData(service.ManagementUrl, mgmtToken, GetManagementStandardEncryptionInfo (service)); if (cleanUpResult.WasOperationSuccessful == false) return false; return true; }
public bool TestClientServiceUrl(Service service) { string result; try { result = _licenseActiviationProvider.BasicServiceTest(service.ClientUrl); } catch(Exception ex) { return false; } return result == "Ok"; }
/// <summary> /// Constructor that takes a parent for this GenerationWindow window. /// </summary> /// <param name="parent">Parent window for this dialog.</param> public UpdateServiceWindow(Window parent, Service service) : this() { this.Owner = parent; Service = service; }
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 bool TestManagementServiceDatabase(Service service) { bool result; try { result = _serviceStatusProvider.DatabaseServiceTest(service.ManagementUrl); } catch (Exception ex) { return false; } return result; }
public bool TestClientServiceDatabase(Service service) { bool result; try { result = _licenseActiviationProvider.DatabaseServiceTest(service.ClientUrl); } catch (Exception ex) { return false; } return result; }
public bool TestManagementServiceFileSystem(Service service) { bool result; try { result = _serviceStatusProvider.FileSystemServiceTest(service.ManagementUrl); } catch (Exception ex) { return false; } return result; }
public bool TestManagementServiceUrl(Service service) { string result; try { result = _serviceStatusProvider.BasicServiceTest(service.ManagementUrl); } catch (Exception ex) { return false; } return result == "Ok"; }
public List<string> GetServiceLicenseKeysForSet(LicenseSet licenseSet, Service service) { string mgmtToken = _packingService.PackToken(service.GetManagementToken()); GetLicenseKeysForProductData data = new GetLicenseKeysForProductData(); data.LicenseSetId = licenseSet.LicenseSetId; GetLicenseKeysForProductResult result = _productsProvider.GetLicenseKeysForLicenseSet(service.ManagementUrl, mgmtToken, GetManagementStandardEncryptionInfo(service), service.GetManagementServiceKeyPair(), data); if (IsResultValid(result)) return result.LicenseKeys; return new List<string>(); }
public Dictionary<License, List<LicenseSet>> GetServiceLicenses(Service service) { Dictionary<License, List<LicenseSet>> data = new Dictionary<License, List<LicenseSet>>(); string mgmtToken = _packingService.PackToken(service.GetManagementToken()); QueryActiveServiceProductsResult result = _serviceStatusProvider.GetActiveServiceProducts(service.ManagementUrl, mgmtToken, GetManagementStandardEncryptionInfo(service), service.GetManagementServiceKeyPair()); if (IsResultValid(result)) { foreach (var v in result.ProductsAndLicenseSets) { License l = _licenseService.GetLicenseById(v.Id); List<LicenseSet> sets = new List<LicenseSet>(); foreach (int i in v.SetIds) { sets.Add(_licenseSetService.GetLiceseSetById(i)); } data.Add(l, sets); } } return data; }
private void SetService() { if (_service == null) { IAsymmetricEncryptionProvider asymmetricEncryptionProvider = ObjectLocator.GetInstance<IAsymmetricEncryptionProvider>(); _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(); IStringDataGeneratorProvider stringDataGenerator = ObjectLocator.GetInstance<IStringDataGeneratorProvider>(); _service.ClientRequestToken = stringDataGenerator.GenerateRandomString(10, 25, true, true); _service.ManagementRequestToken = stringDataGenerator.GenerateRandomString(10, 25, true, true); } }
public bool InitializeService(Service service) { string token = _packingService.PackToken(service.GetManagementToken()); StatusRequestResult statusResult = _serviceStatusProvider.GetServiceStatus(service.ManagementUrl, token, GetManagementStandardEncryptionInfo(service)); if (statusResult.IsInitialized == true) return false; if (statusResult.IsActive == true) return false; if (statusResult.IsRequestValid == false) return false; MasterServiceData masterData = new MasterServiceData(); masterData.ServiceId = service.UniquePad; masterData.Token = service.Token; masterData.Initialized = true; masterData.ClientInboundKey = service.GetClientInboundKeyPart1(); masterData.ClientOutboundKey = service.GetClientOutboundKeyPart1(); masterData.ManagementInboundKey = service.GetManagementInboundKeyPart1(); masterData.ManagementOutboundKey = service.GetManagementOutboundKeyPart1(); InitializationResult result = _serviceStatusProvider.InitializeService(service.ManagementUrl, token, masterData, GetManagementStandardEncryptionInfo(service)); if (!result.WasInitializionSucessful) return false; return true; }
public void Before_each_test() { clientLicenseRepoistory = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider); clientLicenseService = new ClientLicenseService(clientLicenseRepoistory); serviceProductsRepository = new ServiceProductsRepository(new ScutexServiceEntities()); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); objectSerializationProvider = new ObjectSerializationProvider(); numberDataGenerator = new NumberDataGenerator(); packingService = new PackingService(numberDataGenerator); commonRepository = new CommonRepository(new ScutexServiceEntities()); clientRepository = new ClientRepository(new ScutexServiceEntities()); keyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); masterService = new MasterService(commonRepository); hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), new HashingProvider()); keyGeneratorLarge = new Scutex.Generators.StaticKeyGeneratorLarge.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService); var mockActivationLogRepository = new Mock <IActivationLogRepoistory>(); mockActivationLogRepository.Setup(log => log.SaveActivationLog(It.IsAny <Scutex.Model.ActivationLog>())); activationLogService = new ActivationLogService(mockActivationLogRepository.Object, hashingProvider); commonService = new CommonService(); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Replace("file:\\", ""); var mockCommonService = new Mock <ICommonService>(); mockCommonService.Setup(common => common.GetPath()).Returns(path + "\\Data\\Client\\"); string masterServiceDataText; using (TextReader reader = new StreamReader(path + "\\Data\\MasterService.dat")) { masterServiceDataText = reader.ReadToEnd().Trim(); } masterServiceData = objectSerializationProvider.Deserialize <MasterServiceData>(masterServiceDataText); var mockCommonRepository = new Mock <ICommonRepository>(); mockCommonRepository.Setup(repo => repo.GetMasterServiceData()).Returns(masterServiceData); masterService = new MasterService(mockCommonRepository.Object); keyPairService = new KeyPairService(mockCommonService.Object, mockCommonRepository.Object); controlService = new ControlService(symmetricEncryptionProvider, keyPairService, packingService, masterService, objectSerializationProvider, asymmetricEncryptionProvider); servicesRepository = new ServicesRepository(new ScutexEntities()); serviceStatusProvider = new ServiceStatusProvider(symmetricEncryptionProvider, objectSerializationProvider, asymmetricEncryptionProvider); licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider); servicesService = new ServicesService(servicesRepository, serviceStatusProvider, packingService, licenseActiviationProvider, null, null, null, null, null); licenseKeyService = new LicenseKeyService(keyGenerator, keyGeneratorLarge, packingService, clientLicenseService); keyService = new KeyManagementService(clientRepository, licenseKeyService, activationLogService, hashingProvider, serviceProductsRepository); activationService = new ActivationService(controlService, keyService, keyPairService, objectSerializationProvider, asymmetricEncryptionProvider, activationLogService, masterService, commonService, null); string serviceData; using (TextReader reader = new StreamReader(path + "\\Data\\Service.dat")) { serviceData = reader.ReadToEnd().Trim(); } service = objectSerializationProvider.Deserialize <Service>(serviceData); }
public bool Equals(Service other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other._serviceId == _serviceId && Equals(other._name, _name) && Equals(other._clientUrl, _clientUrl) && Equals(other._managementUrl, _managementUrl) && Equals(other._token, _token) && other._uniquePad.Equals(_uniquePad); }