public ActionResult Register(RegisterUserViewModel user) { if (ModelState.IsValid) { try { var hashedPassword = HashingProvider.GenerateHash(user.Password); user.Password = hashedPassword; this.userService.RegisterUser(user); CreateSession(user.Email); } catch (UserExistsException e) { ModelState.AddModelError("", e.Message); return(View(user)); } catch (Exception) { return(View("Error")); } return(RedirectToAction("Index", "Dashboard")); } else { return(View(user)); } }
public static void HashTokenWithSalt() { HashingProvider provider = new HashingProvider(); Console.WriteLine(provider.ComputeHashWithSalt("b$7SDt%43J*a!9", "SHA256", null)); PackingService service = new PackingService(new NumberDataGenerator()); Token t = new Token(); t.Data = "MXLBEcLe6/i1CjdyomC7T0vTlACTXpdRmnxcDXDE8yDuCal0xA=="; t.Timestamp = DateTime.Now; Console.WriteLine(service.PackToken(t)); SymmetricEncryptionProvider encryption = new SymmetricEncryptionProvider(); EncryptionInfo ei = new EncryptionInfo(); ei.HashAlgorithm = "SHA1"; ei.InitVector = "a01JQ3481Ahnqwe9"; ei.Iterations = 2; ei.KeySize = 256; ei.PassPhrase = "Da*eW6_EzU4_swuk8*hU"; ei.SaltValue = "VuW9uDrE"; Console.WriteLine(encryption.Encrypt("861641072009MXLBEcLe6/i1CjdyomC7T0vTlACTXpdRmnxcDXDE8yDuCal0xA==41410860", ei)); Console.WriteLine(); Console.WriteLine("Press enter to exit."); Console.ReadLine(); }
/// <summary> /// Returns hashing result based on <paramref name="data"/> and <paramref name="hashingProvider"/>. /// </summary> public static HashingResult Hash(string data, HashingProvider hashingProvider) { if (data == null) return HashingResult.DefaultHashResult; var hashAlgorithm = GetHashAlgorithm(hashingProvider); return new HashingResult(hashAlgorithm.ComputeHash(DefaultEncoding.GetBytes(data))); }
public static void WriteEncodedLicensingDllHash() { IHashingProvider hashingProvider = new HashingProvider(); IEncodingService encodingService = new EncodingService(); string hash = hashingProvider.HashFile(Directory.GetCurrentDirectory() + "\\WaveTech.Scutex.Licensing.dll"); Console.WriteLine(encodingService.Encode(hash)); }
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); activationLogRepository = new ActivationLogRepoistory(new ScutexServiceEntities()); activationLogService = new ActivationLogService(activationLogRepository, hashingProvider); keyService = new KeyManagementService(clientRepository, licenseKeyService, activationLogService, hashingProvider, serviceProductsRepository); 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); 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, packingService, clientLicenseService); activationService = new ActivationService(controlService, keyService, keyPairService, objectSerializationProvider, asymmetricEncryptionProvider, null, null); string serviceData; using (TextReader reader = new StreamReader(path + "\\Data\\Service.dat")) { serviceData = reader.ReadToEnd().Trim(); } service = objectSerializationProvider.Deserialize<Service>(serviceData); }
public static void BatchSmallLicenseKeyGenrationTest() { IAsymmetricEncryptionProvider asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); ISymmetricEncryptionProvider symmetricEncryptionProvider = new SymmetricEncryptionProvider(); IHashingProvider hashingProvider = new HashingProvider(); IObjectSerializationProvider objectSerializationProvider = new ObjectSerializationProvider(); ILicenseActiviationProvider licenseActiviationProvider = new LicenseActiviationProvider( asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider); INumberDataGeneratorProvider numberDataGeneratorProvider = new NumberDataGenerator(); IPackingService packingService = new PackingService(numberDataGeneratorProvider); IHardwareFingerprintService hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), hashingProvider); IClientLicenseRepository clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider); IClientLicenseService clientLicenseService = new ClientLicenseService(clientLicenseRepository); ISmallKeyGenerator smallKeyGenerator = new WaveTech.Scutex.Generators.StaticKeyGeneratorSmall.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); ILargeKeyGenerator staticKeyGeneratorLarge = new WaveTech.Scutex.Generators.StaticKeyGeneratorLarge.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService); LicenseKeyService licenseKeyService = new LicenseKeyService(smallKeyGenerator, staticKeyGeneratorLarge, packingService, clientLicenseService); ClientLicense license = new ClientLicense(); LicenseGenerationOptions 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; string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); DateTime start = DateTime.Now; List <string> licenseKeys = licenseKeyService.GenerateLicenseKeys("TEST", license, generationOptions, 100000); Dictionary <string, string> doubleCheck = new Dictionary <string, string>(); DateTime end = DateTime.Now; foreach (string s in licenseKeys) { doubleCheck.Add(s, ""); Console.WriteLine(s); } Console.WriteLine(); Console.WriteLine("================================="); Console.WriteLine(string.Format("Key Generation took {0}", end - start)); Console.WriteLine(string.Format("Generated {0} unique license keys", licenseKeys.Count)); Console.WriteLine(); Console.WriteLine("Press enter to exit."); Console.ReadLine(); }
public void LoginUser(LoginUserDto userDto) { if (userDto == null) { throw new ArgumentNullException("Invalid user provided!"); } var user = this.context.Users.Where(u => u.Email == userDto.Email.ToLower()).FirstOrDefault() ?? throw new InvalidCredentialsException(); if (!HashingProvider.VerifyPasswords(userDto.Password, user.Password)) { throw new InvalidCredentialsException(); } }
public static void SmallLicenseKeyWithLessThen15CharsTest() { IAsymmetricEncryptionProvider asymmetricEncryptionProvider; ISymmetricEncryptionProvider symmetricEncryptionProvider; IHashingProvider hashingProvider; WaveTech.Scutex.Generators.StaticKeyGeneratorSmall.KeyGenerator smallKeyGenerator; ClientLicense license; LicenseGenerationOptions generationOptions; //List<LicensePlaceholder> placeholders; //Dictionary<int, LicensePlaceholder> placeholdersInTemplate; for (int i = 0; i < 100000; i++) { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); symmetricEncryptionProvider = new SymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); smallKeyGenerator = new WaveTech.Scutex.Generators.StaticKeyGeneratorSmall.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 key = smallKeyGenerator.GenerateLicenseKey("TEST", license, generationOptions); if (key.Length < 15) { string error = key; Console.WriteLine("ERROR: " + error); } Console.WriteLine(key); } }
public static void LicenseKeyGenerationTest() { IAsymmetricEncryptionProvider asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); ISymmetricEncryptionProvider symmetricEncryptionProvider = new SymmetricEncryptionProvider(); IHashingProvider hashingProvider = new HashingProvider(); IObjectSerializationProvider objectSerializationProvider = new ObjectSerializationProvider(); ILicenseActiviationProvider licenseActiviationProvider = new LicenseActiviationProvider( asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider); INumberDataGeneratorProvider numberDataGeneratorProvider = new NumberDataGenerator(); IPackingService packingService = new PackingService(numberDataGeneratorProvider); IHardwareFingerprintService hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), hashingProvider); IClientLicenseRepository clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider); IClientLicenseService clientLicenseService = new ClientLicenseService(clientLicenseRepository); KeyGenerator staticKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); ILargeKeyGenerator staticKeyGeneratorLarge = new WaveTech.Scutex.Generators.StaticKeyGeneratorLarge.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService); LicenseKeyService licenseKeyService = new LicenseKeyService(staticKeyGenerator, staticKeyGeneratorLarge, packingService, clientLicenseService); ClientLicense license = new ClientLicense(); LicenseGenerationOptions 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; string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); Dictionary <string, string> licenseKeys = new Dictionary <string, string>(); DateTime start = DateTime.Now; for (int i = 0; i < 100000; i++) { string key = licenseKeyService.GenerateLicenseKey("TEST", license, generationOptions); licenseKeys.Add(key, key.GetHashCode().ToString()); Console.WriteLine(key); } DateTime end = DateTime.Now; Console.WriteLine(start - end); }
private static HashAlgorithm GetHashAlgorithm(HashingProvider hashingProvider) { switch (hashingProvider) { case HashingProvider.Sha1: return new SHA1Managed(); case HashingProvider.Sha256: return new SHA256Managed(); case HashingProvider.Sha384: return new SHA384Managed(); case HashingProvider.Sha512: return new SHA512Managed(); case HashingProvider.Md5: return new MD5CryptoServiceProvider(); } throw new InvalidEnumArgumentException(string.Format("Not supported hashing provider: {0}", hashingProvider)); }
public void TestLicenseKeyHashing() { IAsymmetricEncryptionProvider asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); ISymmetricEncryptionProvider symmetricEncryptionProvider = new SymmetricEncryptionProvider(); IHashingProvider hashingProvider = new HashingProvider(); IObjectSerializationProvider objectSerializationProvider = new ObjectSerializationProvider(); ILicenseActiviationProvider licenseActiviationProvider = new LicenseActiviationProvider( asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider); INumberDataGeneratorProvider numberDataGeneratorProvider = new NumberDataGenerator(); IHardwareFingerprintService hardwareFingerprintService = new HardwareFingerprintService(new WmiDataProvider(), new HashingProvider()); IPackingService packingService = new PackingService(numberDataGeneratorProvider); IClientLicenseRepository clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider, symmetricEncryptionProvider); IClientLicenseService clientLicenseService = new ClientLicenseService(clientLicenseRepository); ILargeKeyGenerator largeKeyGenerator = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider, hardwareFingerprintService); ISmallKeyGenerator smallKeyGenerator = new WaveTech.Scutex.Generators.StaticKeyGeneratorSmall.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider); LicenseKeyService licenseKeyService = new LicenseKeyService(smallKeyGenerator, largeKeyGenerator, packingService, clientLicenseService); ClientLicense license = new ClientLicense(); LicenseGenerationOptions 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; string productHash = hashingProvider.Checksum32(license.GetLicenseProductIdentifier()).ToString("X"); Dictionary <string, string> licenseKeys = new Dictionary <string, string>(); List <string> keys = licenseKeyService.GenerateLicenseKeys("TEST", license, generationOptions, 100000); foreach (string key in keys) { string hash = hashingProvider.ComputeHash(key, "SHA256"); licenseKeys.Add(hash, key); Console.WriteLine(key + "\t" + hash); Assert.IsTrue(hash.Equals(hashingProvider.ComputeHash(key, "SHA256"))); Assert.IsFalse(hash.Contains("'")); } }
public void Before_each_test() { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); objectSerializationProvider = new ObjectSerializationProvider(); numberDataGenerator = new NumberDataGenerator(); packingService = new PackingService(numberDataGenerator); servicesService = new ServicesService(null, null, packingService, null, null, null, null, null, null); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Replace("file:\\", ""); string serviceData; using (TextReader reader = new StreamReader(path + "\\Data\\Service.dat")) { serviceData = reader.ReadToEnd().Trim(); } service = objectSerializationProvider.Deserialize<Service>(serviceData); }
public void Before_each_test() { asymmetricEncryptionProvider = new AsymmetricEncryptionProvider(); hashingProvider = new HashingProvider(); objectSerializationProvider = new ObjectSerializationProvider(); numberDataGenerator = new NumberDataGenerator(); packingService = new PackingService(numberDataGenerator); servicesService = new ServicesService(null, null, packingService, null, null, null, null, null, null); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); path = path.Replace("file:\\", ""); string serviceData; using (TextReader reader = new StreamReader(path + "\\Data\\Service.dat")) { serviceData = reader.ReadToEnd().Trim(); } service = objectSerializationProvider.Deserialize <Service>(serviceData); }
public async Task <IActionResult> Restore(RestoreUserViewModel model) { var user = await Authorize(); if (user == null) { return(RedirectToAction("Login", "Auth", new { fallbackUrl = HttpContext.Request.Path })); } if (!user.Roles.Any(r => r.Name == "Администратор")) //Для этого действия нужны права администратора { return(Unauthorized()); } if (ModelState.IsValid) { var restoreUser = await UserRepository.Get(model.Id); //Получение пользователя, для которого надо восстановить пароль if (restoreUser != null) { restoreUser.PasswordHash = HashingProvider.Hash(model.Password); //Создание нового пароля await UserRepository.Update(restoreUser); //Обновление пользователя в репозитории var token = await AuthenticationProvider.GenerateTokenAsync(restoreUser.Username, model.Password); //После смены пароля выбрасываем пользователя из всех сессий await AuthenticationProvider.LogoutFromAllSessionsAsync(token); return(RedirectToAction(nameof(AdminPanel))); } else { return(NotFound()); } } else { return(View(model)); } }
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); }
/// <summary> /// Returns true if <paramref name="inputToVerify"/> value is equal to the <paramref name="hashedValue"/> represented as a byte array. /// </summary> public static bool VerifyHash(string inputToVerify, byte[] hashedValue, HashingProvider hashProvider) { return Util.AreBytesEqual(Hash(inputToVerify, hashProvider).Bytes.ToArray(), hashedValue); }
/// <summary> /// Returns true if <paramref name="inputToVerify"/> value is equal to the <paramref name="hashedValue"/> represented as a string. /// </summary> public static bool VerifyHash(string inputToVerify, string hashedValue, StringFormat hashedValueStringFormat, HashingProvider hashProvider) { return Hash(inputToVerify, hashProvider).As(hashedValueStringFormat) == hashedValue; }
public static void WriteLicensingDllHash() { IHashingProvider hashingProvider = new HashingProvider(); Console.WriteLine(hashingProvider.HashFile(Directory.GetCurrentDirectory() + "\\WaveTech.Scutex.Licensing.dll")); }
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); }
protected override void Seed(BlogContext db) { List <Post> testPosts = new List <Post>(); testPosts.Add(new Post { Id = 1, Title = "Test blog post #1", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now, IsPublished = true }); testPosts.Add(new Post { Id = 2, Title = "Test blog post #2", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMinutes(1), IsPublished = true }); testPosts.Add(new Post { Id = 3, Title = "Test blog post #3", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMinutes(2), IsPublished = false }); testPosts.Add(new Post { Id = 4, Title = "Test blog post #4", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMinutes(3), IsPublished = false }); testPosts.Add(new Post { Id = 5, Title = "Test blog post #5", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMinutes(4), IsPublished = false }); testPosts.Add(new Post { Id = 6, Title = "Test blog post #6", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMinutes(5), IsPublished = false }); testPosts.Add(new Post { Id = 7, Title = "Test blog post #7", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMinutes(6), IsPublished = false }); testPosts.Add(new Post { Id = 8, Title = "Test blog post #8", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMinutes(7), IsPublished = false }); testPosts.Add(new Post { Id = 9, Title = "Test blog post #9", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMonths(-1), IsPublished = true }); testPosts.Add(new Post { Id = 10, Title = "Test blog post #10", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMonths(-1), IsPublished = true }); testPosts.Add(new Post { Id = 11, Title = "Test blog post #11", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMonths(-1), IsPublished = true }); testPosts.Add(new Post { Id = 12, Title = "Test blog post #12", IntroText = "Intro Text", MainText = "Main Text", CreateDate = DateTime.Now.AddMonths(-1), IsPublished = true }); testPosts[0].Title = "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum"; testPosts[0].IntroText = "Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at."; testPosts[0].MainText = "Ad nam commodo numquam verterem. Vis ea illum zril, quo no adhuc everti periculis. Delenit definitiones has ne, nec eu maluisset rationibus. Cu liber fierent ius. Eu mei animal molestie splendide, te mei suas wisi elitr. At iriure quaeque alienum vix. Ius ut eligendi comprehensam, veniam debitis signiferumque ex vim. Laudem aperiri ex mei, doming mediocrem pri ex. Omnium sapientem vim an, nostro admodum percipitur eu sed. Ex partem graecis ius. Novum pertinacia cotidieque in eam, paulo nemore tincidunt vis ut. Has cu nulla nominati, admodum eligendi appellantur et vix, posse graece ad duo. Eum an oblique persius vivendum, summo salutatus ad est. Vis et saperet debitis. Cu epicuri volutpat cotidieque eos. Mei case laoreet no, phaedrum sapientem inciderint ad ius. Everti lucilius quaestio ei nam, sonet choro ne per, natum animal fuisset duo ea. Te verterem reprimique interesset sit, everti sanctus minimum mea at. Id justo postulant est, te nam essent gloriatur, duo volumus detraxit te. In labore delectus per, in per graece denique. Et mei sale omnis, aliquid copiosae laboramus ei vel. Mei ne ludus munere impedit, modus nonumes ne vim."; testPosts[1].Title = "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum"; testPosts[1].IntroText = "Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at."; testPosts[1].MainText = "Ad nam commodo numquam verterem. Vis ea illum zril, quo no adhuc everti periculis. Delenit definitiones has ne, nec eu maluisset rationibus. Cu liber fierent ius. Eu mei animal molestie splendide, te mei suas wisi elitr. At iriure quaeque alienum vix. Ius ut eligendi comprehensam, veniam debitis signiferumque ex vim. Laudem aperiri ex mei, doming mediocrem pri ex. Omnium sapientem vim an, nostro admodum percipitur eu sed. Ex partem graecis ius. Novum pertinacia cotidieque in eam, paulo nemore tincidunt vis ut. Has cu nulla nominati, admodum eligendi appellantur et vix, posse graece ad duo. Eum an oblique persius vivendum, summo salutatus ad est. Vis et saperet debitis. Cu epicuri volutpat cotidieque eos. Mei case laoreet no, phaedrum sapientem inciderint ad ius. Everti lucilius quaestio ei nam, sonet choro ne per, natum animal fuisset duo ea. Te verterem reprimique interesset sit, everti sanctus minimum mea at. Id justo postulant est, te nam essent gloriatur, duo volumus detraxit te. In labore delectus per, in per graece denique. Et mei sale omnis, aliquid copiosae laboramus ei vel. Mei ne ludus munere impedit, modus nonumes ne vim."; testPosts[2].Title = "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum"; testPosts[2].IntroText = "Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at."; testPosts[2].MainText = "Ad nam commodo numquam verterem. Vis ea illum zril, quo no adhuc everti periculis. Delenit definitiones has ne, nec eu maluisset rationibus. Cu liber fierent ius. Eu mei animal molestie splendide, te mei suas wisi elitr. At iriure quaeque alienum vix. Ius ut eligendi comprehensam, veniam debitis signiferumque ex vim. Laudem aperiri ex mei, doming mediocrem pri ex. Omnium sapientem vim an, nostro admodum percipitur eu sed. Ex partem graecis ius. Novum pertinacia cotidieque in eam, paulo nemore tincidunt vis ut. Has cu nulla nominati, admodum eligendi appellantur et vix, posse graece ad duo. Eum an oblique persius vivendum, summo salutatus ad est. Vis et saperet debitis. Cu epicuri volutpat cotidieque eos. Mei case laoreet no, phaedrum sapientem inciderint ad ius. Everti lucilius quaestio ei nam, sonet choro ne per, natum animal fuisset duo ea. Te verterem reprimique interesset sit, everti sanctus minimum mea at. Id justo postulant est, te nam essent gloriatur, duo volumus detraxit te. In labore delectus per, in per graece denique. Et mei sale omnis, aliquid copiosae laboramus ei vel. Mei ne ludus munere impedit, modus nonumes ne vim."; testPosts[8].Title = "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum"; testPosts[8].IntroText = "Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium."; testPosts[8].MainText = "Ad nam commodo numquam verterem. Vis ea illum zril, quo no adhuc everti periculis. Delenit definitiones has ne, nec eu maluisset rationibus. Cu liber fierent ius. Eu mei animal molestie splendide, te mei suas wisi elitr. At iriure quaeque alienum vix. Ius ut eligendi comprehensam, veniam debitis signiferumque ex vim. Laudem aperiri ex mei, doming mediocrem pri ex. Omnium sapientem vim an, nostro admodum percipitur eu sed. Ex partem graecis ius. Novum pertinacia cotidieque in eam, paulo nemore tincidunt vis ut. Has cu nulla nominati, admodum eligendi appellantur et vix, posse graece ad duo. Eum an oblique persius vivendum, summo salutatus ad est. Vis et saperet debitis. Cu epicuri volutpat cotidieque eos. Mei case laoreet no, phaedrum sapientem inciderint ad ius. Everti lucilius quaestio ei nam, sonet choro ne per, natum animal fuisset duo ea. Te verterem reprimique interesset sit, everti sanctus minimum mea at. Id justo postulant est, te nam essent gloriatur, duo volumus detraxit te. In labore delectus per, in per graece denique. Et mei sale omnis, aliquid copiosae laboramus ei vel. Mei ne ludus munere impedit, modus nonumes ne vim."; testPosts[9].Title = "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum"; testPosts[9].IntroText = "Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium."; testPosts[9].MainText = "Ad nam commodo numquam verterem. Vis ea illum zril, quo no adhuc everti periculis. Delenit definitiones has ne, nec eu maluisset rationibus. Cu liber fierent ius. Eu mei animal molestie splendide, te mei suas wisi elitr. At iriure quaeque alienum vix. Ius ut eligendi comprehensam, veniam debitis signiferumque ex vim. Laudem aperiri ex mei, doming mediocrem pri ex. Omnium sapientem vim an, nostro admodum percipitur eu sed. Ex partem graecis ius. Novum pertinacia cotidieque in eam, paulo nemore tincidunt vis ut. Has cu nulla nominati, admodum eligendi appellantur et vix, posse graece ad duo. Eum an oblique persius vivendum, summo salutatus ad est. Vis et saperet debitis. Cu epicuri volutpat cotidieque eos. Mei case laoreet no, phaedrum sapientem inciderint ad ius. Everti lucilius quaestio ei nam, sonet choro ne per, natum animal fuisset duo ea. Te verterem reprimique interesset sit, everti sanctus minimum mea at. Id justo postulant est, te nam essent gloriatur, duo volumus detraxit te. In labore delectus per, in per graece denique. Et mei sale omnis, aliquid copiosae laboramus ei vel. Mei ne ludus munere impedit, modus nonumes ne vim."; testPosts[10].Title = "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum"; testPosts[10].IntroText = "Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium."; testPosts[10].MainText = "Ad nam commodo numquam verterem. Vis ea illum zril, quo no adhuc everti periculis. Delenit definitiones has ne, nec eu maluisset rationibus. Cu liber fierent ius. Eu mei animal molestie splendide, te mei suas wisi elitr. At iriure quaeque alienum vix. Ius ut eligendi comprehensam, veniam debitis signiferumque ex vim. Laudem aperiri ex mei, doming mediocrem pri ex. Omnium sapientem vim an, nostro admodum percipitur eu sed. Ex partem graecis ius. Novum pertinacia cotidieque in eam, paulo nemore tincidunt vis ut. Has cu nulla nominati, admodum eligendi appellantur et vix, posse graece ad duo. Eum an oblique persius vivendum, summo salutatus ad est. Vis et saperet debitis. Cu epicuri volutpat cotidieque eos. Mei case laoreet no, phaedrum sapientem inciderint ad ius. Everti lucilius quaestio ei nam, sonet choro ne per, natum animal fuisset duo ea. Te verterem reprimique interesset sit, everti sanctus minimum mea at. Id justo postulant est, te nam essent gloriatur, duo volumus detraxit te. In labore delectus per, in per graece denique. Et mei sale omnis, aliquid copiosae laboramus ei vel. Mei ne ludus munere impedit, modus nonumes ne vim."; testPosts[11].Title = "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum"; testPosts[11].IntroText = "Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium nam ea. Eum cu tractatos patrioque dissentias, at mel consul vocent, nibh duis legendos eam at. Lorem ipsum dolor sit amet, id scaevola maluisset omittantur vis, vivendum praesent assentior his id. In vis commodo conclusionemque. Aliquip docendi antiopam his eu. In illud patrioque similique sed. At mea nostrum percipitur, quidam quaeque petentium."; testPosts[11].MainText = "Ad nam commodo numquam verterem. Vis ea illum zril, quo no adhuc everti periculis. Delenit definitiones has ne, nec eu maluisset rationibus. Cu liber fierent ius. Eu mei animal molestie splendide, te mei suas wisi elitr. At iriure quaeque alienum vix. Ius ut eligendi comprehensam, veniam debitis signiferumque ex vim. Laudem aperiri ex mei, doming mediocrem pri ex. Omnium sapientem vim an, nostro admodum percipitur eu sed. Ex partem graecis ius. Novum pertinacia cotidieque in eam, paulo nemore tincidunt vis ut. Has cu nulla nominati, admodum eligendi appellantur et vix, posse graece ad duo. Eum an oblique persius vivendum, summo salutatus ad est. Vis et saperet debitis. Cu epicuri volutpat cotidieque eos. Mei case laoreet no, phaedrum sapientem inciderint ad ius. Everti lucilius quaestio ei nam, sonet choro ne per, natum animal fuisset duo ea. Te verterem reprimique interesset sit, everti sanctus minimum mea at. Id justo postulant est, te nam essent gloriatur, duo volumus detraxit te. In labore delectus per, in per graece denique. Et mei sale omnis, aliquid copiosae laboramus ei vel. Mei ne ludus munere impedit, modus nonumes ne vim."; db.Posts.Add(testPosts[0]); db.Posts.Add(testPosts[1]); db.Posts.Add(testPosts[2]); db.Posts.Add(testPosts[3]); db.Posts.Add(testPosts[4]); db.Posts.Add(testPosts[5]); db.Posts.Add(testPosts[6]); db.Posts.Add(testPosts[7]); db.Posts.Add(testPosts[8]); db.Posts.Add(testPosts[9]); db.Posts.Add(testPosts[10]); db.Posts.Add(testPosts[11]); List <Tag> testTags = new List <Tag>(); testTags.Add(new Tag { Id = 1, Name = "C#", Posts = new List <Post>() { testPosts[1], testPosts[2] } }); testTags.Add(new Tag { Id = 2, Name = "ASP.NET MVC", Posts = new List <Post>() { testPosts[0], testPosts[1] } }); testTags.Add(new Tag { Id = 3, Name = "Web API", Posts = new List <Post>() { testPosts[9], testPosts[8] } }); testTags.Add(new Tag { Id = 4, Name = "Web Dev", Posts = new List <Post>() { testPosts[0] } }); testTags.Add(new Tag { Id = 5, Name = "Visual Studio", Posts = new List <Post>() { testPosts[11] } }); testTags.Add(new Tag { Id = 6, Name = "WinPhone", Posts = new List <Post>() { testPosts[10] } }); testTags.Add(new Tag { Id = 7, Name = "Xamarin", Posts = new List <Post>() { testPosts[8] } }); testTags.Add(new Tag { Id = 8, Name = ".NET", Posts = new List <Post>() { testPosts[11] } }); testTags.Add(new Tag { Id = 9, Name = "Unity3D", Posts = new List <Post>() { testPosts[10] } }); db.Tags.Add(testTags[0]); db.Tags.Add(testTags[1]); db.Tags.Add(testTags[2]); db.Tags.Add(testTags[3]); db.Tags.Add(testTags[4]); db.Tags.Add(testTags[5]); db.Tags.Add(testTags[6]); db.Tags.Add(testTags[7]); db.Tags.Add(testTags[8]); db.Comments.Add(new Comment { Id = 1, Text = "Test Comment #1", CreateDate = DateTime.Now, Username = "******", IsApproved = false, PostId = 1 }); db.Comments.Add(new Comment { Id = 2, Text = "Test Comment #2", CreateDate = DateTime.Now.AddMinutes(1), Username = "******", IsApproved = false, PostId = 1 }); db.Comments.Add(new Comment { Id = 3, Text = "Test Comment #3", CreateDate = DateTime.Now.AddMinutes(2), Username = "******", IsApproved = true, PostId = 1 }); db.Comments.Add(new Comment { Id = 4, Text = "Test Comment #3", CreateDate = DateTime.Now.AddMinutes(3), Username = "******", IsApproved = true, PostId = 1 }); db.Comments.Add(new Comment { Id = 5, Text = "Test Comment", CreateDate = DateTime.Now.AddMinutes(3), Username = "******", IsApproved = true, PostId = 12 }); db.Comments.Add(new Comment { Id = 6, Text = "Test Comment #2", CreateDate = DateTime.Now.AddMinutes(5), Username = "******", IsApproved = true, PostId = 12 }); HashingProvider hashing = new HashingProvider(); db.Admins.Add(new Admin { Login = "******", Username = "******", PasswordHash = hashing.HashPassword("h2qq4W1") }); Settings settings = new Settings { Id = 1, PageSize = 5, PostListPageSize = 3, AdminEmail = "*****@*****.**", VkAppId = "5198654", VkAppSecret = "J8vHQkxHhUlX2IeJDb2FZ", GoogleAppId = "988813254802-37rg5bqo1memih5h0ece3s9f4ktr49sj.apps.googleusercontent.com", GoogleAppSecret = "y1P_Rwjl3fRlVm4SzwlpTUa7", OAuthRedirectUri = "http://localhost:55854/OAuth/SignIn" }; db.Settings.Add(settings); db.SaveChanges(); base.Seed(db); }