예제 #1
0
		public List<LicenseActivation> GetAllServiceLicenseActivations(Service service)
		{
			string mgmtToken = _packingService.PackToken(service.GetManagementToken());

			GetAllLicenseActivationsResult result = _reportingProvider.GetAllServiceLicenseActivations(service.ManagementUrl, mgmtToken,
																														 GetManagementStandardEncryptionInfo(service),
																														 service.GetManagementServiceKeyPair());

			if (IsResultValid(result))
				return result.LicenseActivations;

			return new List<LicenseActivation>();
		}
예제 #2
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;
        }
예제 #3
0
        public bool AddProductToService(License license, List<LicenseSet> licenseSets, Service service)
        {
            ServiceProduct sp = new ServiceProduct();
            sp.LicenseId = license.LicenseId;
            sp.LicenseName = license.Name;
            sp.LicenseSets = new List<ServiceLicenseSet>();

            foreach (var ls in licenseSets)
            {
                ServiceLicenseSet set = new ServiceLicenseSet();
                set.LicenseId = license.LicenseId;
                set.LicenseSetId = ls.LicenseSetId;
                set.LicenseSetName = ls.Name;
                set.LicenseType = ls.SupportedLicenseTypes;
                set.MaxUsers = ls.MaxUsers;

                sp.LicenseSets.Add(set);
            }

            string mgmtToken = _packingService.PackToken(service.GetManagementToken());

            AddProductResult result = _productsProvider.AddProduct(service.ManagementUrl, mgmtToken,
                                                                                                                         GetManagementStandardEncryptionInfo(service),
                                                                                                                         service.GetManagementServiceKeyPair(), sp);

            if (IsResultValid(result))
                return true;

            return false;
        }
예제 #4
0
        public bool TestService(Service service)
        {
            string clientToken = _packingService.PackToken(service.GetClientToken());
            string mgmtToken = _packingService.PackToken(service.GetManagementToken());

            LicenseActivationPayload payload = new LicenseActivationPayload();
            payload.ServiceLicense = new ServiceLicense(CreateTestClientLicense(service));

            LicenseGenerationOptions options = new LicenseGenerationOptions();
            options.LicenseKeyType = LicenseKeyTypes.MultiUser;

            payload.LicenseKey = _licenseKeyService.GenerateLicenseKey(null, payload.ServiceLicense, options);

            SetupTestProductResult result = _serviceStatusProvider.SetupTestProduct(service.ManagementUrl, mgmtToken, payload.LicenseKey, GetManagementStandardEncryptionInfo(service));

            if (result.WasRequestValid == false)
                return false;

            if (result.WasOperationSuccessful == false)
                return false;

            ActivationResult activationResult1 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                payload, CreateTestClientLicense(service));

            ActivationResult activationResult2 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                payload, CreateTestClientLicense(service));

            ActivationResult activationResult3 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                payload, CreateTestClientLicense(service));

            if (activationResult1.WasRequestValid == false || activationResult1.ActivationSuccessful == false)
                return false;

            if (activationResult2.WasRequestValid == false || activationResult2.ActivationSuccessful == false)
                return false;

            if (activationResult3.WasRequestValid == false || activationResult3.ActivationSuccessful == true)
                return false;

            SetupTestProductResult cleanUpResult = _serviceStatusProvider.CleanUpTestProductData(service.ManagementUrl, mgmtToken,
                                                                                                                                                                                     GetManagementStandardEncryptionInfo
                                                                                                                                                                                        (service));

            if (cleanUpResult.WasOperationSuccessful == false)
                return false;

            return true;
        }
예제 #5
0
        public bool InitializeService(Service service)
        {
            string token = _packingService.PackToken(service.GetManagementToken());
            StatusRequestResult statusResult = _serviceStatusProvider.GetServiceStatus(service.ManagementUrl, token, GetManagementStandardEncryptionInfo(service));

            if (statusResult.IsInitialized == true)
                return false;

            if (statusResult.IsActive == true)
                return false;

            if (statusResult.IsRequestValid == false)
                return false;

            MasterServiceData masterData = new MasterServiceData();
            masterData.ServiceId = service.UniquePad;
            masterData.Token = service.Token;
            masterData.Initialized = true;
            masterData.ClientInboundKey = service.GetClientInboundKeyPart1();
            masterData.ClientOutboundKey = service.GetClientOutboundKeyPart1();
            masterData.ManagementInboundKey = service.GetManagementInboundKeyPart1();
            masterData.ManagementOutboundKey = service.GetManagementOutboundKeyPart1();

            InitializationResult result = _serviceStatusProvider.InitializeService(service.ManagementUrl, token, masterData,
                                                                                             GetManagementStandardEncryptionInfo(service));

            if (!result.WasInitializionSucessful)
                return false;

            return true;
        }
예제 #6
0
        public Dictionary<License, List<LicenseSet>> GetServiceLicenses(Service service)
        {
            Dictionary<License, List<LicenseSet>> data = new Dictionary<License, List<LicenseSet>>();
            string mgmtToken = _packingService.PackToken(service.GetManagementToken());

            QueryActiveServiceProductsResult result = _serviceStatusProvider.GetActiveServiceProducts(service.ManagementUrl, mgmtToken,
                                                                                                        GetManagementStandardEncryptionInfo(service), service.GetManagementServiceKeyPair());

            if (IsResultValid(result))
            {
                foreach (var v in result.ProductsAndLicenseSets)
                {
                    License l = _licenseService.GetLicenseById(v.Id);

                    List<LicenseSet> sets = new List<LicenseSet>();

                    foreach (int i in v.SetIds)
                    {
                        sets.Add(_licenseSetService.GetLiceseSetById(i));
                    }

                    data.Add(l, sets);
                }
            }

            return data;
        }
예제 #7
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>();
        }