public static void Check(out bool isValid, out bool expired, out int siteQty) { siteQty = 0; isValid = false; expired = true; XmlDocument xmlDocument = HiCache.Get("FileCache_CommercialLicenser") as XmlDocument; if (xmlDocument == null) { string text = HttpContext.Current.Request.MapPath("/config/Certificates.cer"); if (!File.Exists(text)) { return; } xmlDocument = new XmlDocument(); xmlDocument.LoadXml(File.ReadAllText(text)); HiCache.Max("FileCache_CommercialLicenser", xmlDocument, new CacheDependency(text)); } XmlNode xmlNode = xmlDocument.DocumentElement.SelectSingleNode("//Host"); XmlNode xmlNode2 = xmlDocument.DocumentElement.SelectSingleNode("//LicenseDate"); XmlNode xmlNode3 = xmlDocument.DocumentElement.SelectSingleNode("//Expires"); XmlNode xmlNode4 = xmlDocument.DocumentElement.SelectSingleNode("//SiteQty"); XmlNode xmlNode5 = xmlDocument.DocumentElement.SelectSingleNode("//Signature"); if (string.Compare(xmlNode.InnerText, HttpContext.Current.Request.Url.Host, true, CultureInfo.InvariantCulture) == 0) { string s = string.Format(CultureInfo.InvariantCulture, "Host={0}&Expires={1}&SiteQty={2}&LicenseDate={3}", new object[] { HttpContext.Current.Request.Url.Host, xmlNode3.InnerText, xmlNode4.InnerText, xmlNode2.InnerText }); using (RSACryptoServiceProvider rSACryptoServiceProvider = new RSACryptoServiceProvider()) { rSACryptoServiceProvider.FromXmlString(LicenseHelper.GetPublicKey()); RSAPKCS1SignatureDeformatter rSAPKCS1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rSACryptoServiceProvider); rSAPKCS1SignatureDeformatter.SetHashAlgorithm("SHA1"); byte[] rgbSignature = Convert.FromBase64String(xmlNode5.InnerText); SHA1Managed sHA1Managed = new SHA1Managed(); byte[] rgbHash = sHA1Managed.ComputeHash(Encoding.UTF8.GetBytes(s)); isValid = rSAPKCS1SignatureDeformatter.VerifySignature(rgbHash, rgbSignature); } expired = (DateTime.Now > DateTime.Parse(xmlNode3.InnerText)); if (isValid && !expired) { int.TryParse(xmlNode4.InnerText, out siteQty); } } }
public static bool CheckCopyright(string wid) { XmlDocument document = HiCache.Get("Hishop_SiteLicense") as XmlDocument; HttpContext current = HttpContext.Current; if (document == null) { string path = null; if (current != null) { path = current.Request.MapPath("~/config/Hishop.lic"); } else { path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Hishop.lic"); } if (!File.Exists(path)) { return(false); } document = new XmlDocument(); document.LoadXml(File.ReadAllText(path)); HiCache.Max("Hishop_SiteLicense", document, new CacheDependency(path)); } XmlNode node = document.DocumentElement.SelectSingleNode("//Host"); XmlNode node2 = document.DocumentElement.SelectSingleNode("//LicenseDate"); XmlNode node3 = document.DocumentElement.SelectSingleNode("//ExpiresDate"); XmlNode node4 = document.DocumentElement.SelectSingleNode("//Signature"); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false, wid); if (string.Compare(node.InnerText, masterSettings.SiteUrl, true, CultureInfo.InvariantCulture) != 0) { return(false); } string s = string.Format(CultureInfo.InvariantCulture, "Host={0}&LicenseDate={1}&ExpiresDate={2}&Key={3}", new object[] { masterSettings.SiteUrl, node2.InnerText, node3.InnerText, masterSettings.CheckCode }); bool flag = false; using (RSACryptoServiceProvider provider = new RSACryptoServiceProvider()) { provider.FromXmlString(LicenseHelper.GetPublicKey()); RSAPKCS1SignatureDeformatter deformatter = new RSAPKCS1SignatureDeformatter(provider); deformatter.SetHashAlgorithm("SHA1"); byte[] rgbSignature = Convert.FromBase64String(node4.InnerText); byte[] rgbHash = new SHA1Managed().ComputeHash(Encoding.UTF8.GetBytes(s)); flag = deformatter.VerifySignature(rgbHash, rgbSignature); } return(flag && (DateTime.Now < DateTime.Parse(node3.InnerText))); }
public static string GetPublicKey() { string text = HiCache.Get("FileCache-Publickey") as string; if (string.IsNullOrEmpty(text)) { HttpContext current = HttpContext.Current; string text2; if (current != null) { text2 = current.Request.MapPath("~/config/publickey.xml"); } else { text2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config\\publickey.xml"); } text = File.ReadAllText(text2); HiCache.Max("FileCache-Publickey", text, new CacheDependency(text2)); } return(text); }
public static string GetPublicKey() { string str = HiCache.Get("FileCache-Publickey") as string; if (string.IsNullOrEmpty(str)) { string path = null; HttpContext current = HttpContext.Current; if (current != null) { path = current.Request.MapPath("~/config/publickey.xml"); } else { path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"config\publickey.xml"); } str = File.ReadAllText(path); HiCache.Max("FileCache-Publickey", str, new CacheDependency(path)); } return(str); }
public static SiteSettings GetMasterSettings(bool cacheable) { if (!cacheable) { HiCache.Remove("FileCache-MasterSettings"); } XmlDocument document = HiCache.Get("FileCache-MasterSettings") as XmlDocument; if (document == null) { string masterSettingsFilename = GetMasterSettingsFilename(); if (!File.Exists(masterSettingsFilename)) { return(null); } document = new XmlDocument(); document.Load(masterSettingsFilename); if (cacheable) { HiCache.Max("FileCache-MasterSettings", document, new CacheDependency(masterSettingsFilename)); } } return(SiteSettings.FromXml(document)); }
public static void Insert(string key, object obj, CacheDependency dep) { HiCache.Insert(key, obj, dep, 8640); }
public static void Insert(string key, object obj) { HiCache.Insert(key, obj, null, 1); }
public static void Max(string key, object obj) { HiCache.Max(key, obj, null); }
public static void Insert(string key, object obj, CacheDependency dep, int seconds) { HiCache.Insert(key, obj, dep, seconds, CacheItemPriority.Normal); }
public static void Insert(string string_0, object object_0) { HiCache.Insert(string_0, object_0, null, 1); }
public static void Save(CustomerServiceSettings settings) { CustomerServiceManager.SaveMasterSettings(settings); HiCache.Remove("FileCache-CustomerServiceSettings"); }
public static void Insert(string string_0, object object_0, CacheDependency cacheDependency_0, int seconds) { HiCache.Insert(string_0, object_0, cacheDependency_0, seconds, CacheItemPriority.Normal); }
public static void Insert(string string_0, object object_0, int seconds) { HiCache.Insert(string_0, object_0, null, seconds); }
public static void Insert(string string_0, object object_0, CacheDependency cacheDependency_0) { HiCache.Insert(string_0, object_0, cacheDependency_0, 8640); }
public static void Insert(string key, object obj, int seconds) { HiCache.Insert(key, obj, null, seconds); }
public static void Save(SiteSettings settings) { SaveMasterSettings(settings); HiCache.Remove("FileCache-MasterSettings"); }
public static void Insert(string key, object obj, int seconds, CacheItemPriority priority) { HiCache.Insert(key, obj, null, seconds, priority); }
public static void Max(string string_0, object object_0) { HiCache.Max(string_0, object_0, null); }