public WebProductLicense LoadWebLicense(string productName) { try { ProductLicenseInfo licenseInfo = _licenseStore.LoadLicense(productName); UsersPool usersPool = _licenseStore.LoadUsersPoolLicense(ActivationConstants.WebUsersPoolName); WebProductLicense productLicense = new WebProductLicense(_cryptoService, _identifierService, licenseInfo, _userInfoProvider, usersPool); return(productLicense); } catch (LicenseNotFoundException ex) { return(new WebProductLicense(WebLicenseStatus.NotFound, "Common_License_StatusReason_Exception", ex.Message)); } catch (Exception ex) { return(new WebProductLicense(WebLicenseStatus.Invalid, "Common_License_StatusReason_Exception", ex.Message)); } }
public WebProductLicense ActivateWebProduct(ProductLicenseInfo licenseInfo) { try { if (licenseInfo.Signature != null) { UsersPool usersPool = _licenseStore.LoadUsersPoolLicense(ActivationConstants.WebUsersPoolName); WebProductLicense productLicense = new WebProductLicense(_cryptoService, _identifierService, licenseInfo, _userInfoProvider, usersPool); return(productLicense); } else { return(new WebProductLicense(WebLicenseStatus.Invalid, "Common_License_StatusReason_Exception", licenseInfo.ActivationInfo)); } } catch (Exception ex) { return(new WebProductLicense(WebLicenseStatus.InternalError, "Common_License_StatusReason_Exception", ex.Message)); } }
public void SaveWebLicense(string productName, WebProductLicense license) { if (string.IsNullOrEmpty(productName)) { throw new ArgumentNullException("ProductName is null or empty."); } if (license != null && license.LicenseInfo == null) { throw new InvalidOperationException("ProductLicense is not valid and can't be saved."); } if (license == null) { _licenseStore.SaveUserPoolLicense(ActivationConstants.WebUsersPoolName, null); } else if (license.UsersPool != null) { _licenseStore.SaveUserPoolLicense(ActivationConstants.WebUsersPoolName, license.UsersPool); } _licenseStore.SaveLicense(productName, license?.LicenseInfo); }