private void SetBackEndCookie() { if (this.haveSetBackEndCookie) { return; } foreach (string text in this.BackEndCookieNames) { if (this.ShouldProcessBackEndCookie(text)) { HttpCookie httpCookie = base.ClientRequest.Cookies[text]; if (httpCookie == null) { ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SetBackEndCookie]: Context {0}; Client request does not include back end cookie.", base.TraceContext); httpCookie = new HttpCookie(text); } httpCookie.HttpOnly = true; httpCookie.Secure = base.ClientRequest.IsSecureConnection; httpCookie.Path = this.GetCookiePath(); if (base.AnchoredRoutingTarget != null) { string text2 = base.AnchoredRoutingTarget.AnchorMailbox.ToCookieKey(); BackEndCookieEntryBase backEndCookieEntryBase = base.AnchoredRoutingTarget.AnchorMailbox.BuildCookieEntryForTarget(base.AnchoredRoutingTarget.BackEndServer, base.ProxyToDownLevel, this.ShouldBackEndCookieHaveResourceForest(text)); if (backEndCookieEntryBase != null) { httpCookie.Values[text2] = backEndCookieEntryBase.ToObscureString(); ExTraceGlobals.VerboseTracer.TraceDebug <int, string, BackEndCookieEntryBase>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SetBackEndCookie]: Context {0}; Setting cookie entry {1}={2}.", base.TraceContext, text2, backEndCookieEntryBase); } } this.SanitizeCookie(httpCookie); base.ClientResponse.Cookies.Add(httpCookie); this.haveSetBackEndCookie = true; } } }
// Token: 0x06000280 RID: 640 RVA: 0x0000CDE8 File Offset: 0x0000AFE8 public static BackEndCookieEntryBase Parse(string entryValue) { BackEndCookieEntryBase result = null; if (!BackEndCookieEntryParser.TryParse(entryValue, out result)) { throw new InvalidBackEndCookieException(); } return(result); }
// Token: 0x060004C7 RID: 1223 RVA: 0x0001A630 File Offset: 0x00018830 private void SanitizeCookie(HttpCookie backEndCookie) { if (backEndCookie == null) { return; } if (this.removeBackEndCookieEntry && base.AnchoredRoutingTarget != null) { string text = base.AnchoredRoutingTarget.AnchorMailbox.ToCookieKey(); backEndCookie.Values.Remove(text); if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SanitizeCookie]: Context {0}; Removed cookie entry with key {1}.", base.TraceContext, text); } } ExDateTime exDateTime = ExDateTime.UtcNow.AddYears(-30); int num = 0; for (int i = backEndCookie.Values.Count - 1; i >= 0; i--) { bool flag = true; BackEndCookieEntryBase backEndCookieEntryBase = null; if (num < this.MaxBackEndCookieEntries && BackEndCookieEntryParser.TryParse(backEndCookie.Values[i], out backEndCookieEntryBase)) { flag = backEndCookieEntryBase.Expired; if (!flag && this.removeBackEndCookieEntry && base.AnchoredRoutingTarget != null && backEndCookieEntryBase.ShouldInvalidate(base.AnchoredRoutingTarget.BackEndServer)) { flag = true; } } if (flag) { string key = backEndCookie.Values.GetKey(i); backEndCookie.Values.Remove(key); if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SanitizeCookie]: Context {0}; Removed cookie entry with key {1}.", base.TraceContext, key); } } else { num++; if (backEndCookieEntryBase.ExpiryTime > exDateTime) { exDateTime = backEndCookieEntryBase.ExpiryTime; } } } if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::SanitizeCookie]: Context {0}; {1}", base.TraceContext, (num == 0) ? "Marking current cookie as expired." : "Extending cookie expiration."); } backEndCookie.Expires = exDateTime.UniversalTime; }
protected virtual BackEndServer TryGetBackEndFromCookie(BackEndCookieEntryBase cookieEntry) { BackEndServerCookieEntry backEndServerCookieEntry = cookieEntry as BackEndServerCookieEntry; if (backEndServerCookieEntry != null) { ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[AnchorMailbox::TryGetBackEndFromCookie]: BackEndServerCookier {0}", backEndServerCookieEntry.ToString()); return(new BackEndServer(backEndServerCookieEntry.Fqdn, backEndServerCookieEntry.Version)); } ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[AnchorMailbox::TryGetBackEndFromCookie]: No BackEndServerCookie"); return(null); }
// Token: 0x0600028B RID: 651 RVA: 0x0000D0C0 File Offset: 0x0000B2C0 public override string ToString() { return(string.Concat(new string[] { BackEndCookieEntryBase.ConvertBackEndCookieEntryTypeToString(base.EntryType), "~", this.Database.ToString(), "~", this.Domain, "~", base.ExpiryTime.ToString("s") })); }
// Token: 0x060000CC RID: 204 RVA: 0x00005010 File Offset: 0x00003210 public virtual BackEndServer AcceptBackEndCookie(HttpCookie backEndCookie) { if (backEndCookie == null) { throw new ArgumentNullException("backEndCookie"); } string name = this.ToCookieKey(); string text = backEndCookie.Values[name]; BackEndServer backEndServer = null; if (!string.IsNullOrEmpty(text)) { try { BackEndCookieEntryBase backEndCookieEntryBase; string text2; if (!BackEndCookieEntryParser.TryParse(text, out backEndCookieEntryBase, out text2)) { throw new InvalidBackEndCookieException(); } if (backEndCookieEntryBase.Expired) { if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <BackEndCookieEntryBase>((long)this.GetHashCode(), "[AnchorMailbox::ProcessBackEndCookie]: Back end cookie entry {0} has expired.", backEndCookieEntryBase); } this.RequestContext.Logger.SafeSet(4, string.Format("Expired~{0}", text2)); throw new InvalidBackEndCookieException(); } this.RequestContext.Logger.SafeSet(4, text2); this.IncomingCookieEntry = backEndCookieEntryBase; this.CacheEntryCacheHit = true; PerfCounters.HttpProxyCacheCountersInstance.CookieUseRate.Increment(); PerfCounters.UpdateMovingPercentagePerformanceCounter(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageCookieUseRate); backEndServer = this.TryGetBackEndFromCookie(this.IncomingCookieEntry); if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <BackEndServer, BackEndCookieEntryBase>((long)this.GetHashCode(), "[AnchorMailbox::ProcessBackEndCookie]: Back end server {0} resolved from cookie {1}.", backEndServer, this.IncomingCookieEntry); } } catch (InvalidBackEndCookieException) { if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[AnchorMailbox::ProcessBackEndCookie]: Invalid back end cookie entry."); } backEndCookie.Values.Remove(name); } } return(backEndServer); }
// Token: 0x06000282 RID: 642 RVA: 0x0000CE20 File Offset: 0x0000B020 public static bool TryParse(string entryValue, out BackEndCookieEntryBase cookieEntry, out string clearCookie) { cookieEntry = null; clearCookie = null; if (string.IsNullOrEmpty(entryValue)) { return(false); } bool result; try { string text = BackEndCookieEntryParser.UnObscurify(entryValue); clearCookie = text; string[] array = StringExtensions.SplitFast(text, '~', int.MaxValue, StringSplitOptions.None); if (array.Length < 4) { result = false; } else { BackEndCookieEntryType backEndCookieEntryType; if (!BackEndCookieEntryBase.TryGetBackEndCookieEntryTypeFromString(array[0], out backEndCookieEntryType)) { backEndCookieEntryType = (BackEndCookieEntryType)Enum.Parse(typeof(BackEndCookieEntryType), array[0], true); } ExDateTime expiryTime; if (!BackEndCookieEntryParser.TryParseDateTime(array[3], out expiryTime)) { result = false; } else if (backEndCookieEntryType != BackEndCookieEntryType.Server) { if (backEndCookieEntryType == BackEndCookieEntryType.Database) { Guid database = new Guid(array[1]); string text2 = string.IsNullOrEmpty(array[2]) ? null : array[2]; string resourceForest = (array.Length < 5 || string.IsNullOrEmpty(array[4])) ? null : array[4]; if (array.Length >= 6) { bool isOrganizationMailboxDatabase = string.Equals(array[5], 1.ToString(), StringComparison.OrdinalIgnoreCase); cookieEntry = new BackEndDatabaseOrganizationAwareCookieEntry(database, text2, resourceForest, expiryTime, isOrganizationMailboxDatabase); } else if (array.Length == 5) { cookieEntry = new BackEndDatabaseResourceForestCookieEntry(database, text2, resourceForest, expiryTime); } else { cookieEntry = new BackEndDatabaseCookieEntry(database, text2, expiryTime); } result = true; } else { result = false; } } else { cookieEntry = new BackEndServerCookieEntry(array[1], int.Parse(array[2]), expiryTime); result = true; } } } catch (ArgumentException) { result = false; } catch (FormatException) { result = false; } return(result); }
// Token: 0x06000281 RID: 641 RVA: 0x0000CE08 File Offset: 0x0000B008 public static bool TryParse(string entryValue, out BackEndCookieEntryBase cookieEntry) { string text = null; return(BackEndCookieEntryParser.TryParse(entryValue, out cookieEntry, out text)); }
// Token: 0x0600027A RID: 634 RVA: 0x0000CC94 File Offset: 0x0000AE94 public string ToObscureString() { return(BackEndCookieEntryBase.Obscurify(this.ToString())); }
public static bool TryParse(string entryValue, out BackEndCookieEntryBase cookieEntry, out string clearCookie) { cookieEntry = null; clearCookie = null; if (string.IsNullOrEmpty(entryValue)) { return(false); } bool result; try { string text = BackEndCookieEntryParser.UnObscurify(entryValue); clearCookie = text; string[] array = text.Split(BackEndCookieEntryParser.CookieSeparators); if (array.Length < 4) { result = false; } else { BackEndCookieEntryType backEndCookieEntryType; if (!BackEndCookieEntryBase.TryGetBackEndCookieEntryTypeFromString(array[0], out backEndCookieEntryType)) { backEndCookieEntryType = (BackEndCookieEntryType)Enum.Parse(typeof(BackEndCookieEntryType), array[0], true); } ExDateTime expiryTime; if (!BackEndCookieEntryParser.TryParseDateTime(array[3], out expiryTime)) { result = false; } else { switch (backEndCookieEntryType) { case BackEndCookieEntryType.Server: cookieEntry = new BackEndServerCookieEntry(array[1], int.Parse(array[2]), expiryTime); result = true; break; case BackEndCookieEntryType.Database: { Guid database = new Guid(array[1]); string text2 = string.IsNullOrEmpty(array[2]) ? null : array[2]; if (array.Length == 5) { string resourceForest = string.IsNullOrEmpty(array[4]) ? null : array[4]; cookieEntry = new BackEndDatabaseResourceForestCookieEntry(database, text2, resourceForest, expiryTime); } else { cookieEntry = new BackEndDatabaseCookieEntry(database, text2, expiryTime); } result = true; break; } default: result = false; break; } } } } catch (ArgumentException) { result = false; } catch (FormatException) { result = false; } return(result); }