/// <summary> /// Loads data from textboxes and store them to data collection /// </summary> private void LoadData() { data.Clear(); var authenticatedUserIdentityOption = MacroIdentityOption.FromUserInfo(MembershipContext.AuthenticatedUser); foreach (String key in Request.Form.AllKeys) { if ((key != null) && key.StartsWithCSafe(UniqueID + "$tk")) { String value = Request.Form[key.Replace(UniqueID + "$tk", UniqueID + "$tv")]; // Sign the macro value = MacroSecurityProcessor.AddSecurityParameters(value, authenticatedUserIdentityOption, null); String k = Request.Form[key]; if (!IsValidKey(k)) { invalidKey = k; k = INVALIDTOKEN; } data.SetValue(k, value); } } // Add data from new field String newValue = Request.Form[UniqueID + "$utv_newvalue"]; String newKey = Request.Form[UniqueID + "$utk_newkey"]; if (!String.IsNullOrEmpty(newValue) || !String.IsNullOrEmpty(newKey)) { if (!IsValidKey(newKey)) { isNewValid = false; return; } // Sign the macro newValue = MacroSecurityProcessor.AddSecurityParameters(newValue, authenticatedUserIdentityOption, null); data.SetValue(newKey, newValue); } }
private void ApplyLicense(string licenseKey) { LicenseExists = false; XmlData.Clear(); RaisePropertyChanged(nameof(XmlData)); LicenseInfo.Key = licenseKey; if (string.IsNullOrWhiteSpace(licenseKey)) { FailureOccurred = false; ShowFailure = false; return; } XmlData.Clear(); var xmlList = _licenseService.LoadXmlFromLicense(LicenseInfo.Key); if (xmlList == null) { FailureOccurred = false; ShowFailure = false; return; } xmlList.ForEach(x => { if (string.Equals(x.Name, "Expiration")) { x.Name = "Maintenance End Date"; } XmlData.Add(x); }); var validationContext = _licenseValidationService.ValidateLicense(licenseKey); if (validationContext.HasErrors) { var xmlFirstError = _licenseValidationService.ValidateXml(licenseKey).GetBusinessRuleErrors().FirstOrDefault(); if (xmlFirstError == null) { var normalFirstError = _licenseValidationService.ValidateLicense(LicenseInfo.Key).GetBusinessRuleErrors().FirstOrDefault(); if (normalFirstError != null) { ShowFailure = true; FailureMessage = normalFirstError.Message; } } else { ShowFailure = true; FailureMessage = xmlFirstError.Message; } } else { FailureOccurred = false; ShowFailure = false; } LicenseExists = true; RaisePropertyChanged(nameof(XmlData)); }