/// <summary> /// It verifies whether your app is genuinely activated or not. The verification is /// done locally by verifying the cryptographic digital signature fetched at the time of activation. /// /// This is just an auxiliary function which you may use in some specific cases, when you /// want to skip the server sync. /// /// NOTE: You may want to set grace period to 0 to ignore grace period. /// </summary> /// <returns>LA_OK, LA_EXPIRED, LA_SUSPENDED, LA_GRACE_PERIOD_OVER, LA_FAIL</returns> private int IsLicenseValid() { if (String.IsNullOrEmpty(this._productId)) { return(LexStatusCodes.LA_E_PRODUCT_ID); } if (!LexValidator.ValidateSystemTime(this._productId)) { return(LexStatusCodes.LA_E_TIME_MODIFIED); } _licenseKey = LexDataStore.GetValue(this._productId, LexConstants.KEY_LICENSE_KEY); if (!LexValidator.ValidateLicenseKey(_licenseKey)) { return(LexStatusCodes.LA_E_LICENSE_KEY); } string jwt = LexDataStore.GetValue(_productId, LexConstants.KEY_ACTIVATION_JWT); if (String.IsNullOrEmpty(jwt)) { return(LexStatusCodes.LA_FAIL); } if (_activationPayload != null && _activationPayload.IsValid) { return(LexValidator.ValidateActivationStatus(_productId, _activationPayload)); } _activationPayload = new ActivationPayload(); return(LexValidator.ValidateActivation(jwt, _rsaPublicKey, _licenseKey, _productId, _activationPayload)); }
/// <summary> /// Sets the license key required to activate the license. /// </summary> /// <param name="licenseKey">a valid license key</param> public void SetLicenseKey(string licenseKey) { if (String.IsNullOrEmpty(this._productId)) { throw new LexActivatorException(LexStatusCodes.LA_E_PRODUCT_ID); } if (String.IsNullOrEmpty(this._rsaPublicKey)) { throw new LexActivatorException(LexStatusCodes.LA_E_RSA_PUBLIC_KEY); } if (!LexValidator.ValidateLicenseKey(licenseKey)) { throw new LexActivatorException(LexStatusCodes.LA_E_LICENSE_KEY); } this._licenseKey = licenseKey; LexDataStore.SaveValue(this._productId, LexConstants.KEY_LICENSE_KEY, licenseKey); }