Esempio n. 1
0
 // Token: 0x06000E95 RID: 3733 RVA: 0x0005D424 File Offset: 0x0005B624
 public static void GetLicense(Api.LicenseChecker checker, string appId, string appKey)
 {
     if (checker == null || string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(appKey))
     {
         throw new InvalidOperationException("checker == null || string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(appKey)");
     }
     Api._appId  = appId;
     Api._appKey = appKey;
     Api.InternalLicenseCheckers.Add(checker);
     if (IntPtr.Size == 8)
     {
         Api.GetLicense_64(new GetLicenseCallback(Api.GetLicenseHandler), Api._appId, Api._appKey);
         return;
     }
     Api.GetLicense(new GetLicenseCallback(Api.GetLicenseHandler), Api._appId, Api._appKey);
 }
Esempio n. 2
0
 // Token: 0x060049A3 RID: 18851 RVA: 0x0018A3B0 File Offset: 0x001887B0
 public static void GetLicense(Api.LicenseChecker checker, string appId, string appKey)
 {
     if (checker == null || string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(appKey))
     {
         throw new InvalidOperationException("checker == null || string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(appKey)");
     }
     Api._appId  = appId;
     Api._appKey = appKey;
     Api.InternalLicenseCheckers.Add(checker);
     if (Api.f__mg0 == null)
     {
         Api.f__mg0 = new GetLicenseCallback(Api.GetLicenseHandler);
     }
     // HMM.
     Api.GetLicense(checker, Api._appId, Api._appKey);
 }
Esempio n. 3
0
        private static void GetLicenseHandler([MarshalAs(UnmanagedType.LPStr)] string message, [MarshalAs(UnmanagedType.LPStr)] string signature)
        {
            if (string.IsNullOrEmpty(message))
            {
                for (int i = Api.InternalLicenseCheckers.Count - 1; i >= 0; i--)
                {
                    Api.LicenseChecker licenseChecker = Api.InternalLicenseCheckers[i];
                    licenseChecker.OnFailure(90003, "License message is empty");
                    Api.InternalLicenseCheckers.Remove(licenseChecker);
                }
                return;
            }
            if (string.IsNullOrEmpty(signature))
            {
                JsonData jsonData     = JsonMapper.ToObject(message);
                int      errorCode    = 99999;
                string   errorMessage = "";
                try
                {
                    errorCode = int.Parse((string)jsonData["code"]);
                }
                catch
                {
                }
                try
                {
                    errorMessage = (string)jsonData["message"];
                }
                catch
                {
                }
                for (int j = Api.InternalLicenseCheckers.Count - 1; j >= 0; j--)
                {
                    Api.LicenseChecker licenseChecker2 = Api.InternalLicenseCheckers[j];
                    licenseChecker2.OnFailure(errorCode, errorMessage);
                    Api.InternalLicenseCheckers.Remove(licenseChecker2);
                }
                return;
            }
            if (!Api.VerifyMessage(Api._appId, Api._appKey, message, signature))
            {
                for (int k = Api.InternalLicenseCheckers.Count - 1; k >= 0; k--)
                {
                    Api.LicenseChecker licenseChecker3 = Api.InternalLicenseCheckers[k];
                    licenseChecker3.OnFailure(90001, "License verification failed");
                    Api.InternalLicenseCheckers.Remove(licenseChecker3);
                }
                return;
            }
            string   @string   = Encoding.UTF8.GetString(Convert.FromBase64String(message.Substring(message.IndexOf("\n", StringComparison.Ordinal) + 1)));
            JsonData jsonData2 = JsonMapper.ToObject(@string);

            Logger.Log("License: " + @string);
            long issueTime      = -1L;
            long expirationTime = -1L;
            int  latestVersion  = -1;
            bool updateRequired = false;

            try
            {
                issueTime = (long)jsonData2["issueTime"];
            }
            catch
            {
            }
            try
            {
                expirationTime = (long)jsonData2["expirationTime"];
            }
            catch
            {
            }
            try
            {
                latestVersion = (int)jsonData2["latestVersion"];
            }
            catch
            {
            }
            try
            {
                updateRequired = (bool)jsonData2["updateRequired"];
            }
            catch
            {
            }
            for (int l = Api.InternalLicenseCheckers.Count - 1; l >= 0; l--)
            {
                Api.LicenseChecker licenseChecker4 = Api.InternalLicenseCheckers[l];
                licenseChecker4.OnSuccess(issueTime, expirationTime, latestVersion, updateRequired);
                Api.InternalLicenseCheckers.Remove(licenseChecker4);
            }
        }