public static void DispatchRequest(RequestContext requestContext) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DispatchRequest] entry."); HttpContext httpContext = requestContext.HttpContext; UrlUtilities.RewriteFederatedDomainInURL(httpContext); DispatchStepResult arg = RequestDispatcher.InternalDispatchRequest(requestContext); ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::DispatchRequest] Last dispatch step result={0}.", arg); switch (arg) { case DispatchStepResult.RedirectToUrl: ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "[RequestDispatcher::DispatchRequest] Redirecting response to '{0}'.", requestContext.DestinationUrl); httpContext.Response.Redirect(requestContext.DestinationUrl, false); if (requestContext.RequestType != OwaRequestType.Logoff || !RequestDispatcherUtilities.IsDownLevelClient(requestContext.HttpContext, false)) { httpContext.ApplicationInstance.CompleteRequest(); } return; case DispatchStepResult.RewritePath: ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "[RequestDispatcher::DispatchRequest] Rewriting path to '{0}'.", requestContext.DestinationUrl); if (string.IsNullOrEmpty(requestContext.DestinationUrlQueryString)) { httpContext.RewritePath(requestContext.DestinationUrl); return; } httpContext.RewritePath(requestContext.DestinationUrl, null, requestContext.DestinationUrlQueryString); break; case DispatchStepResult.RewritePathToError: case DispatchStepResult.Continue: break; case DispatchStepResult.EndResponse: ExTraceGlobals.CoreCallTracer.TraceDebug <int>(0L, "[RequestDispatcher::DispatchRequest] Ending response with statusCode={0}.", (int)requestContext.HttpStatusCode); HttpUtilities.EndResponse(requestContext.HttpContext, requestContext.HttpStatusCode); return; case DispatchStepResult.EndResponseWithPrivateCaching: ExTraceGlobals.CoreCallTracer.TraceDebug <int>(0L, "[RequestDispatcher::DispatchRequest] Ending response with statusCode={0} and PRIVATE cacheability.", (int)requestContext.HttpStatusCode); HttpUtilities.EndResponse(requestContext.HttpContext, requestContext.HttpStatusCode, HttpCacheability.Private); return; case DispatchStepResult.Stop: ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DispatchRequest] Stopped the dispatching of this request."); return; default: return; } }
// Token: 0x0600073B RID: 1851 RVA: 0x000166E8 File Offset: 0x000148E8 private static string GetLayoutString(HttpContext context) { if (RequestDispatcherUtilities.GetStringUrlParameter(context, "sharepointapp") == "true") { return("mouse"); } string text = RequestDispatcherUtilities.GetStringUrlParameter(context, "layout"); if (string.IsNullOrEmpty(text)) { text = OwaUserAgentUtilities.GetAppCacheManiestLayoutCookieValue(context); } return(text); }
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); }
internal static string GetDestinationForRedirectToLanguagePage(RequestContext requestContext) { string text = OwaUrl.LanguagePage.GetExplicitUrl(requestContext.HttpContext.Request); if (!string.IsNullOrEmpty(requestContext.DestinationUrlQueryString)) { text += string.Concat(new string[] { "?", RequestDispatcherUtilities.GetRequestQueryStringLcidParams(requestContext.HttpContext.Request), "url", "=", OwaUrl.ApplicationRoot.GetExplicitUrl(requestContext.HttpContext.Request), "?", HttpUtility.UrlEncode(requestContext.DestinationUrlQueryString) }); } return(text); }
internal static bool TryReadMowaGlobalizationSettings(RequestContext requestContext, out CultureInfo culture, out string timeZoneKeyName) { string text = requestContext.HttpContext.Request.QueryString["MOWALanguageID"]; string text2 = requestContext.HttpContext.Request.QueryString["MOWATimeZoneID"]; culture = null; timeZoneKeyName = null; if (string.IsNullOrEmpty(text)) { HttpCookie httpCookie = requestContext.HttpContext.Request.Cookies["MOWALanguageID"]; if (httpCookie != null) { text = httpCookie.Value; } } if (string.IsNullOrEmpty(text2)) { HttpCookie httpCookie2 = requestContext.HttpContext.Request.Cookies["MOWATimeZoneID"]; if (httpCookie2 != null) { text2 = httpCookie2.Value; } } if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2)) { return(false); } try { culture = new CultureInfo(text); if (!ClientCultures.IsSupportedCulture(culture)) { return(false); } } catch (CultureNotFoundException arg) { ExTraceGlobals.CoreCallTracer.TraceDebug <string, CultureNotFoundException>(0L, "The language passed in by MOWA is invalid, language={0}, exception: {1}", text, arg); return(false); } timeZoneKeyName = text2; return(!string.IsNullOrEmpty(timeZoneKeyName) && RequestDispatcherUtilities.IsValidTimeZoneKeyName(timeZoneKeyName)); }
private static DispatchStepResult DispatchIfLogoffRequest(RequestContext requestContext) { if (requestContext.RequestType != OwaRequestType.Logoff) { return(DispatchStepResult.Continue); } ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DispatchIfLogoffRequest] entry."); OwaDiagnostics.TracePfd(21769, "Dispatching logoff request.", new object[0]); requestContext.UserContext = UserContextManager.GetUserContext(requestContext.HttpContext, false); if (requestContext.UserContext != null) { RequestDispatcher.DoLogoffCleanup(requestContext); } if (RequestDispatcherUtilities.IsChangePasswordLogoff(requestContext.HttpContext.Request)) { requestContext.DestinationUrl = OwaUrl.LogoffChangePasswordPage.GetExplicitUrl(requestContext.HttpContext.Request); } else { requestContext.DestinationUrl = RequestDispatcher.GetLogoffURL(requestContext); } return(DispatchStepResult.RedirectToUrl); }
private static DispatchStepResult DoFinalDispatch(RequestContext requestContext) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DoFinalDispatch] entry."); if (requestContext.RequestType == OwaRequestType.ProxyLogon) { ExTraceGlobals.CoreCallTracer.TraceDebug <int>(0L, "[RequestDispatcher::DoFinalDispatch] Proxy logon request. Ending with status code {0}.", 241); requestContext.HttpStatusCode = (HttpStatusCode)241; return(DispatchStepResult.EndResponse); } if (requestContext.RequestType == OwaRequestType.LanguagePost) { if (requestContext.FailedToSaveUserCulture) { requestContext.DestinationUrl = OwaUrl.InfoFailedToSaveCulture.GetExplicitUrl(requestContext.HttpContext.Request); } else if (string.IsNullOrEmpty(requestContext.DestinationUrl)) { requestContext.DestinationUrl = OwaUrl.ApplicationRoot.GetExplicitUrl(requestContext.HttpContext.Request); } ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "[RequestDispatcher::DoFinalDispatch] language post request. Redirecting to '{0}' url.", requestContext.DestinationUrl ?? "<NULL>"); return(DispatchStepResult.RedirectToUrl); } if (requestContext.RequestType == OwaRequestType.KeepAlive) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DoFinalDispatch] processing keep alive request."); requestContext.HttpStatusCode = HttpStatusCode.OK; return(DispatchStepResult.EndResponse); } if (requestContext.RequestType == OwaRequestType.Form15 && !RequestDispatcherUtilities.IsDownLevelClient(requestContext.HttpContext, false)) { ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "[RequestDispatcher::DoFinalDispatch] rewriting path to '{0}'.", OwaUrl.Default15Page.ImplicitUrl); requestContext.DestinationUrl = OwaUrl.Default15Page.ImplicitUrl; return(DispatchStepResult.RewritePath); } ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::DoFinalDispatch] continue to the next handler."); return(DispatchStepResult.Continue); }
private static void InternalOnPostAuthorizeRequest(object sender) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] entry."); RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger; SubActivityScopeLogger subActivityScopeLogger = SubActivityScopeLogger.Create(getRequestDetailsLogger, OwaServerLogger.LoggerData.OnPostAuthorizeRequestLatencyDetails); HttpApplication httpApplication = (HttpApplication)sender; HttpContext context = httpApplication.Context; if (!context.Request.IsAuthenticated && (context.Request.Url.LocalPath.EndsWith("service.svc", StringComparison.OrdinalIgnoreCase) || context.Request.Url.LocalPath.EndsWith("Speech.reco", StringComparison.OrdinalIgnoreCase))) { ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] unauthorized request. Request URL={0}.", context.Request.Url.OriginalString); context.Response.StatusCode = 401; httpApplication.CompleteRequest(); return; } RequestContext requestContext = RequestContext.Get(httpApplication.Context); subActivityScopeLogger.LogNext("a"); RequestDispatcher.DispatchRequest(requestContext); subActivityScopeLogger.LogNext("b"); OwaRequestType requestType = requestContext.RequestType; RequestDispatcherUtilities.SetXFrameOptionsHeader(RequestContext.Current, requestType); subActivityScopeLogger.LogNext("c"); if (context.User != null && context.User.Identity != null) { if (context.User.Identity is ClientSecurityContextIdentity) { IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(context, null, false); subActivityScopeLogger.LogNext("d"); if (OwaRequestHandler.IsProxyLogonRequest(requestType)) { ExTraceGlobals.CoreCallTracer.TraceDebug <OwaRequestType>(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] proxy logon request. RequestType={0}", requestType); return; } RequestDetailsLogger.LogEvent(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryValidationBegin); bool flag = OwaRequestHandler.IsRequestWithCanary(context.Request, requestType, context.Request.IsAuthenticated); bool flag2 = OwaRequestHandler.IsAfterLogonRequest(context.Request); string originalIdentitySid = OwaRequestHandler.GetOriginalIdentitySid(context); CanaryLogEvent.CanaryStatus canaryStatus = CanaryLogEvent.CanaryStatus.None; bool flag3 = !flag || flag2; if (!flag3) { Canary15Cookie.CanaryValidationResult canaryValidationResult; flag3 = Canary15Cookie.ValidateCanaryInHeaders(context, originalIdentitySid, Canary15Profile.Owa, out canaryValidationResult); canaryStatus |= (CanaryLogEvent.CanaryStatus)canaryValidationResult; } OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, flag, CanaryLogEvent.CanaryStatus.IsCanaryNeeded); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, flag3, CanaryLogEvent.CanaryStatus.IsCanaryValid); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, flag2, CanaryLogEvent.CanaryStatus.IsCanaryAfterLogonRequest); Canary15Cookie canary15Cookie = Canary15Cookie.TryCreateFromHttpContext(context, originalIdentitySid, Canary15Profile.Owa); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, canary15Cookie.IsAboutToExpire, CanaryLogEvent.CanaryStatus.IsCanaryAboutToExpire); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, canary15Cookie.IsRenewed, CanaryLogEvent.CanaryStatus.IsCanaryRenewed); subActivityScopeLogger.LogNext("e"); bool flag4 = flag || canary15Cookie.IsAboutToExpire; if (flag4) { canary15Cookie = new Canary15Cookie(originalIdentitySid, Canary15Profile.Owa); } if (canary15Cookie.IsRenewed || flag4) { context.Response.SetCookie(canary15Cookie.HttpCookie); CanaryLogEvent logEvent = new CanaryLogEvent(context, mailboxContext, canaryStatus, canary15Cookie.CreationTime, canary15Cookie.LogData); OwaServerLogger.AppendToLog(logEvent); subActivityScopeLogger.LogNext("f"); } if (flag3) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryCreationTime, canary15Cookie.CreationTime); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryLogData, canary15Cookie.LogData); subActivityScopeLogger.LogNext("g"); } else { if (RequestDispatcherUtilities.IsDownLevelClient(context, false)) { throw new OwaCanaryException(Canary15Profile.Owa.Name, canary15Cookie.Value); } context.Response.StatusCode = 449; context.Response.End(); } RequestDetailsLoggerBase <RequestDetailsLogger> requestDetailsLogger = getRequestDetailsLogger; Enum key = OwaServerLogger.LoggerData.CanaryStatus; int num = (int)canaryStatus; RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, key, num.ToString("X")); RequestDetailsLogger.LogEvent(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryValidationEnd); subActivityScopeLogger.LogEnd(); return; } } else { ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] httpContext.User or httpContext.User.Identity is <NULL>."); } }
// Token: 0x060011C6 RID: 4550 RVA: 0x00044898 File Offset: 0x00042A98 private void OnError(object sender, EventArgs e) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "OwaModule.OnError"); HttpApplication httpApplication = (HttpApplication)sender; Exception lastError = httpApplication.Server.GetLastError(); if (lastError == null) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "GetLastError returned null. Bailing out."); return; } RequestContext requestContext = RequestContext.Current; if (requestContext.RequestType == OwaRequestType.Invalid) { requestContext.RequestType = RequestDispatcherUtilities.GetRequestType(requestContext.HttpContext.Request); } if (!RequestDispatcherUtilities.IsDownLevelClient(requestContext.HttpContext, true) && (RequestDispatcherUtilities.IsPremiumRequest(requestContext.HttpContext.Request) || requestContext.RequestType == OwaRequestType.Form15 || requestContext.RequestType == OwaRequestType.LanguagePost)) { httpApplication.Server.ClearError(); ErrorHandlerUtilities.HandleException(requestContext, lastError); return; } ErrorHandlerUtilities.RecordException(requestContext, lastError); }
private static DispatchStepResult ValidateAndSetThreadCulture(RequestContext requestContext) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::ValidateAndSetThreadCulture] entry."); CultureInfo cultureInfo = null; EcpUserSettings ecpUserSettings = (EcpUserSettings)0U; UserContext userContext = requestContext.UserContext as UserContext; if (requestContext.UserContext != null && userContext == null) { throw new OwaInvalidOperationException(string.Format("Context was expected to be of type UserContext, but it is of type {0}", requestContext.UserContext.GetType())); } if (RequestDispatcherUtilities.TryReadUpdatedUserSettingsCookie(requestContext, out ecpUserSettings)) { cultureInfo = RequestDispatcherUtilities.GetUserCultureFromEcpCookie(requestContext, ecpUserSettings); if (userContext != null) { userContext.RefreshUserSettings(cultureInfo, ecpUserSettings); } RequestDispatcherUtilities.DeleteUserSettingsCookie(requestContext); } if (cultureInfo == null) { bool flag = requestContext.RequestType == OwaRequestType.SuiteServiceProxyPage; if (requestContext.LanguagePostUserCulture != null) { cultureInfo = requestContext.LanguagePostUserCulture; } else if (userContext != null && !flag) { cultureInfo = Culture.GetPreferredCultureInfo(userContext.ExchangePrincipal); if (cultureInfo == null && userContext.IsExplicitLogon) { cultureInfo = ClientCultures.GetPreferredCultureInfo(userContext.LogonIdentity.GetOWAMiniRecipient().Languages); userContext.UserCulture = cultureInfo; } if (cultureInfo == null) { if (string.IsNullOrEmpty(requestContext.DestinationUrlQueryString)) { requestContext.DestinationUrlQueryString = requestContext.HttpContext.Request.QueryString.ToString(); } bool flag2 = string.IsNullOrEmpty(requestContext.HttpContext.Request.Headers["X-SuiteServiceProxyOrigin"]); CultureInfo culture; string timeZoneKeyName; if (OfflineClientRequestUtilities.IsRequestFromMOWAClient(requestContext.HttpContext.Request, requestContext.HttpContext.Request.UserAgent) && RequestDispatcherUtilities.TryReadMowaGlobalizationSettings(requestContext, out culture, out timeZoneKeyName)) { return(RequestDispatcher.HandleLanguagePost(requestContext, culture, timeZoneKeyName, false, requestContext.DestinationUrl)); } if (flag2) { requestContext.DestinationUrl = RequestDispatcherUtilities.GetDestinationForRedirectToLanguagePage(requestContext); requestContext.HttpContext.Response.AppendHeader("X-OWA-Version", Globals.ApplicationVersion); requestContext.HttpContext.Response.AppendToLog("&redir=lang"); return(DispatchStepResult.RedirectToUrl); } requestContext.HttpContext.Response.Headers["X-OWA-Error"] = "OwaInvalidUserLanguageException"; requestContext.HttpStatusCode = HttpStatusCode.NoContent; return(DispatchStepResult.EndResponse); } else if (userContext.IsUserCultureExplicitlySet) { cultureInfo = userContext.UserCulture; } } } if (cultureInfo != null) { Culture.InternalSetThreadPreferredCulture(cultureInfo); } else { Culture.InternalSetThreadPreferredCulture(); } return(DispatchStepResult.Continue); }
private static DispatchStepResult InternalDispatchRequest(RequestContext requestContext) { HttpRequest request = requestContext.HttpContext.Request; requestContext.RequestType = RequestDispatcherUtilities.GetRequestType(request); ExTraceGlobals.CoreCallTracer.TraceDebug <OwaRequestType>(0L, "[RequestDispatcher::InternalDispatchRequest] Processing requestType={0}.", requestContext.RequestType); OwaRequestType requestType = requestContext.RequestType; if (requestType <= OwaRequestType.LanguagePage) { switch (requestType) { case OwaRequestType.Invalid: requestContext.HttpStatusCode = HttpStatusCode.BadRequest; return(DispatchStepResult.EndResponse); case OwaRequestType.Authorize: break; case OwaRequestType.Logoff: case OwaRequestType.Aspx: goto IL_C2; case OwaRequestType.EsoRequest: return(DispatchStepResult.Stop); default: switch (requestType) { case OwaRequestType.ProxyPing: RequestDispatcherUtilities.RespondProxyPing(requestContext); return(DispatchStepResult.EndResponse); case OwaRequestType.LanguagePage: break; default: goto IL_C2; } break; } requestContext.HttpContext.Response.AppendHeader("X-OWA-Version", Globals.ApplicationVersion); return(DispatchStepResult.Stop); } if (requestType == OwaRequestType.Resource) { return(DispatchStepResult.Stop); } switch (requestType) { case OwaRequestType.WopiRequest: return(DispatchStepResult.Stop); case OwaRequestType.RemoteNotificationRequest: return(DispatchStepResult.Stop); case OwaRequestType.GroupSubscriptionRequest: return(DispatchStepResult.Stop); } IL_C2: if (!requestContext.HttpContext.Request.IsAuthenticated) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::InternalDispatchRequest] Request not authenticated. returning."); requestContext.HttpStatusCode = HttpStatusCode.Unauthorized; return(DispatchStepResult.EndResponse); } DispatchStepResult dispatchStepResult = RequestDispatcher.DispatchIfLogoffRequest(requestContext); if (dispatchStepResult != DispatchStepResult.Continue) { ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::InternalDispatchRequest] DispatchIfLogoffRequest returned {0}. returning.", dispatchStepResult); return(dispatchStepResult); } dispatchStepResult = RequestDispatcher.DispatchIfLastPendingGet(requestContext); if (dispatchStepResult != DispatchStepResult.Continue) { ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::InternalDispatchRequest] DispatchIfLastPendingGet returned {0}. returning.", dispatchStepResult); return(dispatchStepResult); } dispatchStepResult = RequestDispatcher.DispatchIfGetUserPhotoRequest(requestContext); if (dispatchStepResult != DispatchStepResult.Continue) { ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::InternalDispatchRequest] DispatchIfGetUserPhotoRequest returned {0}. returning.", dispatchStepResult); return(dispatchStepResult); } requestContext.UserContext = UserContextManager.GetMailboxContext(requestContext.HttpContext, null, true); if (!requestContext.UserContext.ExchangePrincipal.MailboxInfo.Configuration.IsOwaEnabled && !OfflineClientRequestUtilities.IsRequestFromMOWAClient(requestContext.HttpContext.Request, requestContext.HttpContext.Request.UserAgent)) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::InternalDispatchRequest] OWA Disabled: redirecting to error page."); throw new AccountDisabledException(new LocalizedString(Strings.GetLocalizedString(531497785))); } if (RequestDispatcher.ShouldBlockConnection(requestContext.HttpContext, requestContext.UserContext.LogonIdentity)) { ExTraceGlobals.CoreCallTracer.TraceWarning <string>(0L, "[RequestDispatcher::InternalOnPostAuthorizeRequest] blocked by Client Access Rules. Request URL={0}.", requestContext.HttpContext.Request.Url.OriginalString); if (requestContext.UserContext.LogonIdentity.UserOrganizationId != null && !OrganizationId.ForestWideOrgId.Equals(requestContext.UserContext.LogonIdentity.UserOrganizationId)) { requestContext.DestinationUrl = OwaUrl.LogoffPageBlockedByClientAccessRules.GetExplicitUrl(requestContext.HttpContext.Request); } else { requestContext.DestinationUrl = OwaUrl.LogoffBlockedByClientAccessRules.GetExplicitUrl(requestContext.HttpContext.Request); } return(DispatchStepResult.RedirectToUrl); } dispatchStepResult = RequestDispatcher.ValidateExplicitLogonPermissions(requestContext); if (dispatchStepResult != DispatchStepResult.Continue) { ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::InternalDispatchRequest] ValidateExplicitLogonPermissions returned {0}. returning.", dispatchStepResult); return(dispatchStepResult); } dispatchStepResult = RequestDispatcher.DispatchIfLanguagePost(requestContext); if (dispatchStepResult != DispatchStepResult.Continue) { ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::InternalDispatchRequest] DispatchIfLanguagePost returned {0}. returning.", dispatchStepResult); return(dispatchStepResult); } if (requestContext.UserContext is UserContext) { dispatchStepResult = RequestDispatcher.ValidateAndSetThreadCulture(requestContext); if (dispatchStepResult != DispatchStepResult.Continue) { ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::InternalDispatchRequest] ValidateAndSetThreadCulture returned {0}. returning.", dispatchStepResult); return(dispatchStepResult); } } Uri originalRequestUrlFromContext = UrlUtilities.GetOriginalRequestUrlFromContext(requestContext.HttpContext); dispatchStepResult = RequestDispatcher.SendAppCacheRedirect(requestContext, originalRequestUrlFromContext); if (dispatchStepResult != DispatchStepResult.Continue) { ExTraceGlobals.CoreCallTracer.TraceDebug <DispatchStepResult>(0L, "[RequestDispatcher::InternalDispatchRequest] SendAppCacheRedirect returned {0}. returning.", dispatchStepResult); return(dispatchStepResult); } requestContext.HttpContext.Response.AppendHeader("X-OWA-Version", Globals.ApplicationVersion); requestContext.HttpContext.Response.AppendHeader("X-OWA-OWSVersion", ExchangeVersion.Latest.Version.ToString()); requestContext.HttpContext.Response.AppendHeader("X-OWA-MinimumSupportedOWSVersion", ExchangeVersionType.V2_6.ToString()); RequestDispatcher.SetTimeoutForRequest(requestContext.HttpContext, requestContext.RequestType); RequestDispatcher.CheckAndAddHostNameChangedCookie(requestContext, request); return(RequestDispatcher.DoFinalDispatch(requestContext)); }
internal static void SetXFrameOptionsHeader(RequestContext requestContext, OwaRequestType requestType) { if (requestContext == null) { return; } HttpContext httpContext = requestContext.HttpContext; if (httpContext == null || !httpContext.Request.HttpMethod.Equals("GET") || (httpContext.Request.UserAgent != null && httpContext.Request.UserAgent.Contains("MSAppHost"))) { return; } switch (requestType) { case OwaRequestType.EsoRequest: case OwaRequestType.Oeh: case OwaRequestType.ProxyPing: case OwaRequestType.KeepAlive: case OwaRequestType.Resource: case OwaRequestType.PublishedCalendarView: case OwaRequestType.ICalHttpHandler: case OwaRequestType.HealthPing: case OwaRequestType.SpeechReco: break; case OwaRequestType.Form15: case OwaRequestType.ProxyLogon: case OwaRequestType.LanguagePage: case OwaRequestType.LanguagePost: case OwaRequestType.Attachment: case OwaRequestType.WebPart: case OwaRequestType.ServiceRequest: goto IL_9D; default: if (requestType != OwaRequestType.SuiteServiceProxyPage) { goto IL_9D; } break; } return; IL_9D: string value = "SAMEORIGIN"; if (RequestDispatcherUtilities.IsCmdWebPart(httpContext.Request)) { UserContext userContext = (requestContext.UserContext ?? UserContextManager.GetMailboxContext(httpContext, null, true)) as UserContext; if (userContext != null) { ConfigurationContext configurationContext = new ConfigurationContext(userContext); if (configurationContext != null) { switch ((int)configurationContext.GetFeaturesEnabled(Feature.WebPartsDefaultOrigin | Feature.WebPartsEnableOrigins)) { case 0: case 1: value = "DENY"; break; case 2: value = null; break; } } } } if (!string.IsNullOrEmpty(value)) { httpContext.Response.Headers.Set("X-Frame-Options", value); } }
public static OwaRequestType GetRequestType(HttpRequest request) { OwaRequestType result; if (Globals.IsAnonymousCalendarApp && RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.PublishedCalendar, true)) { result = OwaRequestType.PublishedCalendarView; } else if (Globals.IsAnonymousCalendarApp && RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.PublishedICal, true)) { result = OwaRequestType.ICalHttpHandler; } else if (Utility.IsResourceRequest(request.Url.LocalPath)) { result = OwaRequestType.Resource; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.OehUrl, true)) { result = OwaRequestType.Oeh; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.LanguagePage, true)) { result = OwaRequestType.LanguagePage; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.Default14Page, true)) { result = OwaRequestType.Form15; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.AttachmentHandler, true)) { result = OwaRequestType.Attachment; } else if (UrlUtilities.IsWacRequest(request)) { result = OwaRequestType.WopiRequest; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.LanguagePost, true)) { result = OwaRequestType.LanguagePost; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.LogoffOwa, true)) { result = OwaRequestType.Logoff; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.ProxyLogon, true)) { result = OwaRequestType.ProxyLogon; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.ProxyPing, true)) { result = OwaRequestType.ProxyPing; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.KeepAlive, true)) { result = OwaRequestType.KeepAlive; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.GroupSubscription, true)) { result = OwaRequestType.GroupSubscriptionRequest; } else if (UrlUtilities.IsRemoteNotificationRequest(request)) { result = OwaRequestType.RemoteNotificationRequest; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.SuiteServiceProxyPage, true)) { result = OwaRequestType.SuiteServiceProxyPage; } else if (request.Url.LocalPath.EndsWith(".owa") && string.Equals(request.Params["ns"], "WebReady", StringComparison.InvariantCultureIgnoreCase)) { result = OwaRequestType.WebReadyRequest; } else if (request.Url.LocalPath.EndsWith(".owa", StringComparison.OrdinalIgnoreCase)) { result = OwaRequestType.Invalid; } else if (RequestDispatcherUtilities.IsOwaUrl(request.Url, OwaUrl.AuthFolderUrl, false)) { result = OwaRequestType.Authorize; } else if (request.Url.LocalPath.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase) || request.Url.LocalPath.EndsWith(".ashx", StringComparison.OrdinalIgnoreCase)) { result = OwaRequestType.Aspx; } else if (request.Url.LocalPath.EndsWith(RequestDispatcherUtilities.VirtualDirectoryNameWithLeadingSlash, StringComparison.OrdinalIgnoreCase) || request.Url.LocalPath.EndsWith(RequestDispatcherUtilities.VirtualDirectoryNameWithLeadingAndTrailingSlash, StringComparison.OrdinalIgnoreCase)) { result = OwaRequestType.Form15; } else if (EsoRequest.IsEsoRequest(request)) { result = OwaRequestType.EsoRequest; } else if (request.Url.LocalPath.Contains("service.svc")) { result = OwaRequestType.ServiceRequest; } else if (request.Url.LocalPath.IndexOf("Speech.reco", StringComparison.OrdinalIgnoreCase) != -1) { result = OwaRequestType.SpeechReco; } else if (Globals.IsPreCheckinApp) { result = OwaRequestType.Form15; } else { result = OwaRequestType.Invalid; } return(result); }
public static bool IsOwaUrl(Uri requestUrl, OwaUrl owaUrl, bool exactMatch) { return(RequestDispatcherUtilities.IsOwaUrl(requestUrl, owaUrl, exactMatch, true)); }
public static bool IsDownLevelClient(HttpContext httpContext, bool avoidUserContextAccess = false) { if (httpContext == null) { throw new ArgumentNullException("httpContext cannot be null"); } HttpCookie httpCookie = httpContext.Request.Cookies["PALEnabled"]; if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value)) { return(false); } if (httpContext.Items.Contains("IsDownLevelClient")) { return((bool)httpContext.Items["IsDownLevelClient"]); } if (Utility.IsResourceRequest(httpContext.Request.Url.LocalPath)) { avoidUserContextAccess = true; } bool flag = false; bool flag2 = false; bool flag3 = true; bool isAndroidPremiumEnabled = false; if (httpContext.User != null && httpContext.User.Identity.IsAuthenticated && !avoidUserContextAccess) { UserContext userContext = UserContextManager.GetMailboxContext(httpContext, null, true) as UserContext; if (userContext != null) { bool flag4 = Culture.GetPreferredCultureInfo(userContext.ExchangePrincipal) != null; if (flag4) { ConfigurationContext configurationContext = new ConfigurationContext(userContext); flag3 = configurationContext.IsFeatureEnabled(Feature.RichClient); flag2 = userContext.IsOptimizedForAccessibility; flag = true; ExTraceGlobals.CoreCallTracer.TraceDebug(0L, string.Format("isOptimizedForAccessibility: {0}, isRichClientFeatureEnabled: {1}", flag2, flag3)); } if (userContext.FeaturesManager.ServerSettings.AndroidPremium.Enabled) { isAndroidPremiumEnabled = true; } } else { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "userContext is null when process IsDownLevelClient"); } } bool flag5 = RequestDispatcherUtilities.IsDownLevelClient(httpContext.Request, flag2, flag3, isAndroidPremiumEnabled); if (flag) { httpContext.Items["IsDownLevelClient"] = flag5; ExTraceGlobals.CoreCallTracer.TraceDebug(0L, string.Format("Cache result '{0}' for IsDownLevelClient", flag5)); } else { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, string.Format("Result '{0}' for IsDownLevelClient is not cached.", flag5)); } return(flag5); }
// 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(); } }