Example #1
0
        protected virtual BackEndServer TryGetBackEndFromCookie(BackEndCookieEntryBase cookieEntry)
        {
            BackEndServerCookieEntry backEndServerCookieEntry = cookieEntry as BackEndServerCookieEntry;

            if (backEndServerCookieEntry != null)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[AnchorMailbox::TryGetBackEndFromCookie]: BackEndServerCookier {0}", backEndServerCookieEntry.ToString());
                return(new BackEndServer(backEndServerCookieEntry.Fqdn, backEndServerCookieEntry.Version));
            }
            ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[AnchorMailbox::TryGetBackEndFromCookie]: No BackEndServerCookie");
            return(null);
        }
        // Token: 0x06000282 RID: 642 RVA: 0x0000CE20 File Offset: 0x0000B020
        public static bool TryParse(string entryValue, out BackEndCookieEntryBase cookieEntry, out string clearCookie)
        {
            cookieEntry = null;
            clearCookie = null;
            if (string.IsNullOrEmpty(entryValue))
            {
                return(false);
            }
            bool result;

            try
            {
                string text = BackEndCookieEntryParser.UnObscurify(entryValue);
                clearCookie = text;
                string[] array = StringExtensions.SplitFast(text, '~', int.MaxValue, StringSplitOptions.None);
                if (array.Length < 4)
                {
                    result = false;
                }
                else
                {
                    BackEndCookieEntryType backEndCookieEntryType;
                    if (!BackEndCookieEntryBase.TryGetBackEndCookieEntryTypeFromString(array[0], out backEndCookieEntryType))
                    {
                        backEndCookieEntryType = (BackEndCookieEntryType)Enum.Parse(typeof(BackEndCookieEntryType), array[0], true);
                    }
                    ExDateTime expiryTime;
                    if (!BackEndCookieEntryParser.TryParseDateTime(array[3], out expiryTime))
                    {
                        result = false;
                    }
                    else if (backEndCookieEntryType != BackEndCookieEntryType.Server)
                    {
                        if (backEndCookieEntryType == BackEndCookieEntryType.Database)
                        {
                            Guid   database       = new Guid(array[1]);
                            string text2          = string.IsNullOrEmpty(array[2]) ? null : array[2];
                            string resourceForest = (array.Length < 5 || string.IsNullOrEmpty(array[4])) ? null : array[4];
                            if (array.Length >= 6)
                            {
                                bool isOrganizationMailboxDatabase = string.Equals(array[5], 1.ToString(), StringComparison.OrdinalIgnoreCase);
                                cookieEntry = new BackEndDatabaseOrganizationAwareCookieEntry(database, text2, resourceForest, expiryTime, isOrganizationMailboxDatabase);
                            }
                            else if (array.Length == 5)
                            {
                                cookieEntry = new BackEndDatabaseResourceForestCookieEntry(database, text2, resourceForest, expiryTime);
                            }
                            else
                            {
                                cookieEntry = new BackEndDatabaseCookieEntry(database, text2, expiryTime);
                            }
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                    }
                    else
                    {
                        cookieEntry = new BackEndServerCookieEntry(array[1], int.Parse(array[2]), expiryTime);
                        result      = true;
                    }
                }
            }
            catch (ArgumentException)
            {
                result = false;
            }
            catch (FormatException)
            {
                result = false;
            }
            return(result);
        }
        public static bool TryParse(string entryValue, out BackEndCookieEntryBase cookieEntry, out string clearCookie)
        {
            cookieEntry = null;
            clearCookie = null;
            if (string.IsNullOrEmpty(entryValue))
            {
                return(false);
            }
            bool result;

            try
            {
                string text = BackEndCookieEntryParser.UnObscurify(entryValue);
                clearCookie = text;
                string[] array = text.Split(BackEndCookieEntryParser.CookieSeparators);
                if (array.Length < 4)
                {
                    result = false;
                }
                else
                {
                    BackEndCookieEntryType backEndCookieEntryType;
                    if (!BackEndCookieEntryBase.TryGetBackEndCookieEntryTypeFromString(array[0], out backEndCookieEntryType))
                    {
                        backEndCookieEntryType = (BackEndCookieEntryType)Enum.Parse(typeof(BackEndCookieEntryType), array[0], true);
                    }
                    ExDateTime expiryTime;
                    if (!BackEndCookieEntryParser.TryParseDateTime(array[3], out expiryTime))
                    {
                        result = false;
                    }
                    else
                    {
                        switch (backEndCookieEntryType)
                        {
                        case BackEndCookieEntryType.Server:
                            cookieEntry = new BackEndServerCookieEntry(array[1], int.Parse(array[2]), expiryTime);
                            result      = true;
                            break;

                        case BackEndCookieEntryType.Database:
                        {
                            Guid   database = new Guid(array[1]);
                            string text2    = string.IsNullOrEmpty(array[2]) ? null : array[2];
                            if (array.Length == 5)
                            {
                                string resourceForest = string.IsNullOrEmpty(array[4]) ? null : array[4];
                                cookieEntry = new BackEndDatabaseResourceForestCookieEntry(database, text2, resourceForest, expiryTime);
                            }
                            else
                            {
                                cookieEntry = new BackEndDatabaseCookieEntry(database, text2, expiryTime);
                            }
                            result = true;
                            break;
                        }

                        default:
                            result = false;
                            break;
                        }
                    }
                }
            }
            catch (ArgumentException)
            {
                result = false;
            }
            catch (FormatException)
            {
                result = false;
            }
            return(result);
        }