示例#1
0
 // Token: 0x06001682 RID: 5762 RVA: 0x00053038 File Offset: 0x00051238
 private void InternalProcessRequest(HttpContext httpContext)
 {
     ExTraceGlobals.CoreTracer.TraceDebug(0L, "OwaServiceHttpHandler.ProcessRequest");
     OwaServerLogger.LogWcfLatency(httpContext);
     try
     {
         HttpRequest  request  = httpContext.Request;
         HttpResponse response = httpContext.Response;
         base.Initialize(response);
         if (base.ServiceMethodInfo.IsHttpGet)
         {
             Uri url = request.Url;
             new Uri(request.Path, UriKind.Relative);
             base.MethodDispatcher.InvokeGetMethod(base.ServiceMethodInfo, base.Service, request, response);
         }
         else
         {
             base.MethodDispatcher.InvokeMethod(base.ServiceMethodInfo, base.Service, request, response);
         }
     }
     catch (TargetInvocationException ex)
     {
         ExTraceGlobals.CoreTracer.TraceError <Exception>(0L, "Method invocation target threw an exception: {0}", ex.InnerException);
         ExceptionDispatchInfo exceptionDispatchInfo = ExceptionDispatchInfo.Capture(ex.InnerException ?? ex);
         exceptionDispatchInfo.Throw();
     }
     finally
     {
         base.MethodDispatcher.DisposeParameters();
     }
 }
示例#2
0
        // Token: 0x0600116E RID: 4462 RVA: 0x00042E34 File Offset: 0x00041034
        protected override bool CheckAccessCore(OperationContext operationContext)
        {
            HttpContext httpContext = HttpContext.Current;

            OwaServerLogger.LogWcfLatency(httpContext);
            return(httpContext.Request.IsAuthenticated && base.CheckAccessCore(operationContext));
        }
 // Token: 0x0600115A RID: 4442 RVA: 0x000429B0 File Offset: 0x00040BB0
 internal override void ExecuteApplicationEndRequest(object sender, EventArgs e)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             try
             {
                 RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;
                 if (getRequestDetailsLogger != null)
                 {
                     HttpApplication httpApplication = (HttpApplication)sender;
                     OwaServerLogger.LogHttpContextData(httpApplication.Context, getRequestDetailsLogger);
                     RequestDetailsLogger.LogEvent(getRequestDetailsLogger, OwaServerLogger.LoggerData.RequestEndTime);
                 }
                 OwaApplication.FinalizeResponse();
             }
             finally
             {
                 Global.CleanUpRequestObjects();
             }
         });
     }
     catch (GrayException arg)
     {
         ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <GrayException>(0L, "OwaApplication.ExecuteApplicationEndRequest: GrayException: {0}", arg);
         throw;
     }
 }
        internal override void OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;

            if (getRequestDetailsLogger != null)
            {
                HttpApplication httpApplication = (HttpApplication)sender;
                httpApplication.Context.Items.Add(ServiceLatencyMetadata.HttpPipelineLatency, (int)getRequestDetailsLogger.ActivityScope.TotalMilliseconds);
                OwaServerLogger.LogUserContextData(httpApplication.Context, getRequestDetailsLogger);
            }
        }
        // Token: 0x06001158 RID: 4440 RVA: 0x000426A0 File Offset: 0x000408A0
        internal override void Initialize()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            ExTraceGlobals.ConfigurationManagerTracer.TraceDebug(0L, "OwaApplication.Initialize: SafeHtml loading begin");
            IntPtr value = NativeMethods.LoadLibrary(Path.GetFullPath(Path.Combine(ExchangeSetupContext.BinPath, "SafeHtmlNativeWrapper.dll")));

            if (value == IntPtr.Zero)
            {
                ExTraceGlobals.ConfigurationManagerTracer.TraceError(0L, "OwaApplication.Initialize: Failed to load SafeHtmlNativeWrapper.");
                Global.SafeHtmlLoaded = false;
            }
            else
            {
                ExTraceGlobals.ConfigurationManagerTracer.TraceDebug(0L, "OwaApplication.Initialize: SafeHtmlNativeWrapper loaded successfully.");
                Global.SafeHtmlLoaded = true;
            }
            SafeHtml.Initialize(ExchangeSetupContext.BinPath + Path.DirectorySeparatorChar);
            ExTraceGlobals.ConfigurationManagerTracer.TraceDebug(0L, "OwaApplication.Initialize: SafeHtml loading finished");
            Global.InitializeSettingsFromWebConfig();
            int workerThreads;
            int num;

            ThreadPool.GetMinThreads(out workerThreads, out num);
            int configIntValue = AppConfigLoader.GetConfigIntValue("ThreadPoolMinIOCPThreads", 0, int.MaxValue, 3 * Environment.ProcessorCount);

            ThreadPool.SetMinThreads(workerThreads, configIntValue);
            OwaApplication.InitializeApplicationCaches();
            RequestDetailsLogger.ApplicationType = LoggerApplicationType.Owa;
            OwaClientLogger.Initialize();
            OwaClientTraceLogger.Initialize();
            OwaServerLogger.Initialize();
            OwaServerTraceLogger.Initialize();
            SettingOverrideSync.Instance.Start(true);
            LoggerSettings.MaxAppendableColumnLength   = null;
            LoggerSettings.ErrorMessageLengthThreshold = null;
            Global.ResponseShapeResolver = new OwaResponseShapeResolver();
            Global.EwsClientMailboxSessionCloningHandler = new EwsClientMailboxSessionCloningHandler(UserContextManager.GetClonedMailboxSession);
            Global.DefaultMapiClientType             = "Client=OWA";
            MailboxSession.DefaultFoldersToForceInit = OwaApplication.foldersToForceInitialize;
            UserContextManager.Initialize();
            if (Globals.OwaIsNoRecycleEnabled)
            {
                OwaVersionId.InitializeOwaVersionReadingTimer();
            }
            KillBitTimer.Singleton.Start();
            KillbitWatcher.TryWatch(new KillbitWatcher.ReadKillBitFromFileCallback(KillBitHelper.ReadKillBitFromFile));
            OwaServerLogger.AppendToLog(new OwaAppStartLogEvent((double)stopwatch.ElapsedMilliseconds));
        }
 private void HandleException(string eventId, Exception e)
 {
     ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "There was an exception on the notification thread: {0}", e.ToString());
     OwaServerLogger.AppendToLog(new ExceptionLogEvent(eventId, this.userContext, e));
     if (this.pendingRequestChannels != null)
     {
         lock (this.pendingRequestChannels)
         {
             if (this.pendingRequestChannels != null)
             {
                 foreach (KeyValuePair <string, PendingRequestChannel> keyValuePair in this.pendingRequestChannels)
                 {
                     keyValuePair.Value.HandleException(e, false);
                 }
             }
         }
     }
 }
        // Token: 0x06001684 RID: 5764 RVA: 0x00053130 File Offset: 0x00051330
        public IAsyncResult BeginProcessRequest(HttpContext httpContext, AsyncCallback cb, object extraData)
        {
            OwaServerLogger.LogWcfLatency(httpContext);
            IAsyncResult result;

            try
            {
                result = this.InternalBeginProcessRequest(httpContext, cb, extraData);
            }
            catch (Exception ex)
            {
                base.FaultHandler.ProvideFault(ex, httpContext.Response);
                result = new AsyncResult(cb, null, true)
                {
                    Exception = ex
                };
            }
            return(result);
        }
        // Token: 0x06000E7A RID: 3706 RVA: 0x00036B64 File Offset: 0x00034D64
        private void WriteNotificationStatisticsData(NotificationStatisticsEventType eventType, NotificationStatistics statistics)
        {
            IDictionary <NotificationStatisticsKey, NotificationStatisticsValue> dictionary;
            DateTime startTime;

            statistics.GetAndResetStatisticData(out dictionary, out startTime);
            foreach (KeyValuePair <NotificationStatisticsKey, NotificationStatisticsValue> keyValuePair in dictionary)
            {
                NotificationStatisticsLogEvent notificationStatisticsLogEvent = new NotificationStatisticsLogEvent(eventType, startTime, keyValuePair.Key, keyValuePair.Value);
                if (this.TestLogEventCreated != null)
                {
                    this.TestLogEventCreated(notificationStatisticsLogEvent);
                }
                else
                {
                    OwaServerLogger.AppendToLog(notificationStatisticsLogEvent);
                }
            }
        }
 internal PendingRequestChannel AddPendingGetChannel(string channelId)
 {
     if (this.pendingRequestChannels != null)
     {
         lock (this.pendingRequestChannels)
         {
             if (this.pendingRequestChannels != null && this.pendingRequestChannels.Count <= 10 && !this.pendingRequestChannels.ContainsKey(channelId))
             {
                 PendingRequestChannel pendingRequestChannel = new PendingRequestChannel(this, channelId);
                 this.pendingRequestChannels.Add(channelId, pendingRequestChannel);
                 this.listenerChannelsManager.AddPendingGetChannel(channelId, this);
                 if (this.userContext.ExchangePrincipal != null && !string.IsNullOrEmpty(this.userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()))
                 {
                     OwaServerLogger.AppendToLog(new PendingRequestChannelLogEvent(this.userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), channelId));
                 }
                 return(pendingRequestChannel);
             }
         }
     }
     return(null);
 }
 private void StartGroupConcurrencyLogThread()
 {
     if (this.loggerThreadAlive != 0)
     {
         return;
     }
     ThreadPool.QueueUserWorkItem(delegate(object param0)
     {
         while (Interlocked.CompareExchange(ref this.loggerThreadAlive, 1, 0) == 0)
         {
             ILogEvent logEvent;
             while (this.logEventQueue.TryDequeue(out logEvent))
             {
                 OwaServerLogger.AppendToLog(logEvent);
             }
             Interlocked.Exchange(ref this.loggerThreadAlive, 0);
             if (this.logEventQueue.Count == 0)
             {
                 return;
             }
         }
     });
 }
示例#11
0
        private static IMailboxContext AcquireUserContext(HttpContext httpContext, AuthZClientInfo effectiveCaller, UserContextKey userContextKey, UserContextCookie userContextCookie)
        {
            IMailboxContext       mailboxContext        = null;
            UserContextStatistics userContextStatistics = null;

            try
            {
                if (userContextKey != null)
                {
                    mailboxContext = UserContextManager.GetMailboxContextFromCache(userContextKey);
                    if (mailboxContext == null || mailboxContext.State == UserContextState.Abandoned)
                    {
                        UserContextManager.CreateUserContext(httpContext, userContextKey, effectiveCaller, out mailboxContext, out userContextStatistics);
                    }
                }
                else
                {
                    UserContextManager.CreateUserContext(httpContext, null, effectiveCaller, out mailboxContext, out userContextStatistics);
                    string cookieId = null;
                    if (mailboxContext != null)
                    {
                        userContextCookie = UserContextCookie.CreateFromKey(cookieId, mailboxContext.Key, httpContext.Request.IsSecureConnection);
                        httpContext.Response.Cookies.Set(userContextCookie.HttpCookie);
                        userContextStatistics.CookieCreated = true;
                    }
                }
            }
            finally
            {
                if (userContextStatistics != null)
                {
                    SignInLogEvent logEvent = new SignInLogEvent(mailboxContext, (userContextCookie != null) ? userContextCookie.CookieValue : string.Empty, userContextStatistics, httpContext.Request.Url);
                    OwaServerLogger.AppendToLog(logEvent);
                }
            }
            return(mailboxContext);
        }
示例#12
0
        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>.");
            }
        }