示例#1
0
        // Token: 0x06001265 RID: 4709 RVA: 0x000702C4 File Offset: 0x0006E4C4
        internal static void UpdateProxyUserContextIdFromResponse(HttpWebResponse response, UserContext userContext)
        {
            ExTraceGlobals.UserContextCallTracer.TraceDebug(0L, "UpdateProxyUserContextIdFromResponse");
            string text = response.Headers["Set-Cookie"];

            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            int num = text.IndexOf("UserContext", StringComparison.Ordinal);

            if (num < 0)
            {
                return;
            }
            int num2 = text.IndexOf(';', num);

            if (num2 < 0)
            {
                num2 = text.Length - 1;
            }
            string text2 = text.Substring(num, num2 - num);

            if (!text2.StartsWith("UserContext", StringComparison.OrdinalIgnoreCase))
            {
                throw new OwaInvalidOperationException("Invalid user context cookie found in proxy response");
            }
            int num3 = text2.IndexOf('=');

            if (num3 < 0)
            {
                throw new OwaInvalidOperationException("Invalid user context cookie found in proxy response");
            }
            string cookieName  = text2.Substring(0, num3);
            string cookieValue = text2.Substring(num3 + 1, text2.Length - num3 - 1);
            string cookieId    = null;

            if (!UserContextCookie.TryParseCookieName(cookieName, out cookieId))
            {
                throw new OwaInvalidOperationException("Invalid user context cookie found in proxy response");
            }
            string canaryString     = null;
            string mailboxUniqueKey = null;

            if (!UserContextCookie.TryParseCookieValue(cookieValue, out canaryString, out mailboxUniqueKey))
            {
                throw new OwaInvalidOperationException("Invalid user context cookie found in proxy response");
            }
            Canary canary = Canary.RestoreCanary(canaryString, userContext.LogonIdentity.UniqueId);

            userContext.ProxyUserContextCookie = UserContextCookie.Create(cookieId, canary, mailboxUniqueKey);
            ExTraceGlobals.UserContextTracer.TraceDebug <UserContextCookie>(0L, "Found set-cookie returned by second CAS: {0}", userContext.ProxyUserContextCookie);
            if (userContext.ProxyUserContextCookie == null)
            {
                throw new OwaInvalidOperationException("Invalid user context cookie found in proxy response");
            }
        }
示例#2
0
        // Token: 0x0600164D RID: 5709 RVA: 0x000832A8 File Offset: 0x000814A8
        internal static UserContextCookie TryCreateFromHttpCookie(HttpCookie cookie, string logonUniqueKey)
        {
            string text   = null;
            string text2  = null;
            string text3  = null;
            Canary canary = null;

            if (string.IsNullOrEmpty(cookie.Value))
            {
                ExTraceGlobals.UserContextTracer.TraceDebug <string, string, string>(21L, "Http cookie value is null, Name={0}, Domain={1}, Path={2}", cookie.Name, cookie.Domain, cookie.Path);
            }
            else if (!UserContextCookie.TryParseCookieValue(cookie.Value, out text, out text2))
            {
                ExTraceGlobals.UserContextTracer.TraceDebug(21L, "TryParseCookeValue failed, Name={0}, Domain={1}, Path={2}, Value={3}", new object[]
                {
                    cookie.Name,
                    cookie.Domain,
                    cookie.Path,
                    cookie.Value
                });
            }
            else
            {
                if (!UserContextCookie.TryParseCookieName(cookie.Name, out text3))
                {
                    ExTraceGlobals.UserContextTracer.TraceDebug(21L, "TryParseCookieName failed, Name={0}, Domain={1}, Path={2}, vVlue={3}, canaryString={4}, mailboxUniqueKey={5}", new object[]
                    {
                        cookie.Name,
                        cookie.Domain,
                        cookie.Path,
                        cookie.Value,
                        text,
                        text2
                    });
                }
                canary = Canary.RestoreCanary(text, logonUniqueKey);
            }
            if (canary == null)
            {
                ExTraceGlobals.UserContextTracer.TraceDebug(21L, "restoredCanary==null, Name={0}, Domain={1}, Path={2}, Value={3}, canaryString={4}, mailboxUniqueKey={5}, logonUniqueKey={6}", new object[]
                {
                    cookie.Name,
                    cookie.Domain,
                    cookie.Path,
                    cookie.Value,
                    text,
                    text2,
                    logonUniqueKey
                });
                canary = new Canary(Guid.NewGuid(), logonUniqueKey);
                ExTraceGlobals.UserContextTracer.TraceDebug <string, string, string>(21L, "Canary is recreated, userContextId={0}, logonUniqueKey={1}, canaryString={2}", canary.UserContextId, canary.LogonUniqueKey, canary.ToString());
            }
            return(UserContextCookie.Create(text3, canary, text2));
        }