Example #1
0
 public ProductLicense LoadLicense(string productName)
 {
     try
     {
         ProductLicenseInfo licenseInfo    = _licenseStore.LoadLicense(productName);
         ProductLicense     productLicense = new ProductLicense(_cryptoService, _identifierService, licenseInfo, _userInfoProvider);
         return(productLicense);
     }
     catch (LicenseNotFoundException ex)
     {
         return(new ProductLicense(LicenseStatus.NotFound, ex.Message));
     }
     catch (Exception ex)
     {
         return(new ProductLicense(LicenseStatus.Invalid, ex.Message));
     }
 }
Example #2
0
 public ProductLicense ActivateProduct(ProductLicenseInfo licenseInfo)
 {
     try
     {
         if (licenseInfo.Signature != null)
         {
             ProductLicense productLicense = new ProductLicense(_cryptoService, _identifierService, licenseInfo, _userInfoProvider);
             return(productLicense);
         }
         else
         {
             return(new ProductLicense(LicenseStatus.Invalid, licenseInfo.ActivationInfo));
         }
     }
     catch (Exception ex)
     {
         return(new ProductLicense(LicenseStatus.InternalError, ex.Message));
     }
 }
Example #3
0
        public void SaveLicense(string productName, ProductLicense license)
        {
            if (String.IsNullOrEmpty(productName))
            {
                throw new ArgumentNullException("ProductName is null or empty.");
            }

            if (license == null)
            {
                throw new ArgumentNullException("ProductLicense is null.");
            }

            if (license.LicenseInfo == null)
            {
                throw new InvalidOperationException("ProductLicense is not valid and can't be saved.");
            }

            _licenseStore.SaveLicense(productName, license.LicenseInfo);
        }