コード例 #1
0
        public void EndUseNotificationPipe(IAsyncResult async)
        {
            if (this.isDisposing)
            {
                return;
            }
            OwaAsyncResult owaAsyncResult = (OwaAsyncResult)async;

            if (HttpContext.Current != null && OwaContext.Current != base.OwaContext)
            {
                base.OwaContext.IgnoreUnlockForcefully = true;
            }
            try
            {
                if (owaAsyncResult.Exception != null)
                {
                    bool             isBasicAuthentication        = Utilities.IsBasicAuthentication(base.OwaContext.HttpContext.Request);
                    ErrorInformation exceptionHandlingInformation = Utilities.GetExceptionHandlingInformation(owaAsyncResult.Exception, base.OwaContext.MailboxIdentity, Utilities.IsWebPartRequest(base.OwaContext), string.Empty, string.Empty, isBasicAuthentication);
                    Exception        ex = (owaAsyncResult.Exception.InnerException == null) ? owaAsyncResult.Exception : owaAsyncResult.Exception.InnerException;
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "An exception was thrown during the processing of the async request");
                    StringBuilder stringBuilder = new StringBuilder();
                    using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
                    {
                        OwaEventHttpHandler.RenderErrorDiv(base.OwaContext, stringWriter, exceptionHandlingInformation.Message, exceptionHandlingInformation.MessageDetails, exceptionHandlingInformation.OwaEventHandlerErrorCode, exceptionHandlingInformation.HideDebugInformation ? null : ex);
                    }
                    if (this.response != null)
                    {
                        this.response.WriteError(Utilities.JavascriptEncode(stringBuilder.ToString()));
                        base.OwaContext.ErrorSent = true;
                    }
                }
                if (this.response != null)
                {
                    this.response.WriteLastChunk();
                }
            }
            catch (OwaNotificationPipeWriteException)
            {
            }
            finally
            {
                if (owaAsyncResult.Exception != null)
                {
                    Utilities.HandleException(base.OwaContext, owaAsyncResult.Exception);
                }
            }
        }
コード例 #2
0
        private string TryNavigateToInternalWssUnc(string uriParam, out ErrorInformation errorInformation)
        {
            errorInformation = null;
            if (base.UserContext.IsBasicExperience)
            {
                return(null);
            }
            Uri uri = Utilities.TryParseUri(uriParam);

            if (uri == null || string.IsNullOrEmpty(uri.Scheme) || string.IsNullOrEmpty(uri.Host))
            {
                return(null);
            }
            if (!DocumentLibraryUtilities.IsTrustedProtocol(uri.Scheme))
            {
                return(null);
            }
            if (!DocumentLibraryUtilities.IsInternalUri(uri.Host, base.UserContext))
            {
                return(null);
            }
            if (DocumentLibraryUtilities.IsBlockedHostName(uri.Host, base.UserContext))
            {
                return(null);
            }
            if (!DocumentLibraryUtilities.IsDocumentsAccessEnabled(base.UserContext))
            {
                return(null);
            }
            bool flag  = DocumentLibraryUtilities.IsNavigationToWSSAllowed(base.UserContext);
            bool flag2 = DocumentLibraryUtilities.IsNavigationToUNCAllowed(base.UserContext);
            bool flag3 = Redir.IsHttpOrHttps(uri.Scheme);
            bool flag4 = string.Equals(uri.Scheme, Uri.UriSchemeFile, StringComparison.OrdinalIgnoreCase);

            if ((flag3 && !flag) || (flag4 && !flag2))
            {
                return(null);
            }
            ClassifyResult documentLibraryObjectId = DocumentLibraryUtilities.GetDocumentLibraryObjectId(uri, base.UserContext);

            if (documentLibraryObjectId == null || documentLibraryObjectId.Error != ClassificationError.None)
            {
                return(null);
            }
            DocumentLibraryObjectId objectId = documentLibraryObjectId.ObjectId;

            if (objectId == null)
            {
                return(null);
            }
            if (objectId.UriFlags == UriFlags.Other)
            {
                return(null);
            }
            UriFlags uriFlags = objectId.UriFlags;
            bool     flag5    = (uriFlags & UriFlags.SharepointDocument) == UriFlags.SharepointDocument;
            bool     flag6    = (uriFlags & UriFlags.UncDocument) == UriFlags.UncDocument;

            if ((uriFlags & UriFlags.DocumentLibrary) == UriFlags.DocumentLibrary || (uriFlags & UriFlags.Folder) == UriFlags.Folder || uriFlags == UriFlags.Sharepoint || uriFlags == UriFlags.Unc)
            {
                return(string.Concat(new string[]
                {
                    OwaUrl.ApplicationRoot.GetExplicitUrl(base.OwaContext),
                    "?ae=Folder&t=IPF.DocumentLibrary&id=",
                    Utilities.UrlEncode(objectId.ToBase64String()),
                    "&URL=",
                    Utilities.UrlEncode(uriParam)
                }));
            }
            if (flag5)
            {
                if (!base.UserContext.IsBasicExperience && DocumentLibraryUtilities.IsWebReadyDocument(objectId, base.UserContext))
                {
                    this.openWebReadyForm = true;
                    return("WebReadyView.aspx?t=wss&id=" + Utilities.UrlEncode(objectId.ToBase64String()) + "&URL=" + Utilities.UrlEncode(uriParam));
                }
                return(string.Concat(new string[]
                {
                    "ev.owa?ns=SharepointDocument&ev=GetDoc&id=",
                    Utilities.UrlEncode(objectId.ToBase64String()),
                    "&URL=",
                    Utilities.UrlEncode(uriParam),
                    Utilities.GetCanaryRequestParameter()
                }));
            }
            else
            {
                if (!flag6)
                {
                    return(null);
                }
                if (!base.UserContext.IsBasicExperience && DocumentLibraryUtilities.IsWebReadyDocument(objectId, base.UserContext))
                {
                    this.openWebReadyForm = true;
                    return("WebReadyView.aspx?t=unc&id=" + Utilities.UrlEncode(objectId.ToBase64String()) + "&URL=" + Utilities.UrlEncode(uriParam));
                }
                return(string.Concat(new string[]
                {
                    "ev.owa?ns=UncDocument&ev=GetDoc&id=",
                    Utilities.UrlEncode(objectId.ToBase64String()),
                    "&URL=",
                    Utilities.UrlEncode(uriParam),
                    Utilities.GetCanaryRequestParameter()
                }));
            }
        }
コード例 #3
0
        public void InvokeTaskManager()
        {
            if (!AppSettings.GetConfiguredValue <bool>("TranscodingServiceEnabled", false))
            {
                this.HandleFault(LocalizedStrings.GetNonEncoded(500694802));
                return;
            }
            AttachmentPolicy attachmentPolicy = this.owaContext.UserContext.AttachmentPolicy;

            using (Stream stream = this.LoadDocument(true, out this.decryptionStatus))
            {
                if (this.decryptionStatus.Failed)
                {
                    SanitizedHtmlString irmErrorDetails = WebReadyViewUtilities.GetIrmErrorDetails(this.owaContext.UserContext, this.decryptionStatus);
                    this.HandleFault(irmErrorDetails.ToString());
                }
                else if (!attachmentPolicy.WebReadyDocumentViewingEnable)
                {
                    this.HandleFault(LocalizedStrings.GetNonEncoded(500694802));
                }
                else if (!AttachmentUtility.IsWebReadyDocument(this.fileExtension, this.mimeType))
                {
                    this.HandleFault(LocalizedStrings.GetNonEncoded(-1584334964));
                }
                else
                {
                    try
                    {
                        byte[] bytes = Encoding.Default.GetBytes(this.documentIdStringBuilder.ToString());
                        byte[] value = null;
                        using (MessageDigestForNonCryptographicPurposes messageDigestForNonCryptographicPurposes = new MessageDigestForNonCryptographicPurposes())
                        {
                            value = messageDigestForNonCryptographicPurposes.ComputeHash(bytes);
                        }
                        WebReadyViewUtilities.InitializeTranscodingService();
                        Utilities.MakePageNoCacheNoStore(this.owaContext.HttpContext.Response);
                        string sourceDocType = string.IsNullOrEmpty(this.fileExtension) ? this.mimeType : this.fileExtension.TrimStart(new char[]
                        {
                            '.'
                        });
                        try
                        {
                            TranscodingTaskManager.Transcode(BitConverter.ToString(value), this.owaContext.UserContext.Key.UserContextId, stream, sourceDocType, this.currentPageNumber, out this.totalPageNumber, this.owaContext.HttpContext.Response);
                        }
                        catch (TranscodingCrashException innerException)
                        {
                            OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingWorkerProcessFails, string.Empty, new object[]
                            {
                                this.owaContext.LogonIdentity.GetLogonName(),
                                this.owaContext.LogonIdentity.UserSid.Value,
                                this.messageFrom,
                                this.messageSubject,
                                this.messageId,
                                this.documentPath,
                                this.documentIdStringBuilder.ToString()
                            });
                            throw new TranscodingUnconvertibleFileException("Transcoding service crash when converting the document.", innerException, this);
                        }
                        if (this.currentPageNumber == 0)
                        {
                            this.currentPageNumber = this.totalPageNumber;
                        }
                    }
                    catch (TranscodingException ex)
                    {
                        ExTraceGlobals.TranscodingTracer.TraceDebug <Type, string>(0L, "Exception: Type: {0} Error: {1}.", ex.GetType(), ex.Message);
                        ErrorInformation exceptionHandlingInformation = Utilities.GetExceptionHandlingInformation(ex, this.owaContext.MailboxIdentity);
                        this.HandleFault(exceptionHandlingInformation.Message);
                    }
                }
            }
        }
コード例 #4
0
        protected override void OnLoad(EventArgs e)
        {
            if (Redir.IsUrlRefererFBALogonPage(base.Request.UrlReferrer))
            {
                Utilities.EndResponse(this.Context, HttpStatusCode.Forbidden);
            }
            string queryStringParameter;
            bool   signedUrl = Redir.GetSignedUrl(base.Request, base.UserContext.Key.Canary.UserContextIdGuid, base.UserContext.Key.Canary.LogonUniqueKey, out queryStringParameter);

            if (!signedUrl)
            {
                queryStringParameter = Utilities.GetQueryStringParameter(base.Request, "URL");
            }
            string queryStringParameter2 = Utilities.GetQueryStringParameter(base.Request, "TranslatedURL", false);
            bool   flag  = !string.IsNullOrEmpty(queryStringParameter2);
            bool   flag2 = string.IsNullOrEmpty(Utilities.GetQueryStringParameter(base.Request, "NoDocLnkCls", false));

            if (Redir.IsSafeUrl(queryStringParameter, base.Request))
            {
                ErrorInformation errorInformation = null;
                Uri uri;
                if (null == (uri = Utilities.TryParseUri(queryStringParameter)))
                {
                    Utilities.EndResponse(this.Context, HttpStatusCode.Forbidden);
                }
                string scheme = uri.Scheme;
                if (CultureInfo.InvariantCulture.CompareInfo.Compare(scheme, "mailto", CompareOptions.IgnoreCase) == 0)
                {
                    StringBuilder stringBuilder = new StringBuilder(512);
                    stringBuilder.Append(OwaUrl.ApplicationRoot.GetExplicitUrl(base.OwaContext));
                    stringBuilder.Append("?ae=Item&a=New&t=");
                    string value = "IPM.Note";
                    if (base.UserContext.IsSmsEnabled)
                    {
                        int length = "mailto:".Length;
                        if (queryStringParameter.Length > length)
                        {
                            string       inputString = queryStringParameter.Substring(length);
                            Participant  participant;
                            ProxyAddress proxyAddress;
                            if (Participant.TryParse(inputString, out participant) && ImceaAddress.IsImceaAddress(participant.EmailAddress) && SmtpProxyAddress.TryDeencapsulate(participant.EmailAddress, out proxyAddress) && Utilities.IsMobileRoutingType(proxyAddress.PrefixString))
                            {
                                value = "IPM.Note.Mobile.SMS";
                            }
                        }
                    }
                    stringBuilder.Append(value);
                    stringBuilder.Append('&');
                    stringBuilder.Append("email");
                    stringBuilder.Append('=');
                    stringBuilder.Append(Utilities.UrlEncode(queryStringParameter));
                    this.safeUrl = stringBuilder.ToString();
                    this.isNewMailLinkCreated = true;
                    return;
                }
                if (flag2)
                {
                    this.safeUrl = this.TryNavigateToInternalWssUnc(queryStringParameter, out errorInformation);
                }
                if (this.safeUrl == null)
                {
                    if (flag && Redir.IsSafeUrl(queryStringParameter2, base.Request))
                    {
                        this.safeUrl = queryStringParameter2;
                    }
                    else
                    {
                        if (errorInformation != null)
                        {
                            Utilities.TransferToErrorPage(base.OwaContext, errorInformation);
                            return;
                        }
                        this.safeUrl = queryStringParameter;
                    }
                }
            }
            else if (flag && Redir.IsSafeUrl(queryStringParameter2, base.Request))
            {
                this.safeUrl = queryStringParameter2;
            }
            else
            {
                Utilities.EndResponse(this.Context, HttpStatusCode.Forbidden);
            }
            if (!signedUrl)
            {
                throw new OwaInvalidCanary14Exception(null, "Invalid canary in redir.aspx query.");
            }
        }