internal static Class53 smethod_1(Enum0 requiredEdition) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Attribute0 customAttribute = (Attribute0)executingAssembly.GetCustomAttributes(typeof(Attribute0), true)[0]; Class53 licenseInfo = new Class53(customAttribute.ProductName); Class123.smethod_2(licenseInfo, executingAssembly, customAttribute, requiredEdition); return(licenseInfo); }
internal static void smethod_0(Enum0 edition) { Class53 class53 = Class123.smethod_1(edition); if (class53.LicensedEdition < edition) { string str; if (class53.IsTrial) { str = "Trial period expired!"; } else { str = class53.ProductName + " " + (object)class53.LicensedEdition + " is not licensed."; } int num = (int)MessageBox.Show(class53.Message, str, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); throw new InternalException(str); } }
private static Class53 smethod_2( Class53 licenseInfo, Assembly assembly, Attribute0 productAttribute, Enum0 requiredEdition) { string xmlString = "<RSAKeyValue><Modulus>5tmp6YoXLdKEUTC0PvXQmgM9V+jtb2LBV/6nCO8l/4StX9muFDQRSrtJAEH8sXcHu5Fgr7Y00oddMMSwfjXgiAG0b4WMhfF3s2/Cpw9MqFJXVnoeMr8dKHCr2Dp6cue6yCb3rIwjbRCYavYCHFmywBhrfztx6m125PD6TuDYDN0=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"; RSACryptoServiceProvider cryptoServiceProvider = new RSACryptoServiceProvider(new CspParameters() { Flags = CspProviderFlags.UseMachineKeyStore }); cryptoServiceProvider.FromXmlString(xmlString); XmlDocument license = License.GetLicense(); SignedXml signedXml = new SignedXml(license); try { XmlNode xmlNode = license.GetElementsByTagName("Signature", "http://www.w3.org/2000/09/xmldsig#")[0]; signedXml.LoadXml((XmlElement)xmlNode); } catch (Exception ex) { licenseInfo.Message = "Error: no signature found."; licenseInfo.Exception = ex; return(licenseInfo); } if (signedXml.CheckSignature((AsymmetricAlgorithm)cryptoServiceProvider)) { XmlNodeList elementsByTagName1 = license.GetElementsByTagName("product"); XmlNode xmlNode1 = (XmlNode)null; foreach (XmlNode xmlNode2 in elementsByTagName1) { if (xmlNode2.Attributes["name"].Value == licenseInfo.ProductName) { xmlNode1 = xmlNode2; break; } } if (xmlNode1 == null) { licenseInfo.Message = "Wrong license."; return(licenseInfo); } Version version1 = assembly.GetName().Version; string[] strArray = xmlNode1.Attributes["version"].Value.Split('.'); Version version2 = new Version(strArray[0] == "*" ? (int)byte.MaxValue : int.Parse(strArray[0], (IFormatProvider)CultureInfo.InvariantCulture), strArray[1] == "*" ? (int)byte.MaxValue : int.Parse(strArray[1], (IFormatProvider)CultureInfo.InvariantCulture), strArray[2] == "*" ? (int)byte.MaxValue : int.Parse(strArray[2], (IFormatProvider)CultureInfo.InvariantCulture)); if (version1.CompareTo(version2) > 0) { licenseInfo.Message = "Wrong license version."; return(licenseInfo); } Enum0 enum0 = Enum0.const_0; switch (xmlNode1.Attributes["edition"].Value) { case "basic": enum0 = Enum0.const_1; break; case "standard": enum0 = Enum0.const_2; break; case "professional": enum0 = Enum0.const_3; break; } if (requiredEdition > enum0) { licenseInfo.Message = "Insufficient license edition."; return(licenseInfo); } if (DateTime.Parse(xmlNode1.Attributes["expirationDate"].Value, (IFormatProvider)CultureInfo.InvariantCulture) < productAttribute.ReleaseDate) { licenseInfo.Message = "The license is not valid for this release of " + licenseInfo.ProductName + ", renew your license."; return(licenseInfo); } string str = xmlNode1.Attributes["type"].Value; if (str == "runtime") { licenseInfo.LicensedEdition = enum0; XmlNodeList elementsByTagName2 = license.GetElementsByTagName("licensee"); licenseInfo.Licensee = elementsByTagName2[0].InnerText; return(licenseInfo); } if (str == "trial") { licenseInfo.IsTrial = true; DateTime firstUsedDate; DateTime lastUsedDate; if (Class123.smethod_4(productAttribute, out firstUsedDate, out lastUsedDate)) { DateTime t1 = firstUsedDate.AddDays(31.0); DateTime utcNow = DateTime.UtcNow; if (lastUsedDate.Ticks > utcNow.Ticks) { licenseInfo.Message = "Licence check error."; return(licenseInfo); } Class123.smethod_5(productAttribute, firstUsedDate, utcNow); if (DateTime.Compare(t1, utcNow) >= 0) { licenseInfo.TrialDaysLeft = Math.Max(0, t1.Subtract(utcNow).Days); licenseInfo.LicensedEdition = enum0; return(licenseInfo); } licenseInfo.Message = "Trial period of 30 days expired."; return(licenseInfo); } licenseInfo.TrialDaysLeft = 30; Class123.smethod_5(productAttribute, DateTime.UtcNow, DateTime.UtcNow); licenseInfo.LicensedEdition = enum0; return(licenseInfo); } licenseInfo.Message = "Wrong license type."; return(licenseInfo); } licenseInfo.Message = "Invalid license."; return(licenseInfo); }