Beispiel #1
0
        public string AddLicenseKeysForProduct(string token, string data)
        {
            AddLicenseKeysForProductResult result = new AddLicenseKeysForProductResult();

            try
            {
                if (!_controlService.ValidateManagementToken(token))
                {
                    result.WasOperationSuccessful = false;
                    return(_controlService.EncryptSymmetricResponse(_serializationProvider.Serialize(result)));
                }

                result.WasRequestValid = true;

                AddLicenseKeysForProductData productData = _controlService.DeserializeAndDencryptMgmtInboundData <AddLicenseKeysForProductData>(data);
                _keyManagementService.AddLicenseKeysForLicenseSet(productData.LicenseSetId, productData.Keys);

                result.WasOperationSuccessful = true;
            }
            catch (Exception ex)
            {
                result.WasException     = true;
                result.ExceptionMessage = ex.Message;
            }

            return(_controlService.SerializeAndEncryptMgmtOutboundData(result));
        }
Beispiel #2
0
        public AddLicenseKeysForProductResult AddLicenseKeysForLicenseSet(string url, string token,
                                                                          EncryptionInfo encryptionInfo, KeyPair serviceKeys, AddLicenseKeysForProductData data)
        {
            ProductsServiceClient client = ProductClientCreator(url);

            string encryptedToken    = _symmetricEncryptionProvider.Encrypt(token, encryptionInfo);
            string serializedPayload = _objectSerializationProvider.Serialize(data);
            string encryptedData     = _asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, serviceKeys);


            string encryptedResult = client.AddLicenseKeysForProduct(encryptedToken, encryptedData);
            string decryptedResult = _asymmetricEncryptionProvider.DecryptPublic(encryptedResult, serviceKeys);

            AddLicenseKeysForProductResult result = _objectSerializationProvider.Deserialize <AddLicenseKeysForProductResult>(decryptedResult);

            return(result);
        }
Beispiel #3
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);
        }
Beispiel #4
0
		public string AddLicenseKeysForProduct(string token, string data)
		{
			AddLicenseKeysForProductResult result = new AddLicenseKeysForProductResult();

			try
			{
				if (!_controlService.ValidateManagementToken(token))
				{
					result.WasOperationSuccessful = false;
					return _controlService.EncryptSymmetricResponse(_serializationProvider.Serialize(result));
				}

				result.WasRequestValid = true;

				AddLicenseKeysForProductData productData = _controlService.DeserializeAndDencryptMgmtInboundData<AddLicenseKeysForProductData>(data);
				_keyManagementService.AddLicenseKeysForLicenseSet(productData.LicenseSetId, productData.Keys);

				result.WasOperationSuccessful = true;
			}
			catch (Exception ex)
			{
				result.WasException = true;
				result.ExceptionMessage = ex.Message;
			}

			return _controlService.SerializeAndEncryptMgmtOutboundData(result);
		}