private Stream LoadWSSDocument(bool isLoadingStream)
        {
            if (!DocumentLibraryUtilities.IsNavigationToWSSAllowed(this.owaContext.UserContext))
            {
                throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
            }
            DocumentLibraryObjectId documentLibraryObjectId = DocumentLibraryUtilities.CreateDocumentLibraryObjectId(this.owaContext);
            SharepointSession       session            = this.owaContext.UserContext.LogonIdentity.CreateSharepointSession(documentLibraryObjectId);
            SharepointDocument      sharepointDocument = SharepointDocument.Read(session, documentLibraryObjectId);

            this.mimeType     = sharepointDocument.FileType;
            this.fileName     = Path.GetFileName(sharepointDocument.Uri.ToString());
            this.fileSize     = sharepointDocument.Size;
            this.documentPath = sharepointDocument.Uri.ToString();
            string queryStringParameter = Utilities.GetQueryStringParameter(this.owaContext.HttpContext.Request, "URL");

            this.openLink = string.Concat(new string[]
            {
                "ev.owa?ns=SharepointDocument&ev=GetDoc&allowLevel2=1&URL=",
                Utilities.UrlEncode(queryStringParameter),
                "&id=",
                Utilities.UrlEncode(documentLibraryObjectId.ToBase64String()),
                Utilities.GetCanaryRequestParameter()
            });
            this.documentIdStringBuilder.Append(documentLibraryObjectId.ToBase64String());
            this.documentIdStringBuilder.Append("-");
            this.documentIdStringBuilder.Append(sharepointDocument.VersionControl.TipVersion);
            if (!isLoadingStream)
            {
                return(null);
            }
            return(sharepointDocument.GetDocument());
        }
Example #2
0
        // Token: 0x0600303A RID: 12346 RVA: 0x0011AC24 File Offset: 0x00118E24
        internal static bool IsWebReadyDocument(DocumentLibraryObjectId objectId, UserContext userContext)
        {
            IDocument document;

            try
            {
                document = DocumentLibraryUtilities.LoadDocumentLibraryItem(objectId, userContext);
            }
            catch (AccessDeniedException)
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI access is denied.");
                return(false);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI object not found.");
                return(false);
            }
            if (document == null)
            {
                return(false);
            }
            PropertyDefinition propertyDefinition = null;

            if ((objectId.UriFlags & UriFlags.SharepointDocument) == UriFlags.SharepointDocument)
            {
                propertyDefinition = SharepointDocumentSchema.FileType;
            }
            else if ((objectId.UriFlags & UriFlags.UncDocument) == UriFlags.UncDocument)
            {
                propertyDefinition = UncDocumentSchema.FileType;
            }
            object obj = document.TryGetProperty(propertyDefinition);
            string mimeType;

            if (!(obj is PropertyError))
            {
                mimeType = (obj as string);
            }
            else
            {
                mimeType = string.Empty;
            }
            string fileName = Path.GetFileName(document.Uri.ToString());
            string fileExtension;

            if (string.IsNullOrEmpty(fileName))
            {
                fileExtension = string.Empty;
            }
            else
            {
                fileExtension = Path.GetExtension(fileName);
            }
            return(AttachmentUtility.IsWebReadyDocument(fileExtension, mimeType));
        }
Example #3
0
        // Token: 0x06002D5A RID: 11610 RVA: 0x000FE9BC File Offset: 0x000FCBBC
        protected void DataBind(DocumentLibraryObjectId objectId)
        {
            this.PreDataBind();
            IDocument document;

            try
            {
                document = DocumentLibraryUtilities.LoadDocumentLibraryItem(objectId, base.UserContext);
            }
            catch (AccessDeniedException)
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI access is denied.");
                Utilities.TransferToErrorPage(base.OwaContext, LocalizedStrings.GetNonEncoded(234621291));
                return;
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI object not found.");
                Utilities.TransferToErrorPage(base.OwaContext, LocalizedStrings.GetNonEncoded(1599334062));
                return;
            }
            if (document == null)
            {
                throw new OwaInvalidRequestException("objectId is invalid for unc/wss document");
            }
            object obj = document.TryGetProperty(this.contentTypePropertyDefinition);

            if (!(obj is PropertyError))
            {
                this.contentType = (obj as string);
            }
            else
            {
                this.contentType = string.Empty;
            }
            this.stream   = document.GetDocument();
            this.fileName = Path.GetFileName(document.Uri.ToString());
            if (!string.IsNullOrEmpty(this.fileName))
            {
                this.fileName = HttpUtility.UrlDecode(this.fileName);
            }
        }
        private Stream LoadUNCDocument(bool isLoadingStream)
        {
            if (!DocumentLibraryUtilities.IsNavigationToUNCAllowed(this.owaContext.UserContext))
            {
                throw new OwaSegmentationException("Access to Unc documents is disabled");
            }
            DocumentLibraryObjectId documentLibraryObjectId = DocumentLibraryUtilities.CreateDocumentLibraryObjectId(this.owaContext);
            UncSession  session     = this.owaContext.UserContext.LogonIdentity.CreateUncSession(documentLibraryObjectId);
            UncDocument uncDocument = UncDocument.Read(session, documentLibraryObjectId);

            this.mimeType     = (uncDocument[UncDocumentSchema.FileType] as string);
            this.fileName     = Path.GetFileName(uncDocument.Uri.ToString());
            this.fileSize     = uncDocument.Size;
            this.documentPath = uncDocument.Uri.ToString();
            string queryStringParameter = Utilities.GetQueryStringParameter(this.owaContext.HttpContext.Request, "URL");

            this.openLink = string.Concat(new string[]
            {
                "ev.owa?ns=UncDocument&ev=GetDoc&allowLevel2=1&URL=",
                Utilities.UrlEncode(queryStringParameter),
                "&id=",
                Utilities.UrlEncode(documentLibraryObjectId.ToBase64String()),
                Utilities.GetCanaryRequestParameter()
            });
            this.documentIdStringBuilder.Append(documentLibraryObjectId.ToBase64String());
            this.documentIdStringBuilder.Append("-");
            object obj = uncDocument.TryGetProperty(UncItemSchema.LastModifiedDate);

            if (obj is DateTime)
            {
                this.documentIdStringBuilder.Append(((DateTime)obj).Ticks);
            }
            if (!isLoadingStream)
            {
                return(null);
            }
            return(uncDocument.GetDocument());
        }
Example #5
0
        // Token: 0x0600303B RID: 12347 RVA: 0x0011AD14 File Offset: 0x00118F14
        internal static IDocument LoadDocumentLibraryItem(DocumentLibraryObjectId objectId, UserContext userContext)
        {
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            IDocument result = null;

            if ((objectId.UriFlags & UriFlags.SharepointDocument) == UriFlags.SharepointDocument)
            {
                SharepointSession session = userContext.LogonIdentity.CreateSharepointSession(objectId);
                result = SharepointDocument.Read(session, objectId);
            }
            else if ((objectId.UriFlags & UriFlags.UncDocument) == UriFlags.UncDocument)
            {
                UncSession session2 = userContext.LogonIdentity.CreateUncSession(objectId);
                result = UncDocument.Read(session2, objectId);
            }
            return(result);
        }
Example #6
0
        public void GetDocument()
        {
            bool flag = false;

            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentEventHandler.GetDocument");
            base.ShowErrorInPage  = true;
            base.DontWriteHeaders = true;
            HttpContext httpContext = base.OwaContext.HttpContext;

            if (!DocumentLibraryUtilities.IsDocumentsAccessEnabled(base.UserContext))
            {
                throw new OwaSegmentationException("Access to this document library is disabled");
            }
            string text = (string)base.GetParameter("id");
            string s    = (string)base.GetParameter("URL");
            DocumentLibraryObjectId documentLibraryObjectId = DocumentLibraryUtilities.CreateDocumentLibraryObjectId(base.OwaContext);

            if (documentLibraryObjectId == null)
            {
                return;
            }
            try
            {
                this.DataBind(documentLibraryObjectId);
            }
            finally
            {
                if (this.stream == null)
                {
                    this.Dispose();
                }
            }
            if (this.stream == null)
            {
                return;
            }
            UserContext userContext = base.OwaContext.UserContext;

            AttachmentPolicy.Level levelForAttachment = AttachmentLevelLookup.GetLevelForAttachment(Path.GetExtension(this.fileName), this.contentType, userContext);
            if (base.IsParameterSet("allowLevel2"))
            {
                flag = true;
            }
            if (levelForAttachment == AttachmentPolicy.Level.Block)
            {
                string errorDescription = string.Format(CultureInfo.InvariantCulture, LocalizedStrings.GetNonEncoded(1280363351), new object[]
                {
                    this.fileName
                });
                Utilities.TransferToErrorPage(base.OwaContext, errorDescription, null, ThemeFileId.ButtonDialogInfo, true);
                return;
            }
            if (levelForAttachment == AttachmentPolicy.Level.ForceSave && !flag)
            {
                string queryStringParameter = Utilities.GetQueryStringParameter(httpContext.Request, "ns");
                string text2 = string.Concat(new string[]
                {
                    "<br> <a onclick=\"return false;\" href=\"ev.owa?ns=",
                    queryStringParameter,
                    "&ev=GetDoc&allowLevel2=1&URL=",
                    Utilities.UrlEncode(s),
                    "&id=",
                    Utilities.UrlEncode(documentLibraryObjectId.ToBase64String()),
                    Utilities.GetCanaryRequestParameter(),
                    "\">",
                    Utilities.HtmlEncode(this.fileName),
                    "</a>"
                });
                string errorDetailedDescription = string.Format(CultureInfo.InvariantCulture, LocalizedStrings.GetHtmlEncoded(-625229753), new object[]
                {
                    text2
                });
                Utilities.TransferToErrorPage(base.OwaContext, LocalizedStrings.GetHtmlEncoded(-226672911), errorDetailedDescription, ThemeFileId.ButtonDialogInfo, true, true);
                return;
            }
            int num = AttachmentHandler.SendDocumentContentToHttpStream(httpContext, this.stream, this.fileName, DocumentEventHandler.CalculateFileExtension(this.fileName), this.contentType);

            if (this.contentType != null && this.contentType.Equals("application/x-zip-compressed", StringComparison.OrdinalIgnoreCase))
            {
                Utilities.DisableContentEncodingForThisResponse(base.OwaContext.HttpContext.Response);
            }
            if (Globals.ArePerfCountersEnabled)
            {
                if ((documentLibraryObjectId.UriFlags & UriFlags.Sharepoint) != (UriFlags)0)
                {
                    OwaSingleCounters.WssBytes.IncrementBy((long)num);
                    OwaSingleCounters.WssRequests.Increment();
                    return;
                }
                if ((documentLibraryObjectId.UriFlags & UriFlags.Unc) != (UriFlags)0)
                {
                    OwaSingleCounters.UncBytes.IncrementBy((long)num);
                    OwaSingleCounters.UncRequests.Increment();
                }
            }
        }
Example #7
0
 internal abstract SharepointSession CreateSharepointSession(DocumentLibraryObjectId objectId);
Example #8
0
 internal abstract UncSession CreateUncSession(DocumentLibraryObjectId objectId);
 // Token: 0x06000D69 RID: 3433 RVA: 0x00059715 File Offset: 0x00057915
 internal override SharepointSession CreateSharepointSession(DocumentLibraryObjectId objectId)
 {
     base.ThrowNotSupported("CreateSharepointSession");
     return(null);
 }
Example #10
0
        public void SendByEmail()
        {
            ExTraceGlobals.DocumentsCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentLibraryEventHandler.SendByEmail");
            MessageItem messageItem = null;

            string[] array  = (string[])base.GetParameter("uri");
            Stream   stream = null;
            bool     flag   = DocumentLibraryUtilities.IsNavigationToWSSAllowed(base.UserContext);
            bool     flag2  = DocumentLibraryUtilities.IsNavigationToUNCAllowed(base.UserContext);

            try
            {
                for (int i = 0; i < array.Length; i++)
                {
                    ClassifyResult documentLibraryObjectId = DocumentLibraryUtilities.GetDocumentLibraryObjectId(array[i], base.UserContext);
                    if (documentLibraryObjectId == null)
                    {
                        ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Could not classify link: " + array[i]);
                        throw new OwaEventHandlerException("Could not add attachment to email", LocalizedStrings.GetNonEncoded(1948229493), OwaEventHandlerErrorCode.SendByEmailError);
                    }
                    DocumentLibraryObjectId objectId = documentLibraryObjectId.ObjectId;
                    if (objectId == null)
                    {
                        ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "ObjectId could not be created from URI parameter: " + array[i]);
                        throw new OwaEventHandlerException("Could not add attachment to email", LocalizedStrings.GetNonEncoded(1948229493), OwaEventHandlerErrorCode.SendByEmailError);
                    }
                    UriFlags uriFlags = objectId.UriFlags;
                    try
                    {
                        string text;
                        switch (uriFlags)
                        {
                        case UriFlags.SharepointDocument:
                        {
                            if (!flag)
                            {
                                throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                            }
                            SharepointSession  session            = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                            SharepointDocument sharepointDocument = SharepointDocument.Read(session, objectId);
                            stream = sharepointDocument.GetDocument();
                            text   = (string.IsNullOrEmpty(sharepointDocument.DisplayName) ? LocalizedStrings.GetNonEncoded(1797976510) : sharepointDocument.DisplayName);
                            break;
                        }

                        case UriFlags.UncDocument:
                        {
                            if (!flag2)
                            {
                                throw new OwaSegmentationException("Access to Unc documents is disabled");
                            }
                            UncSession  session2    = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                            UncDocument uncDocument = UncDocument.Read(session2, objectId);
                            stream = uncDocument.GetDocument();
                            text   = Path.GetFileName(uncDocument.Uri.ToString());
                            if (!string.IsNullOrEmpty(text))
                            {
                                text = HttpUtility.UrlDecode(text);
                            }
                            break;
                        }

                        default:
                            throw new OwaNotSupportedException("Unhandled document library type");
                        }
                        if (messageItem == null)
                        {
                            messageItem = MessageItem.Create(base.UserContext.MailboxSession, base.UserContext.DraftsFolderId);
                            messageItem[ItemSchema.ConversationIndexTracking] = true;
                        }
                        int num;
                        AttachmentAddResult attachmentAddResult = AttachmentUtility.AddAttachmentFromStream(messageItem, text, null, stream, base.UserContext, out num);
                        if (Globals.ArePerfCountersEnabled)
                        {
                            if (uriFlags == UriFlags.UncDocument)
                            {
                                OwaSingleCounters.UncRequests.Increment();
                                OwaSingleCounters.UncBytes.IncrementBy((long)num);
                            }
                            else
                            {
                                OwaSingleCounters.WssRequests.Increment();
                                OwaSingleCounters.WssBytes.IncrementBy((long)num);
                            }
                        }
                        if (attachmentAddResult.ResultCode != AttachmentAddResultCode.NoError)
                        {
                            throw new OwaEventHandlerException("Could not add attachment to email. " + attachmentAddResult.Message, LocalizedStrings.GetNonEncoded(1948229493), OwaEventHandlerErrorCode.SendByEmailError);
                        }
                    }
                    finally
                    {
                        if (stream != null)
                        {
                            stream.Close();
                            stream = null;
                        }
                    }
                }
                messageItem.Save(SaveMode.ResolveConflicts);
                messageItem.Load();
                this.Writer.Write(messageItem.Id.ObjectId.ToBase64String());
            }
            finally
            {
                if (messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
        }
Example #11
0
        public void ClassifyLink()
        {
            ExTraceGlobals.DocumentsCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentLibraryEventHandler.ClassifyLink");
            string text = (string)base.GetParameter("uri");
            Uri    uri  = Utilities.TryParseUri(text);

            if (uri == null && !text.StartsWith("\\\\", StringComparison.Ordinal))
            {
                text = "http://" + text;
                uri  = Utilities.TryParseUri(text);
            }
            if (uri == null || string.IsNullOrEmpty(uri.Scheme) || string.IsNullOrEmpty(uri.Host))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Cannot parse a Uri from string.");
                base.RenderPartialFailure(-2054976140, new Strings.IDs?(-381883412), ButtonDialogIcon.Warning);
                return;
            }
            if (!DocumentLibraryUtilities.IsTrustedProtocol(uri.Scheme))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI protocol is not http, https or file.");
                base.RenderPartialFailure(1453018462, new Strings.IDs?(-743095750), ButtonDialogIcon.Information);
                return;
            }
            if (!DocumentLibraryUtilities.IsInternalUri(uri.Host, base.UserContext))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Not an internal URI");
                base.RenderPartialFailure(-1721073157, new Strings.IDs?(1325518514), ButtonDialogIcon.Warning);
                return;
            }
            if (DocumentLibraryUtilities.IsBlockedHostName(uri.Host, base.UserContext))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Host name is in the blocked list.");
                base.RenderPartialFailure(343095135, new Strings.IDs?(-777407791), ButtonDialogIcon.Warning);
                return;
            }
            ClassifyResult documentLibraryObjectId = DocumentLibraryUtilities.GetDocumentLibraryObjectId(uri, base.UserContext);

            if (documentLibraryObjectId.Error != ClassificationError.None)
            {
                if (documentLibraryObjectId.Error == ClassificationError.ConnectionFailed)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Connection could not be made to server.");
                    base.RenderPartialFailure(678272416, new Strings.IDs?(-820112926), ButtonDialogIcon.Warning);
                    return;
                }
                if (documentLibraryObjectId.Error == ClassificationError.ObjectNotFound)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI object not found.");
                    base.RenderPartialFailure(-54320700, new Strings.IDs?(1599334062), ButtonDialogIcon.Warning);
                    return;
                }
                if (documentLibraryObjectId.Error == ClassificationError.AccessDenied)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI access is denied.");
                    if (Utilities.IsBasicAuthentication(base.OwaContext.HttpContext.Request))
                    {
                        base.RenderPartialFailure(234621291, new Strings.IDs?(-3401788), ButtonDialogIcon.Warning);
                        return;
                    }
                    base.RenderPartialFailure(1819837349, new Strings.IDs?(-3401788), ButtonDialogIcon.Warning);
                    return;
                }
                else
                {
                    if (documentLibraryObjectId.Error == ClassificationError.UriTypeNotSupported)
                    {
                        ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI is not supported.");
                        base.RenderPartialFailure(1453018462, new Strings.IDs?(-743095750), ButtonDialogIcon.Information);
                        return;
                    }
                    if (documentLibraryObjectId.Error == ClassificationError.InvalidUri)
                    {
                        ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI was Invalid.");
                        base.RenderPartialFailure(-2054976140, new Strings.IDs?(-381883412), ButtonDialogIcon.Warning);
                        return;
                    }
                    if (documentLibraryObjectId.Error == ClassificationError.ProxyError)
                    {
                        ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI was Invalid.");
                        base.RenderPartialFailure(1454208029, new Strings.IDs?(1335662059), ButtonDialogIcon.Warning);
                        return;
                    }
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Other classification error.  ClassifyResult.Error: " + documentLibraryObjectId.Error.ToString());
                    base.RenderPartialFailure(-785304559, new Strings.IDs?(-86901060), ButtonDialogIcon.Warning);
                    return;
                }
            }
            else
            {
                DocumentLibraryObjectId objectId = documentLibraryObjectId.ObjectId;
                if (objectId == null)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "ObjectId could not be created from Uri");
                    base.RenderPartialFailure(-2054976140, new Strings.IDs?(-381883412), ButtonDialogIcon.Warning);
                    return;
                }
                UriFlags uriFlags = objectId.UriFlags;
                bool     flag     = (uriFlags & UriFlags.Sharepoint) == UriFlags.Sharepoint;
                bool     flag2    = (uriFlags & UriFlags.Unc) == UriFlags.Unc;
                bool     flag3    = DocumentLibraryUtilities.IsNavigationToWSSAllowed(base.UserContext);
                bool     flag4    = DocumentLibraryUtilities.IsNavigationToUNCAllowed(base.UserContext);
                if (objectId.UriFlags == UriFlags.Other)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Link could not be classified as Sharepoint or UNC");
                    if (flag4 && flag3)
                    {
                        base.RenderPartialFailure(1528018289, new Strings.IDs?(-743095750), ButtonDialogIcon.Information);
                        return;
                    }
                    if (flag4)
                    {
                        base.RenderPartialFailure(-1758685302, new Strings.IDs?(-743095750), ButtonDialogIcon.Information);
                        return;
                    }
                    if (flag3)
                    {
                        base.RenderPartialFailure(762710799, new Strings.IDs?(-743095750), ButtonDialogIcon.Information);
                    }
                    return;
                }
                else
                {
                    if ((flag2 && !flag4) || (flag && !flag3))
                    {
                        ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Segmentation failure. Access Denied");
                        base.RenderPartialFailure(flag2 ? 813043446 : -972777689, new Strings.IDs?(-3401788), ButtonDialogIcon.Warning);
                        return;
                    }
                    this.Writer.Write("<div id=uri>");
                    this.Writer.Write(text);
                    this.Writer.Write("</div><div id=uf>");
                    this.Writer.Write((int)uriFlags);
                    this.Writer.Write("</div><div id=oid>");
                    this.Writer.Write(objectId.ToBase64String());
                    this.Writer.Write("</div>");
                    AttachmentPolicy attachmentPolicy = base.UserContext.AttachmentPolicy;
                    this.Writer.Write("<div id=divFwr>");
                    this.Writer.Write((attachmentPolicy.ForceWebReadyDocumentViewingFirst && DocumentLibraryUtilities.IsWebReadyDocument(objectId, base.UserContext)) ? 1 : 0);
                    this.Writer.Write("</div>");
                    return;
                }
            }
        }
Example #12
0
        public void AddFavoriteLibrary()
        {
            ExTraceGlobals.DocumentsCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentLibraryEventHandler.AddFavoriteLibrary");
            string[] array = (string[])base.GetParameter("uri");
            bool     flag  = false;

            this.Writer.Write("<div id=divAFavLibs>");
            for (int i = 0; i < array.Length; i++)
            {
                ClassifyResult documentLibraryObjectId = DocumentLibraryUtilities.GetDocumentLibraryObjectId(array[i], base.UserContext);
                if (documentLibraryObjectId == null)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Could not classify link: " + array[i]);
                }
                else
                {
                    DocumentLibraryObjectId objectId = documentLibraryObjectId.ObjectId;
                    if (objectId != null)
                    {
                        UriFlags        uriFlags        = objectId.UriFlags;
                        DocumentLibrary documentLibrary = new DocumentLibrary();
                        bool            flag2           = DocumentLibraryUtilities.IsNavigationToWSSAllowed(base.UserContext);
                        bool            flag3           = DocumentLibraryUtilities.IsNavigationToUNCAllowed(base.UserContext);
                        UriFlags        uriFlags2       = uriFlags;
                        switch (uriFlags2)
                        {
                        case UriFlags.Sharepoint:
                            {
                                if (!flag2)
                                {
                                    throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                                }
                                SharepointSession sharepointSession = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                                documentLibrary.DisplayName = (string.IsNullOrEmpty(sharepointSession.DisplayName) ? LocalizedStrings.GetNonEncoded(-527057840) : sharepointSession.DisplayName);
                                documentLibrary.SiteName    = sharepointSession.DisplayName;
                                break;
                            }

                        case UriFlags.Unc:
                            {
                                if (!flag3)
                                {
                                    throw new OwaSegmentationException("Access to Unc documents is disabled");
                                }
                                UncSession uncSession = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                                documentLibrary.DisplayName = uncSession.Title;
                                documentLibrary.SiteName    = uncSession.Uri.Host;
                                break;
                            }

                        case UriFlags.Sharepoint | UriFlags.Unc:
                        case UriFlags.DocumentLibrary:
                            goto IL_34F;

                        case UriFlags.SharepointDocumentLibrary:
                        {
                            if (!flag2)
                            {
                                throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                            }
                            SharepointSession         sharepointSession2        = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                            SharepointDocumentLibrary sharepointDocumentLibrary = SharepointDocumentLibrary.Read(sharepointSession2, objectId);
                            documentLibrary.DisplayName = (string.IsNullOrEmpty(sharepointDocumentLibrary.Title) ? LocalizedStrings.GetNonEncoded(477016274) : sharepointDocumentLibrary.Title);
                            documentLibrary.SiteName    = sharepointSession2.DisplayName;
                            break;
                        }

                        case UriFlags.UncDocumentLibrary:
                        {
                            if (!flag3)
                            {
                                throw new OwaSegmentationException("Access to Unc documents is disabled");
                            }
                            UncSession         session            = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                            UncDocumentLibrary uncDocumentLibrary = UncDocumentLibrary.Read(session, objectId);
                            documentLibrary.DisplayName = (string.IsNullOrEmpty(uncDocumentLibrary.Title) ? LocalizedStrings.GetNonEncoded(477016274) : uncDocumentLibrary.Title);
                            documentLibrary.SiteName    = uncDocumentLibrary.Uri.Host;
                            break;
                        }

                        default:
                            switch (uriFlags2)
                            {
                            case UriFlags.SharepointFolder:
                            {
                                if (!flag2)
                                {
                                    throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                                }
                                SharepointSession sharepointSession3 = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                                SharepointDocumentLibraryFolder sharepointDocumentLibraryFolder = SharepointDocumentLibraryFolder.Read(sharepointSession3, objectId);
                                documentLibrary.DisplayName = (string.IsNullOrEmpty(sharepointDocumentLibraryFolder.DisplayName) ? LocalizedStrings.GetNonEncoded(-527057840) : sharepointDocumentLibraryFolder.DisplayName);
                                documentLibrary.SiteName    = sharepointSession3.DisplayName;
                                break;
                            }

                            case UriFlags.UncFolder:
                            {
                                if (!flag3)
                                {
                                    throw new OwaSegmentationException("Access to Unc documents is disabled");
                                }
                                UncSession session2 = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                                UncDocumentLibraryFolder uncDocumentLibraryFolder = UncDocumentLibraryFolder.Read(session2, objectId);
                                documentLibrary.DisplayName = (string.IsNullOrEmpty(uncDocumentLibraryFolder.DisplayName) ? LocalizedStrings.GetNonEncoded(-527057840) : uncDocumentLibraryFolder.DisplayName);
                                documentLibrary.SiteName    = uncDocumentLibraryFolder.Uri.Host;
                                break;
                            }

                            default:
                                goto IL_34F;
                            }
                            break;
                        }
                        documentLibrary.Type = uriFlags;
                        documentLibrary.Uri  = array[i];
                        int num = 0;
                        if (DocumentLibraryUtilities.AddFavorite(documentLibrary, base.UserContext, out num) && num <= 1000)
                        {
                            DocumentLibraryUtilities.RenderLibraryItem(this.Writer, documentLibrary, base.UserContext, true);
                            flag = true;
                            goto IL_3A0;
                        }
                        goto IL_3A0;
                        IL_34F:
                        throw new OwaNotSupportedException("Unhandled document library type");
                    }
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "ObjectId could not be created from URI parameter: " + array[i]);
                }
                IL_3A0 :;
            }
            this.Writer.Write("</div>");
            if (flag)
            {
                this.Writer.Write("<div id=divMsgFav>");
                this.Writer.Write(LocalizedStrings.GetHtmlEncoded(344777715));
                this.Writer.Write("</div><div id=divMsgTtl>");
                this.Writer.Write(LocalizedStrings.GetHtmlEncoded(803639727));
            }
            else
            {
                this.Writer.Write("<div id=divNoLib>");
            }
            this.Writer.Write("</div>");
        }
Example #13
0
        // Token: 0x0600302E RID: 12334 RVA: 0x00119E0C File Offset: 0x0011800C
        public static DocumentLibraryObjectId CreateDocumentLibraryObjectId(OwaContext owaContext)
        {
            DocumentLibraryObjectId documentLibraryObjectId = null;

            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            HttpContext httpContext          = owaContext.HttpContext;
            HttpRequest request              = httpContext.Request;
            string      queryStringParameter = Utilities.GetQueryStringParameter(request, "TranslatedURL", false);
            bool        flag = !string.IsNullOrEmpty(queryStringParameter);
            string      queryStringParameter2 = Utilities.GetQueryStringParameter(request, "id", false);
            bool        flag2 = !string.IsNullOrEmpty(queryStringParameter2);
            Uri         uri;

            if (!flag2)
            {
                string queryStringParameter3 = Utilities.GetQueryStringParameter(request, "URL", false);
                uri = Utilities.TryParseUri(queryStringParameter3);
            }
            else
            {
                documentLibraryObjectId = DocumentLibraryObjectId.Deserialize(queryStringParameter2);
                if (documentLibraryObjectId == null)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Other classification error.  objectId " + queryStringParameter2);
                    Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(-785304559), null, ThemeFileId.Warning, true);
                    return(null);
                }
                if (documentLibraryObjectId is UncObjectId)
                {
                    uri = (documentLibraryObjectId as UncObjectId).Path;
                }
                else
                {
                    uri = (documentLibraryObjectId as SharepointSiteId).SiteUri;
                }
            }
            if (uri == null || string.IsNullOrEmpty(uri.Host) || string.IsNullOrEmpty(uri.Scheme))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI was Invalid.");
                Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(-2054976140), flag ? string.Format(LocalizedStrings.GetHtmlEncoded(-666455008), "<a href=\"" + Utilities.UrlEncode(queryStringParameter) + "\" target=\"_blank\" class=lnk>", "</a>") : null, ThemeFileId.Warning, true);
                return(null);
            }
            if (!DocumentLibraryUtilities.IsTrustedProtocol(uri.Scheme))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI protocol is not http, https or file.");
                Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(1453018462), null, ThemeFileId.ButtonDialogInfo, true);
                return(null);
            }
            if (!DocumentLibraryUtilities.IsInternalUri(uri.Host, owaContext.UserContext))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI was not internal.");
                Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(-1721073157), null, ThemeFileId.Warning, true);
                return(null);
            }
            if (DocumentLibraryUtilities.IsBlockedHostName(uri.Host, owaContext.UserContext))
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI was blocked.");
                Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(343095135), null, ThemeFileId.Warning, true);
                return(null);
            }
            ClassifyResult documentLibraryObjectId2 = DocumentLibraryUtilities.GetDocumentLibraryObjectId(uri, owaContext.UserContext);

            if (documentLibraryObjectId2.Error != ClassificationError.None)
            {
                string      errorDetailedDescription = null;
                ThemeFileId icon = ThemeFileId.Warning;
                string      nonEncoded;
                if (documentLibraryObjectId2.Error == ClassificationError.ConnectionFailed)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Connection could not be made to server.");
                    nonEncoded = LocalizedStrings.GetNonEncoded(678272416);
                }
                else if (documentLibraryObjectId2.Error == ClassificationError.ObjectNotFound)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI object not found.");
                    nonEncoded = LocalizedStrings.GetNonEncoded(-54320700);
                }
                else if (documentLibraryObjectId2.Error == ClassificationError.AccessDenied)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI access is denied.");
                    nonEncoded = LocalizedStrings.GetNonEncoded(234621291);
                }
                else if (documentLibraryObjectId2.Error == ClassificationError.UriTypeNotSupported)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI is not supported.");
                    nonEncoded = LocalizedStrings.GetNonEncoded(1453018462);
                    icon       = ThemeFileId.ButtonDialogInfo;
                }
                else if (documentLibraryObjectId2.Error == ClassificationError.InvalidUri)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI was Invalid.");
                    nonEncoded = LocalizedStrings.GetNonEncoded(-2054976140);
                    if (flag)
                    {
                        errorDetailedDescription = string.Format(LocalizedStrings.GetNonEncoded(-666455008), "<a href=\"" + queryStringParameter + "\" target=\"_blank\" class=lnk>", "</a>");
                    }
                }
                else
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Other classification error.  ClassifyResult.Error: " + documentLibraryObjectId2.Error.ToString());
                    nonEncoded = LocalizedStrings.GetNonEncoded(-785304559);
                }
                Utilities.TransferToErrorPage(owaContext, nonEncoded, errorDetailedDescription, icon, true);
                return(null);
            }
            if (!flag2)
            {
                documentLibraryObjectId = documentLibraryObjectId2.ObjectId;
            }
            return(documentLibraryObjectId);
        }
Example #14
0
 internal override SharepointSession CreateSharepointSession(DocumentLibraryObjectId objectId)
 {
     return(SharepointSession.Open(objectId, this.WindowsPrincipal));
 }
Example #15
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()
                }));
            }
        }