Exemplo n.º 1
0
        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);
            licenseKeyService = new LicenseKeyService(staticKeyGenerator, 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);
			}
Exemplo n.º 3
0
        public ClientLicense ActivateLicenseKey(string licenseKey, Guid? token, bool isOffline, ClientLicense scutexLicense)
        {
            /* This method used to live in the LicenseKeyService class, where it should be
             *  but because of a circular reference in the WebServicesProvider and the ServicesLibrary
             *  project requiring the LicenseKeyService to valid keys it was causing and error and had
             *  to be moved here.
             */

            if (_licenseKeyService.ValidateLicenseKey(licenseKey, scutexLicense, true))
            {
                Token t = new Token();
                t.Data = scutexLicense.ServiceToken;
                t.Timestamp = DateTime.Now;

                string packedToken = _packingService.PackToken(t);

                LicenseActivationPayload payload = new LicenseActivationPayload();
                payload.LicenseKey = licenseKey;
                payload.ServiceLicense = new ServiceLicense(scutexLicense);
                payload.Token = token;

                if (!isOffline)
                {
                    ActivationResult result = _licenseActiviationProvider.ActivateLicense(scutexLicense.ServiceAddress, packedToken,
                                                                                                                                                                GetClientStandardEncryptionInfo(scutexLicense),
                                                                                                                                                                payload, scutexLicense);

                    if (result != null && result.WasRequestValid && result.ActivationSuccessful)
                    {
                        scutexLicense.IsLicensed = true;
                        scutexLicense.IsActivated = true;
                        scutexLicense.ActivatingServiceId = result.ServiceId;
                        scutexLicense.ActivationToken = result.ActivationToken;
                        scutexLicense.ActivatedOn = DateTime.Now;
                        scutexLicense.ActivationLastCheckedOn = DateTime.Now;

                        _clientLicenseService.SaveClientLicense(scutexLicense);

                        return scutexLicense;
                    }
                }
                else
                {
                    scutexLicense.IsLicensed = true;
                    scutexLicense.IsActivated = false;
                    scutexLicense.ActivatingServiceId = null;
                    scutexLicense.ActivationToken = null;
                    scutexLicense.ActivatedOn = DateTime.Now;
                    scutexLicense.ActivationLastCheckedOn = DateTime.Now;

                    _clientLicenseService.SaveClientLicense(scutexLicense);

                    return scutexLicense;
                }
            }

            return scutexLicense;
        }
Exemplo n.º 4
0
		public MoreInfoContent(ClientLicense clientLicense)
			: this()
		{
			_clientLicense = clientLicense;

			btnBuyNowUrl.Content = _clientLicense.BuyNowUrl;
			btnHomepage.Content = _clientLicense.ProductUrl;
			btnEulaUrl.Content = _clientLicense.EulaUrl;
		}
		internal EncryptionInfo GetClientStandardEncryptionInfo(ClientLicense clientLicense)
		{
			EncryptionInfo ei = new EncryptionInfo();
			ei.HashAlgorithm = "SHA1";
			ei.InitVector = Resources.ServicesIV;
			ei.Iterations = 2;
			ei.KeySize = 192;
			ei.PassPhrase = clientLicense.Ces1;
			ei.SaltValue = clientLicense.Ces2;

			return ei;
		}
Exemplo n.º 6
0
		public LicenseWindow(object licensingManager, ScutexLicense scutexLicense, ClientLicense clientLicense)
		{
			InitializeComponent();

			_clientLicense = clientLicense;
			_licensingManager = licensingManager as LicensingManager;
			_scutexLicense = scutexLicense;

			SetIcon();
			SetWindowIcon();
			SetFormData();
			SetFormDisplay();
			SetTrialDelayTimer();
		}
		public ActivationResult ActivateLicense(string url, string token, EncryptionInfo encryptionInfo,
			LicenseActivationPayload payload, ClientLicense clientLicense)
		{
			ActivationServiceClient client = ActivationServiceClientCreator(url);

			string encryptedToken = _symmetricEncryptionProvider.Encrypt(token, encryptionInfo);
			string serializedPayload = _objectSerializationProvider.Serialize(payload);
			string encryptedData = _asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, clientLicense.ServicesKeys);


			string serviceResult = client.ActivateLicense(encryptedToken, encryptedData);
			string result = _asymmetricEncryptionProvider.DecryptPublic(serviceResult, clientLicense.ServicesKeys);

			ActivationResult activationResult = _objectSerializationProvider.Deserialize<ActivationResult>(result);
			return activationResult;
		}
Exemplo n.º 8
0
        public RegisterContent(ClientLicense clientLicense, ScutexLicense scutexLicense)
            : this()
        {
            _clientLicense = clientLicense;
            _scutexLicense = scutexLicense;

            switch (_clientLicense.KeyGeneratorType)
            {
                case KeyGeneratorTypes.StaticSmall:
                    txtLicenseKey.InputMask = @"www-wwwwww-wwww";
                    break;
                case KeyGeneratorTypes.StaticLarge:
                    txtLicenseKey.InputMask = @"wwwww-wwwww-wwwww-wwwww-wwwww";
                    break;
            }
        }
Exemplo n.º 9
0
		public ClientLicense SaveClientLicense(ClientLicense clientLicense, string filePath)
		{
			if (File.Exists(filePath))
				File.Delete(filePath);

			string plainTextObjectData;
			plainTextObjectData = objectSerializationProvider.Serialize(clientLicense);

			string encryptedObjectData;
			encryptedObjectData = encryptionProvider.Encrypt(plainTextObjectData, encryptionInfo);

			using (StreamWriter writer = new StreamWriter(filePath))
			{
				writer.Write(encryptedObjectData);
			}

			return GetClientLicense(filePath);
		}
Exemplo n.º 10
0
        private void btnGetDataFile_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.FileName = "sxu.dll";
            dialog.DefaultExt = ".dll";
            dialog.Filter = "DLL Files (.dll)|*.dll";

            dialog.ShowDialog();
            if (!String.IsNullOrEmpty(dialog.FileName))
            {
                ClientLicense cl = new ClientLicense(UIContext.License);

                string fileName = System.IO.Path.GetFileName(dialog.FileName);

                if (fileName != "sxu.dll")
                {
                    MessageBox.Show("This version of Scutex only supports a data file with the name of sxu.dll.");
                    return;
                }

                IClientLicenseService clientLicenseService = ObjectLocator.GetInstance<IClientLicenseService>();
                clientLicenseService.SaveClientLicense(cl, dialog.FileName);
            }
        }
Exemplo n.º 11
0
		public ClientLicense SaveClientLicense(ClientLicense clientLicense, string filePath)
		{
			return _clientLicenseRepository.SaveClientLicense(clientLicense, filePath);
		}
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        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();
        }
Exemplo n.º 14
0
 public ScutexLicense Validate(string licenseKey, ScutexLicense scutexLicense, ClientLicense clientLicense)
 {
     return scutexLicense;
 }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        public static void SmallLicenseKeyGenrationTest()
        {
            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);

            IClientLicenseRepository clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider,
                                                                                                                                                                         symmetricEncryptionProvider);
            IClientLicenseService clientLicenseService = new ClientLicenseService(clientLicenseRepository);

            IKeyGenerator smallKeyGenerator = new WaveTech.Scutex.Generators.StaticKeyGeneratorSmall.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider);
            LicenseKeyService licenseKeyService = new LicenseKeyService(smallKeyGenerator, 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;
            try
            {
                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);

                    Console.WriteLine(hash + " " + hash.Equals(hashingProvider.ComputeHash(key, "SHA256")));
                }
            }
            catch (Exception ex)
            { Console.WriteLine(ex.Message); }
            finally
            {

                Console.WriteLine();
                Console.WriteLine("=================================");

                DateTime end = DateTime.Now;
                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();
            }
        }
Exemplo n.º 17
0
        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();
            IPackingService packingService = new PackingService(numberDataGeneratorProvider);
            IClientLicenseRepository clientLicenseRepository = new ClientLicenseRepository(objectSerializationProvider,
                                                                                                                                                                         symmetricEncryptionProvider);
            IClientLicenseService clientLicenseService = new ClientLicenseService(clientLicenseRepository);

            IKeyGenerator smallKeyGenerator = new WaveTech.Scutex.Generators.StaticKeyGeneratorSmall.KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider);
            LicenseKeyService licenseKeyService = new LicenseKeyService(smallKeyGenerator, 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("'"));
            }
        }
Exemplo n.º 18
0
        public void CreateFile(ClientLicense license)
        {
            string path = Helper.AssemblyDirectory;

            if (File.Exists(path + "\\sxu.dll"))
                File.Delete(path + "\\sxu.dll");

            clientLicenseService.SaveClientLicense(license, path + "\\sxu.dll");
        }
Exemplo n.º 19
0
        public void InvalidTrialSetup()
        {
            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);

            ClientLicense lic2 = new ClientLicense(License);
            lic2.RunCount = 10;
            lic2.LastRun = DateTime.Now.AddMonths(12);
            lic2.FirstRun = DateTime.Now.AddMonths(24);

            CreateFile(lic2);
        }
Exemplo n.º 20
0
        internal EncryptionInfo GetClientStandardEncryptionInfo(ClientLicense clientLicense)
        {
            EncryptionInfo ei = new EncryptionInfo();
            ei.HashAlgorithm = "SHA1";
            ei.InitVector = Resources.ServicesIV;
            ei.Iterations = 2;
            ei.KeySize = 192;

            // Outbound Key
            string outKey1 = clientLicense.ServicesKeys.PrivateKey.Substring(0, (clientLicense.ServicesKeys.PrivateKey.Length / 2));
            string outKey2 = clientLicense.ServicesKeys.PrivateKey.Substring(outKey1.Length, (clientLicense.ServicesKeys.PrivateKey.Length - outKey1.Length));

            // Inbound Key
            string inKey1 = clientLicense.ServicesKeys.PublicKey.Substring(0, (clientLicense.ServicesKeys.PublicKey.Length / 2));
            string inKey2 = clientLicense.ServicesKeys.PublicKey.Substring(inKey1.Length, (clientLicense.ServicesKeys.PublicKey.Length - inKey1.Length));

            ei.PassPhrase = outKey2;
            ei.SaltValue = inKey2;

            return ei;
        }
Exemplo n.º 21
0
        public ScutexLicense GetScutexLicense(ClientLicense clientLicense)
        {
            ScutexLicense scutexLicense = new ScutexLicense();
            scutexLicense.TrialFaultReason = TrialFaultReasons.None;
            scutexLicense.IsTrialValid = true;
            scutexLicense.LastRun = clientLicense.LastRun;
            scutexLicense.TrialSettings = clientLicense.TrialSettings;
            scutexLicense.TrailNotificationSettings = clientLicense.TrailNotificationSettings;
            scutexLicense.IsCommunityEdition = ApplicationConstants.IsCommunityEdition;

            if (!clientLicense.FirstRun.HasValue)
            {
                Logging.LogDebug(string.Format("Is First Run!"));
                clientLicense.FirstRun = _networkTimeProvider.GetNetworkTime();
                scutexLicense.WasTrialFristRun = true;

                Logging.LogDebug(string.Format("FirstRun SetTo: {0}", clientLicense.FirstRun.Value));
            }
            else
            {
                Logging.LogDebug(string.Format("Is Existing Run!"));
                Logging.LogDebug(string.Format("FirstRun Date: {0}", clientLicense.FirstRun.Value));
                Logging.LogDebug(string.Format("NetTime Date: {0}", _networkTimeProvider.GetNetworkTime()));
            }

            if (clientLicense.LastRun.HasValue && _networkTimeProvider.GetNetworkTime() < clientLicense.LastRun)
            {
                Logging.LogDebug(string.Format("TIME FAULT"));
                Logging.LogDebug(string.Format("LastRun Date: {0}", clientLicense.LastRun.Value));
                Logging.LogDebug(string.Format("NetRun Date: {0}", _networkTimeProvider.GetNetworkTime()));
                Logging.LogDebug(string.Format("Delta: {0}", (_networkTimeProvider.GetNetworkTime() - clientLicense.LastRun.Value)));

                scutexLicense.IsTrialValid = false;
                scutexLicense.TrialFaultReason = TrialFaultReasons.TimeFault;
            }

            clientLicense.LastRun = _networkTimeProvider.GetNetworkTime();

            Logging.LogDebug(string.Format("Old Run Count: {0}", clientLicense.RunCount));
            clientLicense.RunCount++;
            Logging.LogDebug(string.Format("New Run Count: {0}", clientLicense.RunCount));

            scutexLicense.FirstRun = clientLicense.FirstRun;

            switch (clientLicense.TrialSettings.ExpirationOptions)
            {
                case TrialExpirationOptions.Days:
                    TimeSpan ts = clientLicense.FirstRun.Value -
                                                _networkTimeProvider.GetNetworkTime().AddDays(-int.Parse(clientLicense.TrialSettings.ExpirationData));

                    scutexLicense.TrialRemaining = ts.Days;

                    if (ts.Days <= 0)
                    {
                        scutexLicense.IsTrialExpired = true;
                        Logging.LogDebug(string.Format("Trial Expired"));
                    }
                    else
                    {
                        scutexLicense.IsTrialExpired = false;
                        Logging.LogDebug(string.Format("Trial Not Expired"));
                    }

                    break;
            }

            // TODO: Need to set a fair amount of data here, like licensed edition, level, etc
            if (clientLicense.IsLicensed)
            {
                scutexLicense.IsLicensed = clientLicense.IsLicensed;
                Logging.LogDebug(string.Format("Product is licensed"));
            }
            else
            {
                Logging.LogDebug(string.Format("Product is not licensed"));
            }

            Logging.LogDebug(string.Format("Saving client license"));
            _clientLicenseService.SaveClientLicense(clientLicense);

            return scutexLicense;
        }
			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]);
			}
Exemplo n.º 23
0
		public ClientLicense SaveClientLicense(ClientLicense clientLicense)
		{
			return _clientLicenseRepository.SaveClientLicense(clientLicense);
		}
Exemplo n.º 24
0
		private static void Demo(object sender, ExecutedRoutedEventArgs e)
		{
			if (UIContext.License != null)
			{
				DemoHostHelper helper = new DemoHostHelper();
				helper.CleanPreviousHost();

				string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
				path = path.Replace("file:\\", "");

				ClientLicense cl = new ClientLicense(UIContext.License);

				IClientLicenseService clientLicenseService = ObjectLocator.GetInstance<IClientLicenseService>();
				clientLicenseService.SaveClientLicense(cl, path + @"\sxu.dll");

				IHashingProvider hashingProvider = ObjectLocator.GetInstance<IHashingProvider>();
				IEncodingService encodingService = ObjectLocator.GetInstance<IEncodingService>();

				string dllCheckHash = encodingService.Encode(hashingProvider.HashFile(Directory.GetCurrentDirectory() + "\\lib\\WaveTech.Scutex.Licensing.dll"));
				string publicKey = encodingService.Encode(UIContext.License.KeyPair.PublicKey);

				try
				{
					File.Copy(Directory.GetCurrentDirectory() + "\\lib\\WaveTech.Scutex.Licensing.dll", Directory.GetCurrentDirectory() + "\\WaveTech.Scutex.Licensing.dll");
				}
				catch { }

				helper.CreateAssembly(publicKey, dllCheckHash);

				helper.ExecuteAssembly();
				helper = null;
			}
			else
			{
				MessageBox.Show("You must have an open licensing project to view the demo trial form.");
			}
		}
Exemplo n.º 25
0
        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;
        }
Exemplo n.º 26
0
		public ClientLicense SaveClientLicense(ClientLicense clientLicense)
		{
			return SaveClientLicense(clientLicense, Name);
		}