internal override void OnPostAuthorizeRequest(object sender, EventArgs e)
        {
            bool flag = false;

            if (this.onPostAuthorizeRequestChain != null)
            {
                flag = this.onPostAuthorizeRequestChain.ExecuteRequestFilterChain(sender, e, RequestEventType.PostAuthorizeRequest);
            }
            if (flag)
            {
                return;
            }
            HttpApplication httpApplication = (HttpApplication)sender;

            if (UrlUtilities.IsWacRequest(httpApplication.Context.Request))
            {
                return;
            }
            try
            {
                RequestDispatcher.DispatchRequest(OwaContext.Get(httpApplication.Context));
            }
            catch (ThreadAbortException)
            {
                OwaContext.Current.UnlockMinResourcesOnCriticalError();
            }
        }
        // Token: 0x0600071C RID: 1820 RVA: 0x00037B9C File Offset: 0x00035D9C
        private void ProcessAttachment(Attachment attachment, HttpContext httpContext, BlockStatus blockStatus)
        {
            if (attachment == null)
            {
                throw new ArgumentNullException("attachment");
            }
            OwaContext  owaContext  = OwaContext.Get(httpContext);
            UserContext userContext = owaContext.UserContext;
            Stream      stream      = null;

            try
            {
                StreamAttachmentBase streamAttachment = AttachmentUtility.GetStreamAttachment(attachment);
                if (streamAttachment == null)
                {
                    ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: attachment is not derived from AttachmentStream");
                }
                else
                {
                    AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(streamAttachment, userContext);
                    if (attachmentLevel == AttachmentPolicy.Level.Block)
                    {
                        Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(-2000404449), LocalizedStrings.GetNonEncoded(-615885395));
                    }
                    else
                    {
                        string fileName = AttachmentUtility.CalculateAttachmentName(streamAttachment.DisplayName, streamAttachment.FileName);
                        string text     = streamAttachment.FileExtension;
                        if (text == null)
                        {
                            text = string.Empty;
                        }
                        string empty       = string.Empty;
                        bool   contentType = this.GetContentType(httpContext, streamAttachment, attachmentLevel, out empty);
                        bool   isInline    = this.GetIsInline(streamAttachment, attachmentLevel);
                        stream = AttachmentUtility.GetStream(streamAttachment);
                        if (stream == null)
                        {
                            ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: Image conversion of OLE attachment failure");
                        }
                        else
                        {
                            AttachmentHandler.SendDocumentContentToHttpStream(httpContext, stream, fileName, text, empty, isInline, streamAttachment.TextCharset, blockStatus, attachmentLevel, contentType);
                        }
                    }
                }
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }
        }
Exemplo n.º 3
0
        // Token: 0x06000FDD RID: 4061 RVA: 0x00062EB8 File Offset: 0x000610B8
        private void OnEndRequest(object sender, EventArgs e)
        {
            ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "OwaModule.OnEndRequest");
            HttpApplication httpApplication = (HttpApplication)sender;

            if (this.ShouldInterceptRequest(httpApplication.Context, false))
            {
                if (!Globals.IsInitialized)
                {
                    return;
                }
                HttpContext context    = httpApplication.Context;
                OwaContext  owaContext = OwaContext.Get(context);
                if (owaContext == null)
                {
                    return;
                }
                try
                {
                    this.requestInspector.OnEndRequest(owaContext);
                }
                finally
                {
                    if (Globals.FilterETag && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).OwaDeployment.FilterETag.Enabled)
                    {
                        context.Response.Headers.Remove("ETag");
                    }
                    long requestLatencyMilliseconds = owaContext.RequestLatencyMilliseconds;
                    if (Globals.OwaVDirType == OWAVDirType.OWA && Globals.ArePerfCountersEnabled)
                    {
                        if (RequestDispatcher.IsUserInitiatedRequest(context.Request))
                        {
                            PerformanceCounterManager.UpdateResponseTimePerformanceCounter(requestLatencyMilliseconds, OwaContext.Current.RequestExecution == RequestExecution.Proxy);
                        }
                        OwaSingleCounters.TotalRequests.Increment();
                        if (owaContext.ErrorInformation != null)
                        {
                            OwaSingleCounters.TotalRequestsFailed.Increment();
                            Exception exception = owaContext.ErrorInformation.Exception;
                            this.UpdateExceptionsPerfCountersQueues(exception);
                        }
                        else
                        {
                            this.UpdateExceptionsPerfCountersQueues(null);
                        }
                        if (owaContext.RequestExecution == RequestExecution.Proxy)
                        {
                            OwaSingleCounters.ProxiedUserRequests.Increment();
                        }
                    }
                    ExTraceGlobals.RequestTracer.TraceDebug <string, long>((long)owaContext.GetHashCode(), "Response: HTTP {0}, time:{1} ms.", owaContext.HttpContext.Response.Status, requestLatencyMilliseconds);
                    OwaDiagnostics.ClearThreadTracing();
                }
            }
        }
Exemplo n.º 4
0
 // Token: 0x0600024D RID: 589 RVA: 0x00014FD4 File Offset: 0x000131D4
 public override void ProcessRequest(HttpContext context)
 {
     try
     {
         base.ProcessRequest(context);
     }
     catch (ThreadAbortException)
     {
         OwaContext.Get(context).UnlockMinResourcesOnCriticalError();
     }
 }
Exemplo n.º 5
0
        // Token: 0x06000FDE RID: 4062 RVA: 0x0006301C File Offset: 0x0006121C
        private void OnError(object sender, EventArgs e)
        {
            ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "OwaModule.OnError");
            HttpApplication httpApplication = (HttpApplication)sender;
            Exception       lastError       = httpApplication.Server.GetLastError();

            if (this.ShouldInterceptRequest(httpApplication.Context, true))
            {
                httpApplication.Server.ClearError();
                Utilities.HandleException(OwaContext.Get(httpApplication.Context), lastError);
            }
        }
        // Token: 0x06001988 RID: 6536 RVA: 0x000953D4 File Offset: 0x000935D4
        internal Stream GetItemAttachmentStream(Attachment attachment, HttpContext httpContext)
        {
            OwaContext  owaContext  = OwaContext.Get(httpContext);
            UserContext userContext = owaContext.UserContext;
            OutboundConversionOptions outboundConversionOptions = Utilities.CreateOutboundConversionOptions(userContext);
            Stream         stream         = Streams.CreateTemporaryStorageStream();
            string         text           = null;
            ItemAttachment itemAttachment = attachment as ItemAttachment;

            using (Item item = itemAttachment.GetItem(StoreObjectSchema.ContentConversionProperties))
            {
                try
                {
                    if (ItemConversion.IsItemClassConvertibleToMime(item.ClassName))
                    {
                        ItemConversion.ConvertItemToMime(item, stream, outboundConversionOptions);
                        text = ".eml";
                    }
                    else if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(item.ClassName))
                    {
                        (item as CalendarItemBase).ExportAsICAL(stream, "UTF-8", outboundConversionOptions);
                        text = ".ics";
                    }
                    else if (ObjectClass.IsContact(item.ClassName))
                    {
                        Contact.ExportVCard(item as Contact, stream, outboundConversionOptions);
                        text = ".vcf";
                    }
                    else
                    {
                        ItemConversion.ConvertItemToMsgStorage(item, stream, outboundConversionOptions);
                    }
                }
                catch (Exception)
                {
                    stream = this.GetContentsReplacementStream(-1706159495);
                    text   = ".txt";
                }
            }
            if (text != null)
            {
                this.fileName             = this.GetConvertedItemFileName(this.fileName, text);
                this.encodedfileNameBytes = this.GetEncodedString(this.fileName);
            }
            stream.Position = 0L;
            return(stream);
        }
Exemplo n.º 7
0
 // Token: 0x0600085C RID: 2140 RVA: 0x0003E370 File Offset: 0x0003C570
 public static void UpdateUserCulture(UserContext userContext, CultureInfo culture, bool updateAD)
 {
     if (culture == null)
     {
         throw new ArgumentNullException("culture");
     }
     if (userContext == null)
     {
         throw new OwaInvalidOperationException("Shouldn't call UpdateUserCulture without a session");
     }
     if (updateAD)
     {
         PreferredCultures preferredCultures = new PreferredCultures(userContext.ExchangePrincipal.PreferredCultures);
         preferredCultures.AddSupportedCulture(culture, new Predicate <CultureInfo>(Culture.IsSupportedCulture));
         Culture.SetPreferredCulture(userContext.ExchangePrincipal, preferredCultures, userContext.MailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent));
         userContext.ExchangePrincipal = userContext.ExchangePrincipal.WithPreferredCultures(preferredCultures);
     }
     userContext.UserCulture = culture;
     Culture.InternalSetThreadCulture(culture);
     userContext.RecreateMailboxSession(OwaContext.Get(HttpContext.Current));
     userContext.RecreatePublicFolderSessions();
 }
        // Token: 0x06000717 RID: 1815 RVA: 0x0003786C File Offset: 0x00035A6C
        private static int SendDocumentContentToHttpStream(HttpContext httpContext, Stream stream, string fileName, string fileExtension, string contentType, bool isInline, Charset charset, BlockStatus blockStatus, AttachmentPolicy.Level level, bool doNeedToFilterHtml)
        {
            if (AttachmentUtility.IsMhtmlAttachment(contentType, fileExtension))
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>(0L, "AttachmentHandler.SendDocumentContentToHttpStream: Explicitly blocking MHTML attachment {0}", fileName);
                return(0);
            }
            AttachmentHandler.SetAttachmentResponseHeaders(httpContext, fileName, contentType, isInline, level);
            uint result;

            if (doNeedToFilterHtml)
            {
                result = AttachmentUtility.WriteFilteredResponse(httpContext, stream, charset, blockStatus);
            }
            else
            {
                bool isNotHtmlandNotXml = !AttachmentUtility.GetIsHtmlOrXml(contentType, fileExtension);
                bool doNotSniff         = AttachmentUtility.GetDoNotSniff(level, OwaContext.Get(httpContext).UserContext);
                result = AttachmentUtility.WriteUnfilteredResponse(httpContext, stream, fileName, isNotHtmlandNotXml, doNotSniff);
            }
            return((int)result);
        }
        public IHttpHandler GetHandler(HttpContext httpContext, string requestType, string url, string pathTranslated)
        {
            ExTraceGlobals.OehCallTracer.TraceDebug(0L, "OwaEventHandlerFactory.GetHandler");
            string          queryStringParameter  = Utilities.GetQueryStringParameter(httpContext.Request, "ns");
            string          queryStringParameter2 = Utilities.GetQueryStringParameter(httpContext.Request, "ev");
            ISessionContext sessionContext        = OwaContext.Get(httpContext).SessionContext;

            ExTraceGlobals.OehDataTracer.TraceDebug <string, string>(0L, "Request namespace: '{0}', event: '{1}'", queryStringParameter, queryStringParameter2);
            OwaEventNamespaceAttribute owaEventNamespaceAttribute = OwaEventRegistry.FindNamespaceInfo(queryStringParameter);

            if (owaEventNamespaceAttribute == null)
            {
                throw new OwaInvalidRequestException(string.Format(CultureInfo.InvariantCulture, "Namespace '{0}' doesn't exist", new object[]
                {
                    queryStringParameter
                }), null, this);
            }
            if (sessionContext != null && !sessionContext.IsProxy && !sessionContext.AreFeaturesEnabled(owaEventNamespaceAttribute.SegmentationFlags))
            {
                Utilities.EndResponse(httpContext, HttpStatusCode.Forbidden);
                return(null);
            }
            OwaEventAttribute owaEventAttribute = owaEventNamespaceAttribute.FindEventInfo(queryStringParameter2);

            if (owaEventAttribute == null)
            {
                throw new OwaInvalidRequestException(string.Format(CultureInfo.InvariantCulture, "Event '{0}' doesn't exist", new object[]
                {
                    queryStringParameter2
                }), null, this);
            }
            if (Globals.OwaVDirType == OWAVDirType.Calendar && !owaEventAttribute.AllowAnonymousAccess)
            {
                Utilities.EndResponse(httpContext, HttpStatusCode.BadRequest);
                return(null);
            }
            if (sessionContext != null && !sessionContext.IsProxy && !sessionContext.AreFeaturesEnabled(owaEventAttribute.SegmentationFlags))
            {
                Utilities.EndResponse(httpContext, HttpStatusCode.Forbidden);
                return(null);
            }
            OwaEventVerb owaEventVerb = OwaEventVerbAttribute.Parse(httpContext.Request.HttpMethod);

            ExTraceGlobals.OehDataTracer.TraceDebug <string>(0L, "Request verb: {0}", httpContext.Request.HttpMethod);
            if ((owaEventAttribute.AllowedVerbs & owaEventVerb) == OwaEventVerb.Unsupported)
            {
                ExTraceGlobals.OehTracer.TraceDebug <OwaEventVerb, OwaEventVerb>(0L, "Verb is not allowed, returning 405. Actual verb: {0}. Allowed: {1}.", owaEventVerb, owaEventAttribute.AllowedVerbs);
                Utilities.EndResponse(httpContext, HttpStatusCode.MethodNotAllowed);
                return(null);
            }
            OwaEventHandlerBase owaEventHandlerBase = (OwaEventHandlerBase)Activator.CreateInstance(owaEventNamespaceAttribute.HandlerType);

            owaEventHandlerBase.EventInfo  = owaEventAttribute;
            owaEventHandlerBase.OwaContext = OwaContext.Current;
            owaEventHandlerBase.Verb       = owaEventVerb;
            if (Globals.CollectPerRequestPerformanceStats)
            {
                OwaContext.Current.OwaPerformanceData.SetOehRequestType(owaEventNamespaceAttribute.HandlerType.Name, owaEventAttribute.IsAsync ? owaEventAttribute.BeginMethodInfo.Name : owaEventAttribute.MethodInfo.Name);
            }
            if (owaEventAttribute.IsAsync)
            {
                OwaContext.Current.TryReleaseBudgetAndStopTiming();
                ExTraceGlobals.OehTracer.TraceDebug(0L, "Created async HTTP handler to server OEH request");
                OwaContext.Current.IsAsyncRequest = true;
                return(new OwaEventAsyncHttpHandler(owaEventHandlerBase));
            }
            ExTraceGlobals.OehTracer.TraceDebug(0L, "Created sync HTTP handler to serve OEH request");
            return(new OwaEventHttpHandler(owaEventHandlerBase));
        }
        // Token: 0x0600071F RID: 1823 RVA: 0x00037D98 File Offset: 0x00035F98
        private bool GetContentType(HttpContext httpContext, StreamAttachmentBase streamAttachment, AttachmentPolicy.Level level, out string contentType)
        {
            contentType = AttachmentUtility.CalculateContentType(streamAttachment);
            bool flag = AttachmentUtility.DoNeedToFilterHtml(contentType, streamAttachment.FileExtension, level, OwaContext.Get(httpContext).UserContext);

            if (string.IsNullOrEmpty(contentType) && this.IsVoiceMailAttachment(httpContext))
            {
                contentType = "audio/x-ms-wma";
            }
            else if (flag)
            {
                AttachmentUtility.UpdateContentTypeForNeedToFilter(out contentType, streamAttachment.TextCharset);
            }
            return(flag);
        }
        // Token: 0x06000716 RID: 1814 RVA: 0x000377E8 File Offset: 0x000359E8
        internal static int SendDocumentContentToHttpStream(HttpContext httpContext, Stream stream, string fileName, string fileExtension, string contentType)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                fileName = LocalizedStrings.GetNonEncoded(1797976510);
            }
            if (fileExtension == null)
            {
                fileExtension = string.Empty;
            }
            if (contentType == null)
            {
                contentType = string.Empty;
            }
            bool flag = AttachmentUtility.DoNeedToFilterHtml(contentType, fileExtension, AttachmentPolicy.Level.Unknown, OwaContext.Get(httpContext).UserContext);

            if (flag)
            {
                AttachmentUtility.UpdateContentTypeForNeedToFilter(out contentType, null);
            }
            return(AttachmentHandler.SendDocumentContentToHttpStream(httpContext, stream, fileName, fileExtension, contentType, false, null, BlockStatus.DontKnow, AttachmentPolicy.Level.Unknown, flag));
        }
 // Token: 0x0600071A RID: 1818 RVA: 0x00037968 File Offset: 0x00035B68
 public void ProcessRequest(HttpContext httpContext)
 {
     ExTraceGlobals.AttachmentHandlingTracer.TraceDebug((long)this.GetHashCode(), "AttachmentHandler.ProcessRequest");
     try
     {
         AttachmentUtility.UpdateAcceptEncodingHeader(httpContext);
         OwaContext  owaContext           = OwaContext.Get(httpContext);
         UserContext userContext          = owaContext.UserContext;
         string      text                 = Utilities.GetQueryStringParameter(httpContext.Request, "id");
         string      queryStringParameter = Utilities.GetQueryStringParameter(httpContext.Request, "dla", false);
         bool        flag                 = queryStringParameter == null && this.IsVoiceMailAttachment(httpContext);
         if (flag)
         {
             text = Utilities.GetStringfromBase64String(text);
         }
         OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromString(text);
         using (Item item = Utilities.GetItem <Item>(userContext, owaStoreObjectId, new PropertyDefinition[0]))
         {
             if (item == null)
             {
                 ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessRequest: Unable to retrieve parent item for attachment");
             }
             else
             {
                 if (userContext.IsIrmEnabled && !userContext.IsBasicExperience)
                 {
                     Utilities.IrmDecryptIfRestricted(item, userContext, true);
                 }
                 if (queryStringParameter == null)
                 {
                     this.DownloadOneAttachment(item, userContext, httpContext, flag);
                 }
                 else
                 {
                     string queryStringParameter2 = Utilities.GetQueryStringParameter(httpContext.Request, "femb", false);
                     if (queryStringParameter2 != null)
                     {
                         using (Item embeddedItem = AttachmentUtility.GetEmbeddedItem(item, httpContext.Request, userContext))
                         {
                             if (embeddedItem != null)
                             {
                                 this.DownloadAllAttachments(embeddedItem, httpContext, userContext);
                             }
                             else
                             {
                                 ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessRequest: Failure to obtain reference to embedded item containing attachment");
                             }
                             goto IL_12E;
                         }
                     }
                     this.DownloadAllAttachments(item, httpContext, userContext);
                 }
                 IL_12E :;
             }
         }
     }
     catch (ThreadAbortException)
     {
         OwaContext.Get(httpContext).UnlockMinResourcesOnCriticalError();
     }
 }