Beispiel #1
0
        public void DisposePendingNotificationClientRequest()
        {
            IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(HttpContext.Current, null, false);
            HttpResponse    response       = HttpContext.Current.Response;
            object          parameter      = base.GetParameter("Fn");
            bool            flag           = false;

            if (parameter != null)
            {
                flag = (bool)parameter;
            }
            bool   flag2 = false;
            string text  = (string)base.GetParameter("cid");

            text = this.ProcessChannelIdOnRequestAndGenerateIfNeeded(text, flag);
            if (mailboxContext != null && text != null)
            {
                PendingRequestChannel pendingGetChannel = mailboxContext.PendingRequestManager.GetPendingGetChannel(text);
                if (pendingGetChannel != null)
                {
                    flag2 = pendingGetChannel.HandleFinishRequestFromClient();
                    if (flag)
                    {
                        ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "[PendingRequestEventHandler::DisposePendingNotificationClientRequest] userContext.PendingRequestManager.RemovePendingGetChannel. ChannelId: {0}", text);
                        mailboxContext.PendingRequestManager.RemovePendingGetChannel(text);
                    }
                }
                else
                {
                    mailboxContext.PendingRequestManager.AddPendingGetChannel(text);
                }
            }
            response.AppendHeader("X-OWA-EventResult", "0");
            response.Write("{");
            if (text != null)
            {
                response.Write("cid:\"");
                response.Write(text);
                response.Write("\",");
            }
            response.Write("syncFnshRq:");
            response.Write(flag2 ? "1}" : "0}");
            HttpUtilities.MakePageNoCacheNoStore(response);
            response.ContentType = HttpUtilities.GetContentTypeString(base.ResponseContentType);
        }
 private static DispatchStepResult DispatchIfLanguagePost(RequestContext requestContext)
 {
     ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DispatchIfLanguagePost] entry.");
     Canary15Cookie.CanaryValidationResult canaryValidationResult;
     if (requestContext.RequestType == OwaRequestType.LanguagePost && HttpUtilities.IsPostRequest(requestContext.HttpContext.Request) && Canary15Cookie.ValidateCanaryInHeaders(requestContext.HttpContext, OwaRequestHandler.GetOriginalIdentitySid(requestContext.HttpContext), Canary15Profile.Owa, out canaryValidationResult))
     {
         OwaDiagnostics.TracePfd(25865, "The request is a post from the language selection page, processing this request...", new object[0]);
         ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DispatchIfLanguagePost] Dispatching.");
         HttpRequest request = requestContext.HttpContext.Request;
         CultureInfo culture;
         string      timeZoneKeyName;
         bool        isOptimized;
         string      destination;
         RequestDispatcherUtilities.GetLanguagePostFormParameters(requestContext, request, out culture, out timeZoneKeyName, out isOptimized, out destination);
         ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DispatchIfLanguagePost] Dispatching language post request locally...");
         return(RequestDispatcher.HandleLanguagePost(requestContext, culture, timeZoneKeyName, isOptimized, destination));
     }
     return(DispatchStepResult.Continue);
 }
        private static void DoLogoffCleanup(RequestContext requestContext)
        {
            ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DoLogoff] entry.");
            HttpContext    httpContext = requestContext.HttpContext;
            UserContext    userContext = requestContext.UserContext as UserContext;
            UserContextKey key         = userContext.Key;

            try
            {
                ExTraceGlobals.UserContextTracer.TraceDebug <UserContext>(0L, "[RequestDispatcher::DoLogoffCleanup] Found user context in the cache, User context instance={0}.", userContext);
                userContext.State = UserContextState.MarkedForLogoff;
                userContext.LogBreadcrumb("MarkedForLogoff");
                userContext.DoLogoffCleanup();
                userContext.LogBreadcrumb("DoLogoffCleanup completed");
            }
            finally
            {
                UserContextCookie userContextCookie = UserContextCookie.GetUserContextCookie(requestContext.HttpContext);
                if (userContextCookie != null)
                {
                    HttpUtilities.DeleteCookie(httpContext.Response, userContextCookie.CookieName);
                }
                HttpUtilities.DeleteCookie(httpContext.Response, Canary15Profile.Owa.Name);
                if (key.UserContextId == null)
                {
                    string message = "User context id couldn't be retrieved. Logoff can't be performed";
                    ExTraceGlobals.UserContextTracer.TraceDebug(0L, message);
                    userContext.LogBreadcrumb(message);
                    userContext.Dispose();
                    userContext = null;
                }
                else
                {
                    userContext.LogBreadcrumb("Logoff invoking Cache.Remove");
                    object obj = HttpRuntime.Cache.Remove(key.ToString());
                    userContext.LogBreadcrumb("Logoff invoked Cache.Remove");
                    string message2 = (obj == null) ? "The userContext was already deleted from the cache" : "Context successfully deleted from the cache";
                    ExTraceGlobals.UserContextTracer.TraceDebug(0L, message2);
                    userContext.LogBreadcrumb(message2);
                }
            }
        }
 // Token: 0x06000D6B RID: 3435 RVA: 0x00032D30 File Offset: 0x00030F30
 internal ChunkedHttpResponse(HttpContext context)
 {
     this.Response = context.Response;
     HttpUtilities.MakePageNoCacheNoStore(this.Response);
     this.evalChunksNotSupportedByXmlhttpRequest = (HttpUtilities.GetQueryStringParameter(context.Request, "ecnsq", false) == "1");
     this.browserNameQueryParamValue             = HttpUtilities.GetQueryStringParameter(context.Request, "brwnm", false);
     this.userAgent = new UserAgent(context.Request.UserAgent, UserContextManager.GetUserContext(context).FeaturesManager.ClientServerSettings.ChangeLayout.Enabled, context.Request.Cookies);
     this.accountValidationContext = (context.Items["AccountValidationContext"] as IAccountValidationContext);
     this.Response.BufferOutput    = false;
     this.Response.Buffer          = false;
     this.Response.ContentType     = "text/html; charset=UTF-8";
     this.Response.AddHeader("Transfer-Encoding", "chunked");
     if ((string.Equals("iPhone", this.userAgent.Platform) || string.Equals("iPad", this.userAgent.Platform)) && ((this.userAgent.Browser == "Safari" && this.userAgent.BrowserVersion.Build > 5) || this.browserNameQueryParamValue == "safari"))
     {
         this.Response.AddHeader("X-FromBackEnd-ClientConnection", "close");
     }
     if (!this.evalChunksNotSupportedByXmlhttpRequest)
     {
         this.Response.TrySkipIisCustomErrors = true;
     }
     this.streamWriter = PendingRequestUtilities.CreateStreamWriter(this.Response.OutputStream);
     this.WriteFirstChunk();
 }
 // Token: 0x0600108E RID: 4238 RVA: 0x0003F720 File Offset: 0x0003D920
 public static void EndResponse(HttpContext httpContext, HttpStatusCode statusCode, HttpCacheability cacheability)
 {
     ExTraceGlobals.CoreCallTracer.TraceDebug <int>(0L, "HttpUtilities.EndResponse: statusCode={0}", (int)statusCode);
     if (httpContext == null)
     {
         throw new ArgumentNullException("httpContext");
     }
     if (cacheability == HttpCacheability.NoCache)
     {
         HttpUtilities.MakePageNoCacheNoStore(httpContext.Response);
     }
     httpContext.Response.StatusCode = (int)statusCode;
     try
     {
         httpContext.Response.Flush();
         httpContext.ApplicationInstance.CompleteRequest();
     }
     catch (HttpException arg)
     {
         ExTraceGlobals.CoreTracer.TraceDebug <HttpException>(0L, "Failed to flush and send response to client. {0}", arg);
     }
     httpContext.Response.End();
 }
 // Token: 0x06001159 RID: 4441 RVA: 0x000428F8 File Offset: 0x00040AF8
 internal override void ExecuteApplicationBeginRequest(object sender, EventArgs e)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();
             RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;
             getRequestDetailsLogger.ActivityScope.UpdateFromMessage(HttpContext.Current.Request);
             getRequestDetailsLogger.ActivityScope.SerializeTo(HttpContext.Current.Response);
             getRequestDetailsLogger.ActivityScope.SetProperty(OwaServerLogger.LoggerData.IsRequest, "1");
             string requestCorrelationId = HttpUtilities.GetRequestCorrelationId(HttpContext.Current);
             getRequestDetailsLogger.Set(OwaServerLogger.LoggerData.CorrelationId, requestCorrelationId);
             getRequestDetailsLogger.Set(OwaServerLogger.LoggerData.RequestStartTime, DateTime.UtcNow);
             HttpContext.Current.Response.AppendToLog("&ActID=" + getRequestDetailsLogger.ActivityId);
             HttpContext.Current.Response.AppendToLog("&CorrelationID=" + requestCorrelationId);
         });
     }
     catch (GrayException arg)
     {
         ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <GrayException>(0L, "OwaApplication.ExecuteApplicationBeginRequest: GrayException: {0}", arg);
         throw;
     }
 }
 internal static void DeleteUserSettingsCookie(RequestContext requestContext)
 {
     HttpUtilities.DeleteCookie(requestContext.HttpContext.Response, "UpdatedUserSettings");
 }
 public static bool IsChangePasswordLogoff(HttpRequest request)
 {
     return(HttpUtilities.GetQueryStringParameter(request, "ChgPwd", false) == "1");
 }
 // Token: 0x0600108D RID: 4237 RVA: 0x0003F714 File Offset: 0x0003D914
 public static void EndResponse(HttpContext httpContext, HttpStatusCode statusCode)
 {
     HttpUtilities.EndResponse(httpContext, statusCode, HttpCacheability.NoCache);
 }
 // Token: 0x0600108A RID: 4234 RVA: 0x0003F65E File Offset: 0x0003D85E
 public static string GetQueryStringParameter(HttpRequest httpRequest, string name)
 {
     return(HttpUtilities.GetQueryStringParameter(httpRequest, name, true));
 }
        // Token: 0x0600097E RID: 2430 RVA: 0x00020CF4 File Offset: 0x0001EEF4
        internal static void HandleException(RequestContext requestContext, Exception exception)
        {
            if (exception is HttpException && (exception.InnerException is SlabManifestException || exception.InnerException is FlightConfigurationException))
            {
                exception = exception.InnerException;
            }
            ErrorHandlerUtilities.RecordException(requestContext, exception);
            ExTraceGlobals.CoreTracer.TraceDebug <Type, Exception>(0L, "Exception: Type: {0} Error: {1}.", exception.GetType(), exception);
            HttpContext httpContext = requestContext.HttpContext;

            HttpUtilities.MakePageNoCacheNoStore(httpContext.Response);
            if (exception is HttpException)
            {
                HttpUtilities.EndResponse(httpContext, HttpStatusCode.BadRequest);
                return;
            }
            if (exception is OwaInvalidRequestException || exception is OwaInvalidIdFormatException)
            {
                HttpUtilities.EndResponse(httpContext, HttpStatusCode.BadRequest);
                return;
            }
            if (exception is MailboxInSiteFailoverException && requestContext.UserContext != null)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "User {0}'s mailbox in-site failover occurs.", requestContext.UserContext.ExchangePrincipal.LegacyDn);
                if (requestContext.UserContext != null)
                {
                    requestContext.UserContext.DisconnectMailboxSession();
                }
            }
            if (exception is MailboxCrossSiteFailoverException || exception is WrongServerException)
            {
                if (requestContext.UserContext != null)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "User {0}'s mailbox cross-site failover occurs.", requestContext.UserContext.ExchangePrincipal.LegacyDn);
                }
                UserContextCookie userContextCookie = UserContextCookie.GetUserContextCookie(httpContext);
                if (userContextCookie != null)
                {
                    HttpUtilities.DeleteCookie(httpContext.Response, userContextCookie.CookieName);
                }
            }
            if (exception is OverBudgetException)
            {
                OverBudgetException ex = (OverBudgetException)exception;
                httpContext.Response.AppendToLog(string.Format("&OverBudget({0}/{1}),Owner:{2}[{3}]", new object[]
                {
                    ex.IsServiceAccountBudget ? "ServiceAccount" : "Normal",
                    ex.PolicyPart,
                    ex.Owner,
                    ex.Snapshot
                }));
            }
            ErrorInformation exceptionHandlingInformation = ErrorHandlerUtilities.GetExceptionHandlingInformation(exception, requestContext);

            try
            {
                if (!requestContext.ErrorSent)
                {
                    requestContext.ErrorSent = true;
                    httpContext.Response.Clear();
                    try
                    {
                        if (RequestDispatcherUtilities.GetRequestType(httpContext.Request) != OwaRequestType.ServiceRequest && RequestDispatcherUtilities.GetRequestType(httpContext.Request) != OwaRequestType.Oeh && !httpContext.Request.Path.Contains(OwaUrl.SessionDataPage.ImplicitUrl))
                        {
                            StringBuilder stringBuilder = new StringBuilder("/owa/auth/errorfe.aspx");
                            stringBuilder.Append("?");
                            stringBuilder.Append("httpCode");
                            stringBuilder.Append("=");
                            stringBuilder.Append(500);
                            if (exceptionHandlingInformation.SharePointApp)
                            {
                                stringBuilder.Append("&sharepointapp=true");
                            }
                            if (exceptionHandlingInformation.SiteMailbox)
                            {
                                stringBuilder.Append("&sm=true");
                            }
                            if (exceptionHandlingInformation.GroupMailboxDestination != null)
                            {
                                stringBuilder.Append("&gm=");
                                stringBuilder.Append(HttpUtility.UrlEncode(exceptionHandlingInformation.GroupMailboxDestination));
                            }
                            if (exceptionHandlingInformation.MessageId != null)
                            {
                                stringBuilder.Append("&");
                                stringBuilder.Append("msg");
                                stringBuilder.Append("=");
                                stringBuilder.Append((long)exceptionHandlingInformation.MessageId.Value);
                                if (!string.IsNullOrWhiteSpace(exceptionHandlingInformation.MessageParameter))
                                {
                                    stringBuilder.Append("&");
                                    stringBuilder.Append("msgParam");
                                    stringBuilder.Append("=");
                                    stringBuilder.Append(HttpUtility.UrlEncode(exceptionHandlingInformation.MessageParameter));
                                }
                            }
                            if (!string.IsNullOrWhiteSpace(httpContext.Response.Headers["X-OWA-Error"]))
                            {
                                stringBuilder.Append("&owaError=");
                                stringBuilder.Append(httpContext.Response.Headers["X-OWA-Error"]);
                            }
                            stringBuilder.Append("&owaVer=");
                            stringBuilder.Append(Globals.ApplicationVersion);
                            stringBuilder.Append("&be=");
                            stringBuilder.Append(Environment.MachineName);
                            stringBuilder.Append("&ts=");
                            stringBuilder.Append(DateTime.UtcNow.ToFileTimeUtc());
                            if (!string.IsNullOrWhiteSpace(exceptionHandlingInformation.Lids))
                            {
                                httpContext.Response.AppendToLog(string.Format("&lids={0}", exceptionHandlingInformation.Lids));
                            }
                            if (exceptionHandlingInformation.SupportLevel != null && exceptionHandlingInformation.SupportLevel != SupportLevel.Unknown)
                            {
                                httpContext.Response.AppendHeader("X-OWASuppLevel", exceptionHandlingInformation.SupportLevel.ToString());
                                httpContext.Response.AppendToLog(string.Format("&{0}={1}", "suplvl", exceptionHandlingInformation.SupportLevel.ToString()));
                            }
                            httpContext.Response.Redirect(stringBuilder.ToString(), false);
                        }
                        else
                        {
                            httpContext.Response.Write(exceptionHandlingInformation.Message);
                            httpContext.Response.StatusCode = 500;
                            if (exceptionHandlingInformation.MessageId != null)
                            {
                                httpContext.Response.AddHeader(WellKnownHeader.XOWAErrorMessageID, exceptionHandlingInformation.MessageId.ToString());
                            }
                            httpContext.Response.TrySkipIisCustomErrors = true;
                            httpContext.Response.Flush();
                        }
                        httpContext.ApplicationInstance.CompleteRequest();
                    }
                    catch (HttpException arg)
                    {
                        ExTraceGlobals.CoreTracer.TraceDebug <HttpException>(0L, "Failed to flush and send response to client after submitting watson and rendering error page. {0}", arg);
                    }
                }
            }
            finally
            {
                if (exceptionHandlingInformation.SendWatsonReport && Globals.SendWatsonReports)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug(0L, "Sending watson report");
                    ReportOptions options = (exception is AccessViolationException || exception is InvalidProgramException || exception is TypeInitializationException) ? ReportOptions.ReportTerminateAfterSend : ReportOptions.None;
                    ExWatson.SendReport(exception, options, null);
                }
                if (exception is AccessViolationException)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug(0L, "Shutting down OWA due to unrecoverable exception");
                    ErrorHandlerUtilities.TerminateProcess();
                }
                else if ((exception is InvalidProgramException || exception is TypeInitializationException) && Interlocked.Exchange(ref ErrorHandlerUtilities.queuedDelayedRestart, 1) == 0)
                {
                    new Thread(new ThreadStart(ErrorHandlerUtilities.DelayedRestartUponUnexecutableCode)).Start();
                }
                httpContext.Response.End();
            }
        }