Exemplo n.º 1
0
        // Token: 0x060004E9 RID: 1257 RVA: 0x0001B2AC File Offset: 0x000194AC
        private static string GetBackendFqdnFromE4eCookie(HttpRequest request, RequestDetailsLogger logger)
        {
            HttpCookie httpCookie = request.Cookies["X-E4eBackEnd"];

            if (httpCookie == null)
            {
                return(null);
            }
            string value = httpCookie.Value;

            if (string.IsNullOrEmpty(value))
            {
                logger.AppendGenericError("E4eBeCookieNullOrEmpty", "The E4E backend cookie hint was found but is null or empty.");
                return(null);
            }
            string[] array = httpCookie.Value.Split(new char[]
            {
                '~'
            });
            if (array.Length != 2)
            {
                logger.AppendGenericError("E4eBeCookieBadValue", string.Format("The E4E backend cookie hint was found but does not have expected value. Actual value [{0}]", value));
                return(null);
            }
            string value2           = array[0];
            string result           = array[1];
            string itemIdFromCookie = E4eProxyRequestHandler.GetItemIdFromCookie(request);

            if (string.IsNullOrEmpty(itemIdFromCookie) || !itemIdFromCookie.Equals(value2, StringComparison.OrdinalIgnoreCase))
            {
                logger.AppendGenericInfo("E4eBeCookieStale", string.Format("The E4E backend cookie hint was found but does not match current item id. Cookie value [{0}], current item ID [{1}]", value, itemIdFromCookie));
                return(null);
            }
            return(result);
        }
Exemplo n.º 2
0
        private void OnEndRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                LatencyTracker latencyTracker = LatencyTracker.FromHttpContext(httpContext);
                RequestDetailsLogger current  = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext);
                int traceContext = httpContext.GetTraceContext();
                if (HttpProxyGlobals.ProtocolType != ProtocolType.Mapi)
                {
                    OwaProxyRequestHandler.TryAddUnAuthenticatedPLTRequestPostDataToUriQueryOfIISLog(httpContext);
                }
                if (httpContext.Response != null && current != null)
                {
                    httpContext.Response.AppendToLog(Constants.RequestIdKeyForIISLogs + current.ActivityId.ToString() + ";");
                }
                if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext))
                {
                    return;
                }
                if (httpContext.Response.StatusCode == 404 && httpContext.Response.SubStatusCode == 13)
                {
                    httpContext.Response.StatusCode = 507;
                }
                if (Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; Username {2}; Context {3};", new object[]
                    {
                        httpContext.Request.HttpMethod,
                        httpContext.Request.Url,
                        (httpContext.User == null) ? string.Empty : httpContext.User.Identity.GetSafeName(true),
                        traceContext
                    });
                }
                if (latencyTracker != null)
                {
                    long currentLatency = latencyTracker.GetCurrentLatency(LatencyTrackerKey.HandlerToModuleSwitchingLatency);
                    if (currentLatency >= 0L)
                    {
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, HttpProxyMetadata.HandlerToModuleSwitchingLatency, currentLatency);
                    }
                }
                ProxyRequestHandler proxyRequestHandler = httpContext.CurrentHandler as ProxyRequestHandler;
                if (proxyRequestHandler != null && !proxyRequestHandler.IsDisposed)
                {
                    current.AppendGenericInfo("DisposeProxyRequestHandler", "ProxyModule::OnEndRequest");
                    proxyRequestHandler.Dispose();
                }
                string value = httpContext.Items["AnonymousRequestFilterModule"] as string;
                if (!string.IsNullOrEmpty(value))
                {
                    current.AppendGenericInfo("AnonymousRequestFilterModule", value);
                }
                try
                {
                    this.OnEndRequestInternal(httpApplication);
                }
                finally
                {
                    if (current != null && !current.IsDisposed)
                    {
                        IActivityScope activityScope = current.ActivityScope;
                        if (activityScope != null)
                        {
                            if (!string.IsNullOrEmpty(activityScope.TenantId))
                            {
                                httpContext.Items["AuthenticatedUserOrganization"] = activityScope.TenantId;
                            }
                            ProxyModule.FinalizeRequestLatencies(httpContext, current, activityScope, latencyTracker, traceContext);
                        }
                        current.LogCurrentTime("EndRequest");
                        current.AsyncCommit(false);
                    }
                    if (Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.TraceDebug(0L, "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; OnEndRequestLatency {2}; Context {3};", new object[]
                        {
                            httpContext.Request.HttpMethod,
                            httpContext.Request.Url,
                            (latencyTracker != null) ? latencyTracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency).ToString() : "Unknown",
                            traceContext
                        });
                    }
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }
Exemplo n.º 3
0
        // Token: 0x060005FB RID: 1531 RVA: 0x00021BD8 File Offset: 0x0001FDD8
        private void OnEndRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            CheckpointTracker.GetOrCreate(httpContext.Items).Add(FrontEndHttpProxyCheckpoints.ProxyModuleEndRequest);
            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                if (!HostHeaderValidator.HasValidHostHeaderStatusDescription(new HttpContextWrapper(httpContext).Response) || httpContext.Items["AutodiscoverRedirectModule"] != null)
                {
                    return;
                }
                LatencyTracker latencyTracker = LatencyTracker.FromHttpContext(httpContext);
                RequestDetailsLogger current  = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext), GuardedSharedCacheExecution.Default.Key, GuardedSharedCacheExecution.Default.Guard.GetCurrentValue());
                int traceContext = httpContext.GetTraceContext();
                if (httpContext.Response != null && current != null)
                {
                    httpContext.Response.AppendToLog(Constants.RequestIdKeyForIISLogs + current.ActivityId.ToString() + ";");
                }
                if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext))
                {
                    return;
                }
                if (httpContext.Response.StatusCode == 404 && httpContext.Response.SubStatusCode == 13)
                {
                    httpContext.Response.StatusCode = 507;
                }
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; Username {2}; Context {3};", new object[]
                    {
                        httpContext.Request.HttpMethod,
                        httpContext.Request.Url,
                        (httpContext.User == null) ? string.Empty : IIdentityExtensions.GetSafeName(httpContext.User.Identity, true),
                        traceContext
                    });
                }
                if (latencyTracker != null)
                {
                    long currentLatency = latencyTracker.GetCurrentLatency(LatencyTrackerKey.HandlerToModuleSwitchingLatency);
                    if (currentLatency >= 0L)
                    {
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, 5, currentLatency);
                    }
                }
                ProxyRequestHandler proxyRequestHandler = httpContext.CurrentHandler as ProxyRequestHandler;
                if (proxyRequestHandler != null && !proxyRequestHandler.IsDisposed)
                {
                    current.AppendGenericInfo("DisposeProxyRequestHandler", "ProxyModule::OnEndRequest");
                    proxyRequestHandler.Dispose();
                }
                ProxyModule.InspectNativeProxyFatalError(httpContext.Response, current);
                string text = httpContext.Items["AnonymousRequestFilterModule"] as string;
                if (!string.IsNullOrEmpty(text))
                {
                    current.AppendGenericInfo("AnonymousRequestFilterModule", text);
                }
                try
                {
                    this.OnEndRequestInternal(httpApplication);
                }
                finally
                {
                    if (current != null && !current.IsDisposed)
                    {
                        IActivityScope activityScope = current.ActivityScope;
                        if (activityScope != null)
                        {
                            if (!string.IsNullOrEmpty(activityScope.TenantId))
                            {
                                httpContext.Items["AuthenticatedUserOrganization"] = activityScope.TenantId;
                            }
                            ProxyModule.FinalizeRequestLatencies(httpContext, current, activityScope, latencyTracker, traceContext);
                        }
                        current.LogCurrentTime("EndRequest");
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, 0, DateTime.UtcNow);
                        current.AsyncCommit(false, NativeProxyHelper.WasProxiedByNativeProxyHandler(SharedHttpContextWrapper.GetWrapper(httpContext)));
                    }
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug(0L, "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; OnEndRequestLatency {2}; Context {3};", new object[]
                        {
                            httpContext.Request.HttpMethod,
                            httpContext.Request.Url,
                            (latencyTracker != null) ? latencyTracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency).ToString() : "Unknown",
                            traceContext
                        });
                    }
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }