Example #1
0
 // Token: 0x060007B5 RID: 1973 RVA: 0x0003A75C File Offset: 0x0003895C
 public static bool ValidateCanary(string canaryString, string logonUniqueKey)
 {
     byte[] userContextIdBinary;
     byte[] array;
     byte[] array2;
     if (!Canary.ParseCanary(canaryString, out userContextIdBinary, out array, out array2))
     {
         ExTraceGlobals.UserContextTracer.TraceDebug <string, string, string>(10L, "{0}.{1}: Parse failed, canaryString={2}", "Owa.Core.Canary", "ValidateCanary", canaryString);
         return(false);
     }
     if (Canary.IsExpired(array))
     {
         ExTraceGlobals.UserContextTracer.TraceDebug <string, string, string>(10L, "{0}.{1}: IsExpired=true, timeStampBinary={2}", "Owa.Core.Canary", "ValidateCanary", Canary.GetHexString(array));
         return(false);
     }
     byte[] array3 = Canary.ComputeHash(userContextIdBinary, array, logonUniqueKey);
     if (Canary.AreEqual(array2, array3))
     {
         return(true);
     }
     ExTraceGlobals.UserContextTracer.TraceDebug(10L, "{0}.{1}: hashBinary is invalid, testHashBinary={2}!=hashBinary={3}", new object[]
     {
         "Owa.Core.Canary",
         "ValidateCanary",
         Canary.GetHexString(array3),
         Canary.GetHexString(array2)
     });
     return(false);
 }
Example #2
0
 // Token: 0x06001649 RID: 5705 RVA: 0x00083201 File Offset: 0x00081401
 private UserContextCookie(string cookieId, Canary canary, string mailboxUniqueKey)
 {
     this.cookieId         = cookieId;
     this.mailboxUniqueKey = mailboxUniqueKey;
     this.ContextCanary    = canary;
     this.cookieValue      = null;
 }
Example #3
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");
            }
        }
Example #4
0
 // Token: 0x0600164C RID: 5708 RVA: 0x00083282 File Offset: 0x00081482
 internal static UserContextCookie Create(string cookieId, Canary canary, string mailboxUniqueKey)
 {
     if (canary == null)
     {
         ExTraceGlobals.UserContextTracer.TraceDebug <string, string>(20L, "Canary == null, cookieId={0}, mailboxUniqueKey={1}", cookieId, mailboxUniqueKey);
         return(null);
     }
     return(new UserContextCookie(cookieId, canary, mailboxUniqueKey));
 }
Example #5
0
 // Token: 0x060007BC RID: 1980 RVA: 0x0003AA30 File Offset: 0x00038C30
 private static bool ParseCanary(string canaryString, out byte[] userContextIdBinary, out byte[] timeStampBinary, out byte[] hashBinary)
 {
     userContextIdBinary = null;
     timeStampBinary     = null;
     hashBinary          = null;
     if (string.IsNullOrEmpty(canaryString) || canaryString.Length != 76)
     {
         if (canaryString == null)
         {
             ExTraceGlobals.UserContextTracer.TraceDebug <string, string>(4L, "{0}.{1}: canaryString is null", "Owa.Core.Canary", "ParseCanary");
         }
         else
         {
             ExTraceGlobals.UserContextTracer.TraceDebug(4L, "{0}.{1}: canaryString.length={2}, CanaryStringLength={3}", new object[]
             {
                 "Owa.Core.Canary",
                 "ParseCanary",
                 canaryString.Length,
                 76
             });
         }
         return(false);
     }
     byte[] array;
     try
     {
         array = Canary.Decode(canaryString);
     }
     catch (FormatException ex)
     {
         if (ExTraceGlobals.UserContextTracer.IsTraceEnabled(TraceType.DebugTrace))
         {
             ExTraceGlobals.UserContextTracer.TraceDebug <string, string, string>(4L, "{0}.{1}: Format Exception: {2}", "Owa.Core.Canary", "ParseCanary", ex.ToString());
         }
         return(false);
     }
     if (array.Length != 56)
     {
         ExTraceGlobals.UserContextTracer.TraceDebug(4L, "{0}.{1}: canaryBinary.Length={2}!=CanaryBinaryLength={3}", new object[]
         {
             "Owa.Core.Canary",
             "ParseCanary",
             array.Length,
             56
         });
         return(false);
     }
     userContextIdBinary = new byte[16];
     timeStampBinary     = new byte[8];
     hashBinary          = new byte[32];
     Array.Copy(array, 0, userContextIdBinary, 0, 16);
     Array.Copy(array, 16, timeStampBinary, 0, 8);
     Array.Copy(array, 24, hashBinary, 0, 32);
     return(true);
 }
Example #6
0
 // Token: 0x060007AC RID: 1964 RVA: 0x0003A644 File Offset: 0x00038844
 private Canary(byte[] userContextIdBinary, byte[] timeStampBinary, string logonUniqueKey)
 {
     byte[] array  = Canary.ComputeHash(userContextIdBinary, timeStampBinary, logonUniqueKey);
     byte[] array2 = new byte[userContextIdBinary.Length + timeStampBinary.Length + array.Length];
     userContextIdBinary.CopyTo(array2, 0);
     timeStampBinary.CopyTo(array2, userContextIdBinary.Length);
     array.CopyTo(array2, userContextIdBinary.Length + timeStampBinary.Length);
     this.UserContextIdGuid = new Guid(userContextIdBinary);
     this.LogonUniqueKey    = logonUniqueKey;
     this.canaryString      = Canary.Encode(array2);
 }
Example #7
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));
        }
Example #8
0
 // Token: 0x060007B3 RID: 1971 RVA: 0x0003A708 File Offset: 0x00038908
 public static Canary RestoreCanary(string canaryString, string logonUniqueKey)
 {
     byte[] userContextIdBinary;
     byte[] timeStampBinary;
     byte[] array;
     if (Canary.ParseCanary(canaryString, out userContextIdBinary, out timeStampBinary, out array) && Canary.ValidateCanary(canaryString, logonUniqueKey))
     {
         return(new Canary(userContextIdBinary, timeStampBinary, logonUniqueKey));
     }
     ExTraceGlobals.UserContextTracer.TraceDebug <string, string, string>(5L, "{0}.RestoreCanary failed: logonUniqueKey={1}, canaryString={2}", "Owa.Core.Canary", logonUniqueKey, canaryString);
     return(null);
 }
Example #9
0
        // Token: 0x0600164A RID: 5706 RVA: 0x00083228 File Offset: 0x00081428
        internal UserContextCookie(string cookieId, string userContextId, string logonUniqueKey, string mailboxUniqueKey)
        {
            Guid userContextId2;

            if (!Guid.TryParse(userContextId, out userContextId2))
            {
                userContextId2 = Guid.NewGuid();
            }
            this.cookieId         = cookieId;
            this.mailboxUniqueKey = mailboxUniqueKey;
            this.ContextCanary    = new Canary(userContextId2, logonUniqueKey);
            this.cookieValue      = null;
        }
Example #10
0
 private UserContextKey(Canary canary, string mailboxUniqueKey)
 {
     this.Canary           = canary;
     this.mailboxUniqueKey = mailboxUniqueKey;
 }
Example #11
0
 private UserContextKey(Guid userContextId, string logonUniqueKey, string mailboxUniqueKey)
 {
     this.Canary           = new Canary(userContextId, logonUniqueKey);
     this.mailboxUniqueKey = mailboxUniqueKey;
 }
Example #12
0
 // Token: 0x060007B4 RID: 1972 RVA: 0x0003A74E File Offset: 0x0003894E
 public bool ValidateCanary(string canaryString)
 {
     return(Canary.ValidateCanary(canaryString, this.LogonUniqueKey));
 }
Example #13
0
        // Token: 0x060007AA RID: 1962 RVA: 0x0003A52C File Offset: 0x0003872C
        static Canary()
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 78, ".cctor", "f:\\15.00.1497\\sources\\dev\\clients\\src\\owa\\bin\\core\\Canary.cs");

            byte[] array  = ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest().ObjectGuid.ToByteArray();
            byte[] array2 = topologyConfigurationSession.GetDatabasesContainerId().ObjectGuid.ToByteArray();
            Canary.adObjectIdsBinary = new byte[array.Length + array2.Length];
            array.CopyTo(Canary.adObjectIdsBinary, 0);
            array2.CopyTo(Canary.adObjectIdsBinary, array.Length);
            if (ExTraceGlobals.UserContextTracer.IsTraceEnabled(TraceType.DebugTrace))
            {
                using (SHA256Cng sha256Cng = new SHA256Cng())
                {
                    byte[] bytes = sha256Cng.ComputeHash(Canary.adObjectIdsBinary);
                    ExTraceGlobals.UserContextTracer.TraceDebug <string, string>(2L, "{0}.Canary(): adObjectIdsBinaryHash={1}", "Owa.Core.Canary", Canary.GetHexString(bytes));
                    sha256Cng.Clear();
                }
            }
        }