Esempio n. 1
0
        internal static Class522 smethod_1(Enum15 requiredEdition)
        {
            Assembly   executingAssembly = Assembly.GetExecutingAssembly();
            Attribute0 customAttribute   = (Attribute0)executingAssembly.GetCustomAttributes(typeof(Attribute0), true)[0];
            Class522   licenseInfo       = new Class522(customAttribute.ProductName);

            Class809.smethod_2(licenseInfo, executingAssembly, customAttribute, requiredEdition);
            return(licenseInfo);
        }
Esempio n. 2
0
        private static Class522 smethod_2(
            Class522 licenseInfo,
            Assembly assembly,
            Attribute0 productAttribute,
            Enum15 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);
                }
                Enum15 enum15 = Enum15.const_0;
                switch (xmlNode1.Attributes["edition"].Value)
                {
                case "basic":
                    enum15 = Enum15.const_1;
                    break;

                case "standard":
                    enum15 = Enum15.const_2;
                    break;

                case "professional":
                    enum15 = Enum15.const_3;
                    break;
                }
                if (requiredEdition > enum15)
                {
                    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 = enum15;
                    XmlNodeList elementsByTagName2 = license.GetElementsByTagName("licensee");
                    licenseInfo.Licensee = elementsByTagName2[0].InnerText;
                    return(licenseInfo);
                }
                if (str == "trial")
                {
                    licenseInfo.IsTrial = true;
                    DateTime firstUsedDate;
                    DateTime lastUsedDate;
                    if (Class809.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);
                        }
                        Class809.smethod_5(productAttribute, firstUsedDate, utcNow);
                        if (DateTime.Compare(t1, utcNow) >= 0)
                        {
                            licenseInfo.TrialDaysLeft   = Math.Max(0, t1.Subtract(utcNow).Days);
                            licenseInfo.LicensedEdition = enum15;
                            return(licenseInfo);
                        }
                        licenseInfo.Message = "Trial period of 30 days expired.";
                        return(licenseInfo);
                    }
                    licenseInfo.TrialDaysLeft = 30;
                    Class809.smethod_5(productAttribute, DateTime.UtcNow, DateTime.UtcNow);
                    licenseInfo.LicensedEdition = enum15;
                    return(licenseInfo);
                }
                licenseInfo.Message = "Wrong license type.";
                return(licenseInfo);
            }
            licenseInfo.Message = "Invalid license.";
            return(licenseInfo);
        }