Esempio n. 1
0
        /// <summary>
        /// 从GloableSetting中读取LicenseServer信息
        /// </summary>
        /// <returns></returns>
        public List <LicenseServer> GetLicenseServers()
        {
            List <LicenseServer> lstServers = new List <LicenseServer>();

            try
            {
                XmlNode       serversNode             = xmlOperator.SelectNode("Parameters02/LicenseServer", "");
                LicenseServer server                  = null;
                string        LStrVerificationCode001 = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M101);
                foreach (XmlNode node in serversNode.ChildNodes)
                {
                    server = new LicenseServer();
                    if (!node.Name.Equals("LicServer"))
                    {
                        continue;
                    }
                    string str     = xmlOperator.SelectAttrib(node, "P02");
                    int    iEnable = int.Parse(EncryptionAndDecryption.EncryptDecryptString(xmlOperator.SelectAttrib(node, "P02"), LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101));
                    if (iEnable == 1)
                    {
                        server        = new LicenseServer();
                        server.IsMain = int.Parse(xmlOperator.SelectAttrib(node, "P01"));
                        server.Host   = EncryptionAndDecryption.EncryptDecryptString(xmlOperator.SelectAttrib(node, "P03"), LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101);
                        server.Port   = int.Parse(EncryptionAndDecryption.EncryptDecryptString(xmlOperator.SelectAttrib(node, "P04"), LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101));
                        lstServers.Add(server);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(lstServers);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //-----------
            const string DemoLicenseKey = "D2287CCA-2A3A-48C2-BCCB-BF12B3E481B0";
            var          server         = new LicenseServer();

            var rawLicense = server.IssueLicense(DateTime.Now.AddDays(10),
                                                 DemoLicenseKey);
            var license = new ClientLicense(rawLicense);

            Console.WriteLine("License is valid? - {0}", license.Verify());
            Console.WriteLine("Message - {0}", license.Message);
            Console.WriteLine();

            Console.ReadKey();

            //-----------Expires
            rawLicense = server.IssueLicense(DateTime.Now.AddDays(10),
                                             DemoLicenseKey);
            var tamper = new XmlDocument();

            tamper.LoadXml(rawLicense);
            tamper.SelectSingleNode("//Expires").InnerText =
                DateTime.Now.AddYears(5).ToString("dd/MM/yyyy HH:mm:ss");

            var tamperedXml = new StringBuilder();

            using (var swOut = new StringWriter(tamperedXml))
            {
                tamper.Save(swOut);
            }
            license = new ClientLicense(tamperedXml.ToString());

            Console.WriteLine("License is valid? - {0}", license.Verify());
            Console.WriteLine("Message - {0}", license.Message);
            Console.WriteLine();

            Console.ReadKey();


            //-----------
            rawLicense = server.IssueLicense(DateTime.Now.AddDays(-10),
                                             DemoLicenseKey);
            license = new ClientLicense(rawLicense);
            Console.WriteLine("License is valid? - {0}", license.Verify());
            Console.WriteLine("Message - {0}", license.Message);


            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            //-----------
            const string DemoLicenseKey = "D2287CCA-2A3A-48C2-BCCB-BF12B3E481B0";
            var server = new LicenseServer();

            var rawLicense = server.IssueLicense(DateTime.Now.AddDays(10),
                                                  DemoLicenseKey);
            var license = new ClientLicense(rawLicense);
            Console.WriteLine("License is valid? - {0}", license.Verify());
            Console.WriteLine("Message - {0}", license.Message);
            Console.WriteLine();

            Console.ReadKey();

            //-----------Expires
            rawLicense = server.IssueLicense(DateTime.Now.AddDays(10),
                                  DemoLicenseKey);
            var tamper = new XmlDocument();
            tamper.LoadXml(rawLicense);
            tamper.SelectSingleNode("//Expires").InnerText =
                DateTime.Now.AddYears(5).ToString("dd/MM/yyyy HH:mm:ss");

            var tamperedXml = new StringBuilder();
            using (var swOut = new StringWriter(tamperedXml))
            {
                tamper.Save(swOut);
            }
            license = new ClientLicense(tamperedXml.ToString());

            Console.WriteLine("License is valid? - {0}", license.Verify());
            Console.WriteLine("Message - {0}", license.Message);
            Console.WriteLine();

            Console.ReadKey();


            //-----------
            rawLicense = server.IssueLicense(DateTime.Now.AddDays(-10),
                                  DemoLicenseKey);
            license = new ClientLicense(rawLicense);
            Console.WriteLine("License is valid? - {0}", license.Verify());
            Console.WriteLine("Message - {0}", license.Message);


            Console.ReadKey();


        }
Esempio n. 4
0
        public static bool CheckNetworkLicense()
        {
            //解析端口号
            uint port = 0;

            uint.TryParse(m_sNetPort, out port);

            //连接网络服务器并验证
            ILicenseServer licenseServer = new LicenseServer();

            licenseServer.SetHost(m_sNetHost, port, m_sNetPwd);

            bool bSucceed = licenseServer.HasPermission();

            return(bSucceed);
        }
Esempio n. 5
0
 static void Main(string[] args)
 {
     try
     {
         ServerName = args[0];
         ServerPort = args[1];
         KeyIndex   = args[2];
         KeySerial  = args[3];
         OutputPath = args[4];
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Did you pass the required arguments?");
         Console.ReadKey();
         Environment.Exit(0);
     }
     //CSV output
     Maintenance.WriteToCSVTable(OutputPath, LicenseServer.GetLicenses(ServerName, ServerPort, KeyIndex, KeySerial));
 }
Esempio n. 6
0
        /// <summary>
        /// 设置授权服务器,本地锁不需要设置
        /// </summary>
        void setLicense()
        {
            ILicenseServer ls = new LicenseServer();

            ls.SetHost("192.168.2.200", 8588, "");
        }