Example #1
0
 public License.Base.License GetLicense(string licenseFile)
 {
     License.Base.License result;
     try
     {
         if (!System.IO.File.Exists(licenseFile))
         {
             throw new LicenseInvalidException("没有找到程序授权信息,请联系中联重科!");
         }
         Security             security      = new Security();
         string               encodedString = System.IO.File.ReadAllText(licenseFile);
         string               s             = security.DecodeString(encodedString);
         XmlSerializer        xmlSerializer = new XmlSerializer(typeof(License.Base.License));
         License.Base.License license       = (License.Base.License)xmlSerializer.Deserialize(new System.IO.StringReader(s));
         if (!this.VerifyLicense(license))
         {
             throw new LicenseInvalidException("许可无效,License Invalid!");
         }
         result = license;
     }
     catch
     {
         throw;
     }
     return(result);
 }
Example #2
0
        private bool VerifyLicense(License.Base.License lic)
        {
            Security security = new Security();
            string   hash     = security.GetHash(lic.GetHashString());
            bool     flag     = security.SignatureDeformatter(hash, lic.Signature);

            return(flag);
        }
Example #3
0
        private void BrowseButton_Click()
        {
            ofd.ShowDialog();
            string f = ofd.FileName;

            LicFileName = f;
            try
            {
                License.Base.License license = GetLicense(f);
                LicContentName = license.ToString();
            }
            catch (System.Exception ex)
            {
                LicContentName = ex.ToString();
            }
        }
Example #4
0
 public static License GetLicense()
 {
     return(License.GetLicense(License.licFile));
 }