Beispiel #1
0
        private void ValidateAllCookiebjectsAreNotRemoved(IEnumerable <ForwardSyncCookieHeader> cookies)
        {
            ForwardSyncCookieHeader forwardSyncCookieHeader = cookies.FirstOrDefault <ForwardSyncCookieHeader>();

            if (forwardSyncCookieHeader != null && this.dateTimeNow < new DateTime(forwardSyncCookieHeader.Timestamp.Ticks + this.rollbackTimeSpan.Ticks, DateTimeKind.Utc))
            {
                base.WriteError(new InvalidUserInputException(Strings.ErrorCannotRemoveAllCookies(this.rollbackTimeSpan.ToString())), ExchangeErrorCategory.Client, null);
            }
        }
Beispiel #2
0
 public ForwardSyncCookie ReadMostRecentCookie()
 {
     if (this.mostRecentCookie == null && this.cookieHeaderList.Count > 0)
     {
         ForwardSyncCookieHeader forwardSyncCookieHeader = this.cookieHeaderList.Last <ForwardSyncCookieHeader>();
         this.mostRecentCookie           = this.cookieSession.Read <ForwardSyncCookie>(forwardSyncCookieHeader.Id);
         this.lastNewCookieTimestamp     = this.mostRecentCookie.Timestamp;
         base.SyncPropertySetVersion     = new ServerVersion(this.mostRecentCookie.SyncPropertySetVersion);
         base.IsSyncPropertySetUpgrading = this.mostRecentCookie.IsUpgradingSyncPropertySet;
     }
     return(this.mostRecentCookie);
 }
Beispiel #3
0
        public override void WriteCookie(byte[] cookie, IEnumerable <string> filteredContextIds, DateTime timestamp, bool isUpgradingCookie, ServerVersion version, bool more)
        {
            if (cookie == null || cookie.Length == 0)
            {
                throw new ArgumentNullException("cookie");
            }
            base.UpdateSyncPropertySetVersion(isUpgradingCookie, version, more);
            ForwardSyncCookie forwardSyncCookie = this.ReadMostRecentCookie();
            bool flag  = forwardSyncCookie == null || timestamp.Subtract(this.lastNewCookieTimestamp) >= this.cookieHistoryInterval;
            bool flag2 = false;

            if (flag)
            {
                if (this.cookieHeaderList.Count > this.maxCookieHistoryCount)
                {
                    this.CleanupOldCookies();
                }
                else
                {
                    flag2 = (this.cookieHeaderList.Count < this.maxCookieHistoryCount);
                }
                forwardSyncCookie = new ForwardSyncCookie();
                if (flag2)
                {
                    string unescapedCommonName = string.Format("{0}-{1}", Enum.GetName(typeof(ForwardSyncCookieType), this.cookieType), timestamp.Ticks);
                    forwardSyncCookie.SetId(this.cookieRootContainer.GetChildId(unescapedCommonName));
                }
                else
                {
                    forwardSyncCookie.SetId(this.cookieHeaderList.First <ForwardSyncCookieHeader>().Id);
                    forwardSyncCookie.Name      = forwardSyncCookie.Id.Name;
                    forwardSyncCookie.m_Session = this.cookieSession;
                    forwardSyncCookie.ResetChangeTracking(true);
                }
                forwardSyncCookie.Type    = this.cookieType;
                forwardSyncCookie.Version = 1;
            }
            forwardSyncCookie.Timestamp = timestamp;
            forwardSyncCookie.Data      = cookie;
            if (filteredContextIds != null)
            {
                forwardSyncCookie.FilteredContextIds = new MultiValuedProperty <string>(filteredContextIds);
            }
            forwardSyncCookie.IsUpgradingSyncPropertySet = base.IsSyncPropertySetUpgrading;
            forwardSyncCookie.SyncPropertySetVersion     = base.SyncPropertySetVersion.ToInt();
            this.cookieSession.Save(forwardSyncCookie);
            this.mostRecentCookie = forwardSyncCookie;
            if (flag)
            {
                ForwardSyncCookieHeader forwardSyncCookieHeader = new ForwardSyncCookieHeader
                {
                    Name      = forwardSyncCookie.Name,
                    Timestamp = forwardSyncCookie.Timestamp
                };
                forwardSyncCookieHeader.SetId(forwardSyncCookie.Id);
                this.cookieHeaderList.Add(forwardSyncCookieHeader);
                this.lastNewCookieTimestamp = timestamp;
                if (!flag2)
                {
                    this.cookieHeaderList.RemoveAt(0);
                }
            }
        }