コード例 #1
0
        //--- Class Methods ---
        private static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                Usage();
                return(-1);
            }
            int  status  = 0;
            bool verbose = false;

            // setup callback to allow invalid SSL certiicates
            System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate {
                return(_allowInvalidSsl);
            };

            // loop over all arguments
            foreach (string arg in args)
            {
                // check if argument is an option
                if (arg.StartsWith("--"))
                {
                    switch (arg)
                    {
                    case "--verbose":
                        verbose = true;
                        break;

                    case "--allow-invalid-ssl":
                        _allowInvalidSsl = true;
                        break;

                    default:
                        Console.WriteLine("ERROR: unknown command line option '{0}'", arg);
                        return(-1);
                    }
                    continue;
                }

                // process host license
                if (verbose)
                {
                    Console.WriteLine("Validating: {0}", arg);
                }
                status = 0;
                try {
                    DekiLicense.Validate(arg);
                } catch (DekiLicenseException e) {
                    Console.WriteLine(e.Message);
                    status = (int)e.Reason;
                } catch (Exception e) {
                    Console.WriteLine("UNEXPECTED ERROR: " + e);
                    status = -2;
                }
                if (status == 0)
                {
                    Console.WriteLine("The server license is valid.");
                }
                if (verbose)
                {
                    Console.WriteLine("Status: {0}", status);
                    Console.WriteLine();
                }
            }
            return(status);
        }
コード例 #2
0
ファイル: LicenseBL.cs プロジェクト: Minocula/MindTouch_Core
 public void Validate(XDoc license)
 {
     DekiLicense.Validate(license);
 }