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);
        }
Esempio n. 2
0
        public void HardwareUserSetup()
        {
            License.Name = "UnitTest Hardware License";

            Product p = new Product();

            p.Name        = "UnitTest Hardware Product";
            p.Description = "Just a hardware product for unit testing";

            License.LicenseId        = 1;
            License.Product          = p;
            License.KeyGeneratorType = KeyGeneratorTypes.StaticLarge;

            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 Hardware License Set";
            ls.MaxUsers              = 5;
            ls.SupportedLicenseTypes = LicenseKeyTypeFlag.HardwareLock;

            License.LicenseSets = new NotifyList <LicenseSet>();
            License.LicenseSets.Add(ls);

            CreateFile(new ClientLicense(License));
        }
		public LicenseSetFeaturesWindow(Window parent, Product product, LicenseSet licenseSet)
			: this(parent)
		{
			_licenseSet = licenseSet;
			_product = product;
			gridProductFeatures.ItemsSource = new ObservableCollection<Feature>(ObjectLocator.GetInstance<IFeaturesService>().GetFeaturesForProduct(_product.ProductId));

			lblTitle.Text = _product.Name + " - " + _licenseSet.Name;
		}
Esempio n. 4
0
		public void SaveLicenseKeysForLicenseSet(LicenseSet licenseSet, List<string> keys)
		{
			foreach (string k in keys)
			{
				LicenseKey lk = new LicenseKey();
				lk.CreatedOn = DateTime.Now;
				lk.Key = k;
				lk.LicenseSetId = licenseSet.LicenseSetId;
				lk.HashedLicenseKey = _hashingProvider.ComputeHash(k, Properties.Resources.KeyHashingAlgo);

				_licenseKeyRepoistory.InsertLicenseKey(lk);
			}
		}
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        public void BrokenTrialSetup()
        {
            License.Name = "UnitTest License";

            Product p = new Product();

            p.Name        = "UnitTest Product";
            p.Description = "Just a product for unit testing";

            License.LicenseId        = 1;
            License.Product          = p;
            License.KeyGeneratorType = KeyGeneratorTypes.StaticSmall;

            LicenseTrialSettings ts = new LicenseTrialSettings();

            ts.ExpirationOptions = TrialExpirationOptions.Days;
            ts.ExpirationData    = "30";

            License.TrialSettings = ts;

            LicenseSet ls = new LicenseSet();

            ls.LicenseId             = 1;
            ls.LicenseSetId          = 1;
            ls.Name                  = "Unit Test License Set";
            ls.MaxUsers              = 5;
            ls.SupportedLicenseTypes = LicenseKeyTypeFlag.Enterprise;

            License.LicenseSets = new NotifyList <LicenseSet>();
            License.LicenseSets.Add(ls);

            License lic = License;
            AsymmetricEncryptionProvider asymmetricEncryptionProvider = new AsymmetricEncryptionProvider();

            lic.KeyPair = asymmetricEncryptionProvider.GenerateKeyPair(BitStrengths.High);

            ClientLicense lic2 = new ClientLicense(License);

            lic2.RunCount = 10;
            lic2.LastRun  = DateTime.Now.AddMonths(-12);
            lic2.FirstRun = DateTime.Now.AddMonths(-24);

            CreateFile(lic2);
        }
Esempio n. 7
0
		private void btnAddLicenseSet_Click(object sender, RoutedEventArgs e)
		{
			if (IsLicenseSetFormValid())
			{
				var licSet = from ls in License.LicenseSets
										 where ls.Name == txtLicenseSetName.Text.Trim()
										 select ls;

				if (licSet.Count() > 0)
				{
					MessageBox.Show(string.Format("LicenseSet name [{0}] is already in use in this project.", txtLicenseSetName.Text.Trim()));
					return;
				}

				if (((KeyGeneratorTypes)cboLicenseKeyType.SelectedItem) == KeyGeneratorTypes.StaticSmall && License.LicenseSets.Count >= 1)
				{
					MessageBox.Show("The Small Static Key Generator only supports a maximum of 1 license set.");
					return;
				}

				LicenseSet l = new LicenseSet();
				l.Name = txtLicenseSetName.Text.Trim();

				LicenseKeyTypeFlag flag = new LicenseKeyTypeFlag();

				if (chkSingleUser.IsChecked.HasValue && chkSingleUser.IsChecked.Value)
					flag = LicenseKeyTypeFlag.SingleUser;

				if (chkMultiUser.IsChecked.HasValue && chkMultiUser.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.MultiUser;

				if (chkHardwareLock.IsChecked.HasValue && chkHardwareLock.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.HardwareLock;

				if (chkUnlimited.IsChecked.HasValue && chkUnlimited.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.Unlimited;

				if (chkEnterprise.IsChecked.HasValue && chkEnterprise.IsChecked.Value)
					flag = flag | LicenseKeyTypeFlag.Enterprise;

				l.SupportedLicenseTypes = flag;

				if (String.IsNullOrEmpty(txtMaxUsers.Text) == false)
					l.MaxUsers = int.Parse(txtMaxUsers.Text);

				if (chkIsLicenseSetUpgradeOnly.IsChecked.HasValue)
					l.IsUpgradeOnly = chkIsLicenseSetUpgradeOnly.IsChecked.Value;
				else
					l.IsUpgradeOnly = false;

				License.LicenseSets.Add(l);
				License.RaisePropertyChanged("LicenseSets");

				ResetNewLicenseSetForm();
				SyncData();

			}
			else
			{
				MessageBox.Show("Please fix the errors in the New License Set form and try again.");
			}
		}
Esempio n. 8
0
        public void SingleUserSetup()
        {
            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.SingleUser;

            License.LicenseSets = new NotifyList<LicenseSet>();
            License.LicenseSets.Add(ls);

            CreateFile(new ClientLicense(License));
        }
Esempio n. 9
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);
        }
Esempio n. 10
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;
        }
Esempio n. 11
0
        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>();
        }