// Token: 0x060005AB RID: 1451 RVA: 0x0001F80C File Offset: 0x0001DA0C
 private UserContextCookie TryGetUserContextFromProxyLogonResponse()
 {
     foreach (object obj in this.proxyLogonResponseCookies)
     {
         Cookie cookie = (Cookie)obj;
         if (cookie.Name.StartsWith("UserContext"))
         {
             return(UserContextCookie.TryCreateFromNetCookie(cookie));
         }
     }
     return(null);
 }
 // Token: 0x060002A7 RID: 679 RVA: 0x0000D514 File Offset: 0x0000B714
 public static bool IsValidGuid(string guid)
 {
     if (guid == null || guid.Length != 32)
     {
         return(false);
     }
     for (int i = 0; i < 32; i++)
     {
         if (!UserContextCookie.IsHexChar(guid[i]))
         {
             return(false);
         }
     }
     return(true);
 }
        // Token: 0x060002AE RID: 686 RVA: 0x0000D6D8 File Offset: 0x0000B8D8
        internal static bool TryParseCookieName(string cookieName, out string cookieId)
        {
            cookieId = null;
            if (!cookieName.StartsWith("UserContext", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            int length = "UserContext".Length;

            if (cookieName.Length == length)
            {
                return(true);
            }
            cookieId = cookieName.Substring(length + 1, cookieName.Length - length - 1);
            return(UserContextCookie.IsValidGuid(cookieId));
        }
        // Token: 0x060002AC RID: 684 RVA: 0x0000D5E8 File Offset: 0x0000B7E8
        internal static UserContextCookie TryCreateFromNetCookie(Cookie cookie)
        {
            string text  = null;
            string text2 = null;

            if (string.IsNullOrEmpty(cookie.Value))
            {
                return(null);
            }
            if (!UserContextCookie.TryParseCookieValue(cookie.Value, out text, out text2))
            {
                return(null);
            }
            string text3 = null;

            if (!UserContextCookie.TryParseCookieName(cookie.Name, out text3))
            {
                return(null);
            }
            return(UserContextCookie.Create(text3, text, text2));
        }
 // Token: 0x060002AD RID: 685 RVA: 0x0000D638 File Offset: 0x0000B838
 internal static bool TryParseCookieValue(string cookieValue, out string userContextId, out string mailboxUniqueKey)
 {
     userContextId    = null;
     mailboxUniqueKey = null;
     if (cookieValue.Length == 32)
     {
         userContextId = cookieValue;
     }
     else
     {
         if (cookieValue.Length < 34)
         {
             return(false);
         }
         int num = cookieValue.IndexOf('&');
         if (num != 32)
         {
             return(false);
         }
         num++;
         userContextId = cookieValue.Substring(0, num - 1);
         string tokenValidBase64String = cookieValue.Substring(num, cookieValue.Length - num);
         byte[] bytes = null;
         try
         {
             bytes = UserContextCookie.ValidTokenBase64Decode(tokenValidBase64String);
         }
         catch (FormatException)
         {
             return(false);
         }
         UTF8Encoding utf8Encoding = new UTF8Encoding();
         mailboxUniqueKey = utf8Encoding.GetString(bytes);
     }
     return(UserContextCookie.IsValidUserContextId(userContextId));
 }
 // Token: 0x060002AF RID: 687 RVA: 0x0000D72F File Offset: 0x0000B92F
 private static bool IsValidUserContextId(string userContextId)
 {
     return(UserContextCookie.IsValidGuid(userContextId));
 }
 // Token: 0x060005AA RID: 1450 RVA: 0x0001F7D8 File Offset: 0x0001D9D8
 private void OnProxyLogonResponseReady(object extraData)
 {
     base.CallThreadEntranceMethod(delegate
     {
         IAsyncResult asyncResult = extraData as IAsyncResult;
         object lockObject        = this.LockObject;
         lock (lockObject)
         {
             try
             {
                 GuardedProxyExecution.Default.Decrement(this.AnchoredRoutingTarget.BackEndServer);
                 this.proxyLogonResponse = (HttpWebResponse)this.proxyLogonRequest.EndGetResponse(asyncResult);
                 this.PfdTracer.TraceResponse("ProxyLogonResponse", this.proxyLogonResponse);
                 this.proxyLogonResponseCookies = this.proxyLogonResponse.Cookies;
                 this.proxyLogonResponse.Close();
                 this.proxyLogonResponse             = null;
                 UserContextCookie userContextCookie = this.TryGetUserContextFromProxyLogonResponse();
                 if (userContextCookie != null && userContextCookie.MailboxUniqueKey != null)
                 {
                     string mailboxUniqueKey = userContextCookie.MailboxUniqueKey;
                     if (SmtpAddress.IsValidSmtpAddress(mailboxUniqueKey))
                     {
                         AnchorMailbox anchorMailbox = new SmtpAnchorMailbox(ProxyAddress.Parse("SMTP", mailboxUniqueKey).AddressString, this);
                         this.AnchoredRoutingTarget  = new AnchoredRoutingTarget(anchorMailbox, this.AnchoredRoutingTarget.BackEndServer);
                     }
                     else
                     {
                         try
                         {
                             AnchorMailbox anchorMailbox2 = new SidAnchorMailbox(new SecurityIdentifier(mailboxUniqueKey), this);
                             this.AnchoredRoutingTarget   = new AnchoredRoutingTarget(anchorMailbox2, this.AnchoredRoutingTarget.BackEndServer);
                         }
                         catch (ArgumentException)
                         {
                         }
                     }
                 }
                 ThreadPool.QueueUserWorkItem(new WaitCallback(this.BeginProxyRequest));
                 this.State = ProxyRequestHandler.ProxyState.PrepareServerRequest;
             }
             catch (WebException ex)
             {
                 if (ex.Status == WebExceptionStatus.ProtocolError && ((HttpWebResponse)ex.Response).StatusCode == (HttpStatusCode)442)
                 {
                     this.RedirectOn442Response();
                 }
                 else
                 {
                     this.CompleteWithError(ex, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
                 }
             }
             catch (HttpException ex2)
             {
                 this.CompleteWithError(ex2, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (IOException ex3)
             {
                 this.CompleteWithError(ex3, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
             catch (HttpProxyException ex4)
             {
                 this.CompleteWithError(ex4, "[OwaEcpProxyRequestHandler::OnProxyLogonResponseReady]");
             }
         }
     });
 }