Example #1
0
        private static bool GetBundleInfo(byte[] unsignedBundleBytes, out SslSocket.BundleInfo info)
        {
            info.bundleKeyHashs = new List <byte[]>();
            info.bundleUris     = new List <string>();
            info.bundleCerts    = new List <X509Certificate2>();
            string text    = null;
            string @string = Encoding.ASCII.GetString(unsignedBundleBytes);

            try
            {
                JsonNode jsonNode = Json.Deserialize(@string) as JsonNode;
                JsonList jsonList = jsonNode["PublicKeys"] as JsonList;
                foreach (object obj in jsonList)
                {
                    JsonNode jsonNode2 = (JsonNode)obj;
                    string   item      = (string)jsonNode2["Uri"];
                    string   hex       = (string)jsonNode2["ShaHashPublicKeyInfo"];
                    byte[]   item2     = null;
                    SslSocket.HexStrToBytesError hexStrToBytesError = SslSocket.HexStrToBytes(hex, out item2);
                    if (hexStrToBytesError != SslSocket.HexStrToBytesError.OK)
                    {
                        text = EnumUtils.GetString <SslSocket.HexStrToBytesError>(hexStrToBytesError);
                        break;
                    }
                    info.bundleKeyHashs.Add(item2);
                    info.bundleUris.Add(item);
                }
                JsonList jsonList2 = jsonNode["SigningCertificates"] as JsonList;
                foreach (object obj2 in jsonList2)
                {
                    JsonNode         jsonNode3 = (JsonNode)obj2;
                    string           s         = (string)jsonNode3["RawData"];
                    byte[]           bytes     = Encoding.ASCII.GetBytes(s);
                    X509Certificate2 item3     = new X509Certificate2(bytes);
                    info.bundleCerts.Add(item3);
                }
            }
            catch (Exception ex)
            {
                text = ex.ToString();
            }
            if (text != null)
            {
                SslSocket.s_log.LogWarning("Exception while trying to parse certificate bundle. {0}", new object[]
                {
                    text
                });
                return(false);
            }
            return(true);
        }
        private static bool GetBundleInfo(byte[] unsignedBundleBytes, out SslSocket.BundleInfo info)
        {
            info = new SslSocket.BundleInfo();
            info.bundleKeyHashs = new List <byte[]>();
            info.bundleUris     = new List <string>();
            info.bundleCerts    = new List <X509Certificate2>();
            string str  = null;
            string str1 = Encoding.ASCII.GetString(unsignedBundleBytes);

            try
            {
                JsonNode jsonNode = Json.Deserialize(str1) as JsonNode;
                foreach (JsonNode item in jsonNode["PublicKeys"] as JsonList)
                {
                    string item1    = (string)item["Uri"];
                    string item2    = (string)item["ShaHashPublicKeyInfo"];
                    byte[] numArray = null;
                    SslSocket.HexStrToBytesError bytes = SslSocket.HexStrToBytes(item2, out numArray);
                    if (bytes == SslSocket.HexStrToBytesError.OK)
                    {
                        info.bundleKeyHashs.Add(numArray);
                        info.bundleUris.Add(item1);
                    }
                    else
                    {
                        str = EnumUtils.GetString <SslSocket.HexStrToBytesError>(bytes);
                        break;
                    }
                }
                foreach (JsonNode jsonNode1 in jsonNode["SigningCertificates"] as JsonList)
                {
                    string           str2             = (string)jsonNode1["RawData"];
                    X509Certificate2 x509Certificate2 = new X509Certificate2(Encoding.ASCII.GetBytes(str2));
                    info.bundleCerts.Add(x509Certificate2);
                }
            }
            catch (Exception exception)
            {
                str = exception.ToString();
            }
            if (str == null)
            {
                return(true);
            }
            SslSocket.s_log.LogWarning("Exception while trying to parse certificate bundle. {0}", new object[] { str });
            return(false);
        }
Example #3
0
        public static void CreateParty(PartyType partyType, PrivacyLevel privacyLevel, byte[] creatorBlob, BnetParty.CreateSuccessCallback successCallback)
        {
            string @string = EnumUtils.GetString <PartyType>(partyType);

            if (BnetParty.s_pendingPartyCreates != null && BnetParty.s_pendingPartyCreates.ContainsKey(partyType))
            {
                BnetParty.RaisePartyError(true, @string, BnetFeatureEvent.Party_Create_Callback, "CreateParty: Already creating party of type {0}", new object[]
                {
                    partyType
                });
                return;
            }
            if (BnetParty.s_pendingPartyCreates == null)
            {
                BnetParty.s_pendingPartyCreates = new Map <PartyType, BnetParty.CreateSuccessCallback>();
            }
            BnetParty.s_pendingPartyCreates[partyType] = successCallback;
            BattleNet.CreateParty(@string, (int)privacyLevel, creatorBlob);
        }
Example #4
0
        public static void RequestInvite(PartyId partyId, BnetGameAccountId whomToAskForApproval, BnetGameAccountId whomToInvite, PartyType partyType)
        {
            if (BnetParty.IsLeader(partyId))
            {
                PartyError error = default(PartyError);
                error.IsOperationCallback = true;
                error.DebugContext        = "RequestInvite";
                error.ErrorCode           = BattleNetErrors.ERROR_INVALID_TARGET_ID;
                error.Feature             = BnetFeature.Party;
                error.FeatureEvent        = BnetFeatureEvent.Party_RequestPartyInvite_Callback;
                error.PartyId             = partyId;
                error.szPartyType         = EnumUtils.GetString <PartyType>(partyType);
                error.StringData          = "leaders cannot RequestInvite - use SendInvite instead.";
                BnetParty.OnError(error);
                return;
            }
            EntityId partyId2 = partyId.ToEntityId();
            EntityId whomToAskForApproval2 = BnetEntityId.CreateEntityId(whomToAskForApproval);
            EntityId whomToInvite2         = BnetEntityId.CreateEntityId(whomToInvite);
            string   @string = EnumUtils.GetString <PartyType>(partyType);

            BattleNet.RequestPartyInvite(partyId2, whomToAskForApproval2, whomToInvite2, @string);
        }
Example #5
0
        public static void JoinParty(PartyId partyId, PartyType partyType)
        {
            EntityId partyId2 = partyId.ToEntityId();

            BattleNet.JoinParty(partyId2, EnumUtils.GetString <PartyType>(partyType));
        }
Example #6
0
        public static bool TryGetEnum <T>(string str, StringComparison comparisonType, out T result)
        {
            Type typeFromHandle = typeof(T);
            Dictionary <string, object> dictionary;

            EnumUtils.s_enumCache.TryGetValue(typeFromHandle, ref dictionary);
            object obj;

            if (dictionary != null && dictionary.TryGetValue(str, ref obj))
            {
                result = (T)((object)obj);
                return(true);
            }
            IEnumerator enumerator = Enum.GetValues(typeFromHandle).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    T      t       = (T)((object)enumerator.get_Current());
                    bool   flag    = false;
                    string @string = EnumUtils.GetString <T>(t);
                    if (@string.Equals(str, comparisonType))
                    {
                        flag   = true;
                        result = t;
                    }
                    else
                    {
                        FieldInfo field = t.GetType().GetField(t.ToString());
                        DescriptionAttribute[] array = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), false);
                        for (int i = 0; i < array.Length; i++)
                        {
                            if (array[i].get_Description().Equals(str, comparisonType))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        if (dictionary == null)
                        {
                            dictionary = new Dictionary <string, object>();
                            EnumUtils.s_enumCache.Add(typeFromHandle, dictionary);
                        }
                        if (!dictionary.ContainsKey(str))
                        {
                            dictionary.Add(str, t);
                        }
                        result = t;
                        return(true);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            result = default(T);
            return(false);
        }
Example #7
0
        public static bool TryGetEnum <T>(string str, StringComparison comparisonType, out T result)
        {
            Dictionary <string, object> strs;
            object obj;
            bool   flag;
            Type   type = typeof(T);

            EnumUtils.s_enumCache.TryGetValue(type, out strs);
            if (strs != null && strs.TryGetValue(str, out obj))
            {
                result = (T)obj;
                return(true);
            }
            IEnumerator enumerator = Enum.GetValues(type).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    T    current = (T)enumerator.Current;
                    bool flag1   = false;
                    if (!EnumUtils.GetString <T>(current).Equals(str, comparisonType))
                    {
                        FieldInfo field = current.GetType().GetField(current.ToString());
                        DescriptionAttribute[] customAttributes = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), false);
                        int num = 0;
                        while (num < (int)customAttributes.Length)
                        {
                            if (!customAttributes[num].Description.Equals(str, comparisonType))
                            {
                                num++;
                            }
                            else
                            {
                                flag1 = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        flag1  = true;
                        result = current;
                    }
                    if (!flag1)
                    {
                        continue;
                    }
                    if (strs == null)
                    {
                        strs = new Dictionary <string, object>();
                        EnumUtils.s_enumCache.Add(type, strs);
                    }
                    if (!strs.ContainsKey(str))
                    {
                        strs.Add(str, current);
                    }
                    result = current;
                    flag   = true;
                    return(flag);
                }
                result = default(T);
                return(false);
            }
            finally
            {
                IDisposable disposable  = enumerator as IDisposable;
                IDisposable disposable1 = disposable;
                if (disposable != null)
                {
                    disposable1.Dispose();
                }
            }
            return(flag);
        }