Пример #1
0
        public Canary15(string logonUniqueKey)
        {
            byte[] userContextIdBinary = Guid.NewGuid().ToByteArray();
            byte[] bytes = BitConverter.GetBytes(DateTime.UtcNow.Ticks);
            long   keyIndex;
            int    segmentIndex;

            byte[] hashBinary = Canary15DataManager.ComputeHash(userContextIdBinary, bytes, logonUniqueKey, out keyIndex, out segmentIndex);
            this.Init(userContextIdBinary, bytes, logonUniqueKey, hashBinary, Canary15.FormatLogData(keyIndex, segmentIndex));
            this.IsRenewed       = true;
            this.IsAboutToExpire = false;
        }
Пример #2
0
 public static Canary15 RestoreCanary15(string canaryString, string logonUniqueKey)
 {
     byte[] userContextIdBinary;
     byte[] array;
     byte[] array2;
     if (Canary15.ParseCanary15(canaryString, out userContextIdBinary, out array, out array2))
     {
         if (Canary15.IsExpired(array))
         {
             ExTraceGlobals.CoreTracer.TraceDebug <string>(5L, "Canary is expired, timeStampBinary={0}", Canary15.GetHexString(array));
             return(null);
         }
         long   keyIndex;
         int    segmentIndex;
         byte[] array3 = Canary15DataManager.ComputeHash(userContextIdBinary, array, logonUniqueKey, out keyIndex, out segmentIndex);
         if (Canary15.AreEqual(array3, array2))
         {
             return(new Canary15(userContextIdBinary, array, logonUniqueKey, array2, Canary15.FormatLogData(keyIndex, segmentIndex)));
         }
         ExTraceGlobals.CoreTracer.TraceDebug <string, string>(5L, "testHashBinary={0}!=hashBinary={1}", Canary15.GetHexString(array3), Canary15.GetHexString(array2));
     }
     ExTraceGlobals.CoreTracer.TraceDebug <string, string>(5L, "RestoreCanary failed, logonUniqueKey={0}, canaryString={1}", logonUniqueKey, canaryString);
     return(null);
 }