private static void CheckAndAddHostNameChangedCookie(RequestContext requestContext, HttpRequest request) { UserContext userContext = UserContextManager.GetMailboxContext(requestContext.HttpContext, null, true) as UserContext; bool flag = userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ServerSettings.OwaHostNameSwitch.Enabled; if (flag && requestContext.RequestType == OwaRequestType.Form15 && !RequestDispatcher.HostNameController.IsUserAgentExcludedFromHostNameSwitchFlight(request)) { Uri requestUrlEvenIfProxied = request.GetRequestUrlEvenIfProxied(); string text = null; if (RequestDispatcher.HostNameController.IsDeprecatedHostName(requestUrlEvenIfProxied.Host, out text)) { RequestDispatcher.HostNameController.AddHostSwitchFlightEnabledCookie(requestContext.HttpContext.Response); } } }
internal static UserContext GetUserContext(HttpContext httpContext, AuthZClientInfo effectiveCaller = null, bool create = true) { IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(httpContext, effectiveCaller, create); if (mailboxContext == null) { return(null); } UserContext userContext = mailboxContext as UserContext; if (userContext == null) { throw new OwaInvalidOperationException("Invalid user context returned. It was expected to be a full user context."); } return(userContext); }
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); }
// Token: 0x06001BD4 RID: 7124 RVA: 0x0006B82C File Offset: 0x00069A2C protected override SubscriptionResponseData[] InternalExecute() { ExTraceGlobals.NotificationsCallTracer.TraceDebug(0L, "[SubscribeToNotificationBase.InternalExecute] Acquiring the UserContext."); Stopwatch stopwatch = Stopwatch.StartNew(); IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, false); if (mailboxContext.NotificationManager == null) { throw new OwaInvalidOperationException("UserContext.MapiNotificationManager is null"); } base.CallContext.ProtocolLog.Set(SubscribeToNotificationMetadata.UserContextLatency, stopwatch.ElapsedMilliseconds); base.CallContext.ProtocolLog.Set(SubscribeToNotificationMetadata.SubscriptionCount, this.subscriptionData.Length); if (this.request.Header.TimeZoneContext != null) { base.CallContext.ProtocolLog.Set(SubscribeToNotificationMetadata.RequestTimeZone, this.request.Header.TimeZoneContext.TimeZoneDefinition.ExTimeZone.DisplayName); } return(this.InternalSubscribe(mailboxContext).ToArray()); }
// Token: 0x0600168A RID: 5770 RVA: 0x000533A4 File Offset: 0x000515A4 internal override bool UseHttpHandlerFactory(HttpContext httpContext) { if (OwaServiceHttpHandlerFactory.FlightEnableOverride.Member) { return(true); } if (Globals.IsAnonymousCalendarApp) { return(false); } if (EsoRequest.IsEsoRequest(httpContext.Request)) { return(false); } UserContext userContext = UserContextManager.GetMailboxContext(httpContext, null, true) as UserContext; return(userContext != null && userContext.FeaturesManager.ServerSettings.OwaHttpHandler.Enabled); }
internal static void InternalCheckClientVersion(CallContext callContext, Func <string, string> headerGetter) { if (EsoRequest.IsEsoRequest(callContext.HttpContext.Request)) { return; } string text = headerGetter("X-OWA-VersionId"); string clientOwsVersionString = headerGetter("X-OWA-ClientOWSVersion"); UserContext userContext = UserContextManager.GetMailboxContext(HttpContext.Current, null, true) as UserContext; bool flag = userContext != null && userContext.FeaturesManager.ServerSettings.OwaVNext.Enabled; bool flag2; if (userContext != null && userContext.FeaturesManager.ClientServerSettings.OwaVersioning.Enabled) { flag2 = OwaVersionId.Supports(clientOwsVersionString, flag); } else { flag2 = OwaVersionId.Matches(text, flag); } if (flag2) { return; } string arg = flag ? OwaVersionId.VNext : OwaVersionId.Current; string text2 = string.Format("Server={0}, Client={1}", arg, text); string actionId = headerGetter("X-OWA-ActionId"); if (CallContext.IsQueuedActionId(actionId)) { Microsoft.Exchange.Diagnostics.Components.Services.ExTraceGlobals.CommonAlgorithmTracer.TraceDebug <string>(0L, "[OWAMessageInspector::CheckClientVersion] Ignoring version mismatch because this is a queued action {0}", text2); return; } Microsoft.Exchange.Diagnostics.Components.Services.ExTraceGlobals.CommonAlgorithmTracer.TraceWarning <string>(0L, "[OWAMessageInspector::CheckClientVersion] Client/Server version mismatch: {0}", text2); throw new OwaVersionException(text2, callContext.GetEffectiveAccessingSmtpAddress()); }
// Token: 0x06001BEA RID: 7146 RVA: 0x0006C5F4 File Offset: 0x0006A7F4 protected override bool InternalExecute() { IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, false); if (mailboxContext.NotificationManager == null) { throw new OwaInvalidOperationException("UserContext.NotificationManager is null"); } for (int i = 0; i < this.subscriptionData.Length; i++) { SubscriptionData subscriptionData = this.subscriptionData[i]; bool flag = RemoteRequestProcessor.IsRemoteRequest(base.CallContext.HttpContext.Request.Headers); if (flag && string.IsNullOrWhiteSpace(subscriptionData.Parameters.ChannelId)) { throw new OwaInvalidRequestException("ChannelId is null or empty. ChannelId is required for remote notification unsubscribe requests."); } this.InternalUnsubscribeNotification(mailboxContext, subscriptionData); if (flag) { RemoteNotificationManager.Instance.UnSubscribe(mailboxContext.Key.ToString(), subscriptionData.SubscriptionId, subscriptionData.Parameters.ChannelId, RemoteRequestProcessor.GetRequesterUserId(base.CallContext.HttpContext.Request.Headers)); } } return(true); }
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>."); } }
private object InternalAfterReceiveRequest(ref Message request, RequestDetailsLogger logger) { try { Globals.UpdateErrorTracingConfiguration(); IActivityScope activityScope = OwaApplication.GetRequestDetailsLogger.ActivityScope; HttpRequestMessageProperty httpRequestMessageProperty = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name]; string value = httpRequestMessageProperty.Headers[OWADispatchOperationSelector.Action]; activityScope.SetProperty(ExtensibleLoggerMetadata.EventId, value); string value2 = httpRequestMessageProperty.Headers["X-OWA-ClientBuildVersion"]; if (!string.IsNullOrEmpty(value2)) { activityScope.SetProperty(OwaServerLogger.LoggerData.ClientBuildVersion, value2); } else { activityScope.SetProperty(OwaServerLogger.LoggerData.ClientBuildVersion, "NA"); } string value3 = httpRequestMessageProperty.Headers["X-EWS-TargetVersion"]; if (!string.IsNullOrEmpty(value3)) { activityScope.SetProperty(OwaServerLogger.LoggerData.RequestVersion, value3); } else { activityScope.SetProperty(OwaServerLogger.LoggerData.RequestVersion, "NA"); } JsonMessageHeaderProcessor jsonMessageHeaderProcessor = new JsonMessageHeaderProcessor(); string methodName = OWAMessageInspector.GetMethodName(request); bool flag = OWAMessageInspector.RequestNeedsHeaderProcessing(methodName); bool flag2 = OWAMessageInspector.RequestNeedsQueryStringProcessing(methodName); bool flag3 = OWAMessageInspector.RequestNeedsHttpHeaderProcessing(methodName); if (flag || flag2 || flag3) { using (MessageBuffer messageBuffer = request.CreateBufferedCopy(int.MaxValue)) { Message request2 = messageBuffer.CreateMessage(); if (flag) { jsonMessageHeaderProcessor.ProcessMessageHeaders(request2); jsonMessageHeaderProcessor.ProcessEwsVersionFromHttpHeaders(request); } else if (flag2) { jsonMessageHeaderProcessor.ProcessMessageHeadersFromQueryString(request2); } else if (flag3) { jsonMessageHeaderProcessor.ProcessHttpHeaders(request, ExchangeVersion.Exchange2013); } request = messageBuffer.CreateMessage(); } } request.Properties["MessageHeaderProcessor"] = jsonMessageHeaderProcessor; request.Properties["ConnectionCostType"] = 0; WebMethodEntry jsonWebMethodEntry; if (!OWAMessageInspector.MethodNameToWebMethodEntryMap.Member.TryGetValue(methodName, out jsonWebMethodEntry)) { jsonWebMethodEntry = WebMethodEntry.JsonWebMethodEntry; } request.Properties["WebMethodEntry"] = jsonWebMethodEntry; MessageHeaderProcessor messageHeaderProcessor = (MessageHeaderProcessor)request.Properties["MessageHeaderProcessor"]; messageHeaderProcessor.MarkMessageHeaderAsUnderstoodIfExists(request, "RequestServerVersion", "http://schemas.microsoft.com/exchange/services/2006/types"); RequestDetailsLogger.LogEvent(logger, OwaServerLogger.LoggerData.CallContextInitBegin); Message requestRef = request; CallContext callContext = OwaApplication.GetRequestDetailsLogger.TrackLatency <CallContext>(ServiceLatencyMetadata.CallContextInitLatency, () => CallContextUtilities.CreateCallContext(requestRef, messageHeaderProcessor, true, "")); RequestDetailsLogger.LogEvent(logger, OwaServerLogger.LoggerData.CallContextInitEnd); callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsMowaClient, OfflineClientRequestUtilities.IsRequestFromMOWAClient(callContext.HttpContext.Request, callContext.HttpContext.Request.UserAgent) ? 1 : 0); bool?flag4 = new bool?(OfflineClientRequestUtilities.IsRequestFromOfflineClient(callContext.HttpContext.Request)); if (flag4 != null) { callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsOfflineEnabled, flag4.Value ? 1 : 0); } callContext.OwaExplicitLogonUser = UserContextUtilities.GetExplicitLogonUser(HttpContext.Current); if (string.IsNullOrEmpty(callContext.OwaExplicitLogonUser)) { OWAMessageInspector.CheckThatUserProvisionedDevice(methodName, callContext); OWAMessageInspector.CheckMowaRemoteWipe(methodName, callContext); OWAMessageInspector.CheckClientVersion(callContext); OWAMessageInspector.CheckMowaDisabled(callContext); OWAMessageInspector.CheckMobileDevicePolicyIsCorrect(methodName, callContext); } OWAMessageInspector.MarkResponseNonCacheable(methodName); callContext.WorkloadType = WorkloadType.Owa; callContext.UsingWcfDispatcher = true; callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.UsingWcfHttpHandler, 1); if (ExchangeVersion.Current == ExchangeVersion.Exchange2007) { ExchangeVersion.Current = ExchangeVersion.Exchange2013; } if (OWAMessageInspector.ShouldCreateUserContext(callContext)) { UserContext userContext = UserContextManager.GetMailboxContext(callContext.HttpContext, callContext.EffectiveCaller, true) as UserContext; if (userContext != null) { callContext.OwaCulture = userContext.UserCulture; if (userContext.FeaturesManager != null) { callContext.FeaturesManager = userContext.FeaturesManager; if (userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled) { callContext.OwaUserContextKey = userContext.Key.ToString(); } } } } } catch (LocalizedException ex) { Microsoft.Exchange.Diagnostics.Components.Services.ExTraceGlobals.CommonAlgorithmTracer.TraceError <string, string>((long)this.GetHashCode(), "[OWAMessageInspector::AfterReceiveRequest] Caught localized exception trying to create callcontext. Class: {0}, Message: {1}", ex.GetType().FullName, ex.Message); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OWAMessageInspector", null, "InternalAfterReceiveRequest", string.Format("OwaServiceFaultException_InnerException - {0}", ex))); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeLogRequestException(OwaApplication.GetRequestDetailsLogger, ex, "OwaServiceFaultException_InnerException"); throw OwaFaultExceptionUtilities.CreateFault(ex); } return(null); }
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 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); }
private void InternalAfterReceiveRequest(HttpRequest httpRequest, string methodName, object request) { try { ExTraceGlobals.CommonAlgorithmTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] called for method name: {0}", methodName); CallContext.ClearCallContextForCurrentThread(); Globals.UpdateErrorTracingConfiguration(); OwaApplication.GetRequestDetailsLogger.ActivityScope.SetProperty(ExtensibleLoggerMetadata.EventId, methodName); OwaServiceMessage message = new OwaServiceMessage(httpRequest, request); message.Headers.Action = methodName; message.Properties["HttpOperationName"] = methodName; OwaMessageHeaderProcessor messageHeaderProcessor = new OwaMessageHeaderProcessor(); bool flag = OWAMessageInspector.RequestNeedsHeaderProcessing(methodName); bool flag2 = OWAMessageInspector.RequestNeedsQueryStringProcessing(methodName); bool flag3 = OWAMessageInspector.RequestNeedsHttpHeaderProcessing(methodName); ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] processing message headers"); if (flag || flag2 || flag3) { if (flag) { messageHeaderProcessor.ProcessMessageHeaders(message); messageHeaderProcessor.ProcessEwsVersionFromHttpHeaders(message); } else if (flag2) { messageHeaderProcessor.ProcessMessageHeadersFromQueryString(message); } else if (flag3) { messageHeaderProcessor.ProcessHttpHeaders(message, ExchangeVersion.Exchange2013); } } message.Properties["MessageHeaderProcessor"] = messageHeaderProcessor; message.Properties["ConnectionCostType"] = 0; WebMethodEntry jsonWebMethodEntry; if (!OWAMessageInspector.MethodNameToWebMethodEntryMap.Member.TryGetValue(methodName, out jsonWebMethodEntry)) { jsonWebMethodEntry = WebMethodEntry.JsonWebMethodEntry; } message.Properties["WebMethodEntry"] = jsonWebMethodEntry; ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] creating CallContext"); CallContext callContext = OwaApplication.GetRequestDetailsLogger.TrackLatency <CallContext>(ServiceLatencyMetadata.CallContextInitLatency, () => CallContextUtilities.CreateCallContext(message, messageHeaderProcessor, true, "")); callContext.IsOwa = true; ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] CallContext created"); callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsMowaClient, OfflineClientRequestUtilities.IsRequestFromMOWAClient(callContext.HttpContext.Request, callContext.HttpContext.Request.UserAgent) ? 1 : 0); bool?flag4 = new bool?(OfflineClientRequestUtilities.IsRequestFromOfflineClient(callContext.HttpContext.Request)); if (flag4 != null) { callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.IsOfflineEnabled, flag4.Value ? 1 : 0); } callContext.OwaExplicitLogonUser = UserContextUtilities.GetExplicitLogonUser(HttpContext.Current); if (string.IsNullOrEmpty(callContext.OwaExplicitLogonUser)) { OWAMessageInspector.CheckThatUserProvisionedDevice(methodName, callContext); OWAMessageInspector.CheckMowaRemoteWipe(methodName, callContext); OWAMessageInspector.CheckClientVersion(callContext); OWAMessageInspector.CheckMowaDisabled(callContext); OWAMessageInspector.CheckMobileDevicePolicyIsCorrect(methodName, callContext); } OWAMessageInspector.MarkResponseNonCacheable(methodName); callContext.WorkloadType = WorkloadType.Owa; callContext.UsingWcfDispatcher = false; callContext.ProtocolLog.Set(OwaServerLogger.LoggerData.UsingWcfHttpHandler, 0); if (ExchangeVersion.Current == ExchangeVersion.Exchange2007) { ExchangeVersion.Current = ExchangeVersion.Exchange2013; } if (OWAMessageInspector.ShouldCreateUserContext(callContext)) { UserContext userContext = UserContextManager.GetMailboxContext(callContext.HttpContext, callContext.EffectiveCaller, true) as UserContext; if (userContext != null) { callContext.OwaCulture = userContext.UserCulture; if (userContext.FeaturesManager != null) { callContext.FeaturesManager = userContext.FeaturesManager; if (userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled) { callContext.OwaUserContextKey = userContext.Key.ToString(); } } } } } catch (LocalizedException ex) { ExTraceGlobals.CommonAlgorithmTracer.TraceError <string, LocalizedException>((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] Caught localized exception trying to process message. Type: {0} Exception: {1}", ex.GetType().Name, ex); OwaServerTraceLogger.AppendToLog(new TraceLogEvent("OWAMessageInspector", null, "InternalAfterReceiveRequest", string.Format("OwaServiceFaultException_InnerException - {0}", ex))); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeLogRequestException(OwaApplication.GetRequestDetailsLogger, ex, "OwaServiceFaultException_InnerException"); throw OwaFaultExceptionUtilities.CreateFault(ex); } catch (Exception ex2) { ExTraceGlobals.CommonAlgorithmTracer.TraceError <string, Exception>((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] Caught exception trying to process message. Type: {0} Exception: {1}", ex2.GetType().Name, ex2); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeLogRequestException(OwaApplication.GetRequestDetailsLogger, ex2, "OwaServiceFaultException_InnerException"); throw; } ExTraceGlobals.CommonAlgorithmTracer.TraceDebug((long)this.GetHashCode(), "[OwaServiceMessageInspector::InternalAfterReceiveRequest] completed"); }