Пример #1
0
        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);
            keygen = new KeyGenerator(symmetricEncryptionProvider, asymmetricEncryptionProvider, hashingProvider);
            licenseActiviationProvider = new LicenseActiviationProvider(asymmetricEncryptionProvider, symmetricEncryptionProvider, objectSerializationProvider);
            service = new LicenseKeyService(keygen, 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);
        }
Пример #2
0
		public void SplitDataSouldEqualOriginal()
		{
			AsymmetricEncryptionProvider provider = new AsymmetricEncryptionProvider();
			KeyPair kp = provider.GenerateKeyPair(BitStrengths.High);

			string inKey1 = kp.PublicKey.Substring(0, (kp.PublicKey.Length/2));
			string inKey2 = kp.PublicKey.Substring(inKey1.Length, (kp.PublicKey.Length - inKey1.Length));

			string outKey1 = kp.PrivateKey.Substring(0, (kp.PrivateKey.Length / 2));
			string outKey2 = kp.PrivateKey.Substring(inKey1.Length, (kp.PrivateKey.Length - outKey1.Length));

			Assert.AreEqual(kp.PublicKey.Length, inKey1.Length + inKey2.Length);
			Assert.AreEqual(kp.PrivateKey.Length, outKey1.Length + outKey2.Length);
		}
Пример #3
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);
        }