Esempio n. 1
0
 // Token: 0x06000D09 RID: 3337 RVA: 0x000585B8 File Offset: 0x000567B8
 private static OtherMailboxConfigEntry FindOtherMailboxConfigEntry(SimpleConfiguration <OtherMailboxConfigEntry> config, string legacyDN)
 {
     foreach (OtherMailboxConfigEntry otherMailboxConfigEntry in config.Entries)
     {
         OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromString(otherMailboxConfigEntry.RootFolderId);
         if (string.Equals(owaStoreObjectId.MailboxOwnerLegacyDN, legacyDN, StringComparison.OrdinalIgnoreCase))
         {
             return(otherMailboxConfigEntry);
         }
     }
     return(null);
 }
Esempio n. 2
0
 protected object ConvertToStrongType(Type paramType, string value)
 {
     if (string.IsNullOrEmpty(value))
     {
         this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Failed to parse type. Type = {0}, Value = {1}", new object[]
         {
             paramType,
             value
         }));
     }
     try
     {
         if (paramType.IsEnum)
         {
             OwaEventEnumAttribute owaEventEnumAttribute = OwaEventRegistry.FindEnumInfo(paramType);
             int    intValue = int.Parse(value, CultureInfo.InvariantCulture);
             object obj      = owaEventEnumAttribute.FindValueInfo(intValue);
             if (obj == null)
             {
                 this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Failed to parse enum type. Type = {0}, Value = {1}", new object[]
                 {
                     paramType,
                     value
                 }));
             }
             return(obj);
         }
         if (paramType == typeof(int))
         {
             return(int.Parse(value, CultureInfo.InvariantCulture));
         }
         if (paramType == typeof(double))
         {
             return(double.Parse(value, CultureInfo.InvariantCulture));
         }
         if (paramType == typeof(ExDateTime))
         {
             return(DateTimeUtilities.ParseIsoDate(value, this.EventHandler.OwaContext.SessionContext.TimeZone));
         }
         if (paramType == typeof(bool))
         {
             if (string.Equals(value, "0", StringComparison.Ordinal))
             {
                 return(false);
             }
             if (string.Equals(value, "1", StringComparison.Ordinal))
             {
                 return(true);
             }
             this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Failed to parse type. Type = {0}, Value = {1}", new object[]
             {
                 paramType,
                 value
             }));
         }
         else
         {
             if (paramType == typeof(StoreObjectId))
             {
                 UserContext userContext = this.EventHandler.OwaContext.UserContext;
                 return(Utilities.CreateStoreObjectId(userContext.MailboxSession, value));
             }
             if (paramType == typeof(ADObjectId))
             {
                 ADObjectId adobjectId = DirectoryAssistance.ParseADObjectId(value);
                 if (adobjectId == null)
                 {
                     this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Failed to parse type. Type = {0}, Value = {1}", new object[]
                     {
                         paramType,
                         value
                     }));
                 }
                 return(adobjectId);
             }
             if (paramType == typeof(DocumentLibraryObjectId))
             {
                 UserContext userContext2 = this.EventHandler.OwaContext.UserContext;
                 Uri         uri;
                 if (null == (uri = Utilities.TryParseUri(value)))
                 {
                     return(null);
                 }
                 ClassifyResult[]   array = null;
                 OwaWindowsIdentity owaWindowsIdentity = userContext2.LogonIdentity as OwaWindowsIdentity;
                 if (owaWindowsIdentity != null && owaWindowsIdentity.WindowsPrincipal != null)
                 {
                     array = LinkClassifier.ClassifyLinks(owaWindowsIdentity.WindowsPrincipal, new Uri[]
                     {
                         uri
                     });
                 }
                 if (array == null || array.Length == 0)
                 {
                     return(null);
                 }
                 return(array[0].ObjectId);
             }
             else if (paramType == typeof(OwaStoreObjectId))
             {
                 UserContext userContext3 = this.EventHandler.OwaContext.UserContext;
                 if (OwaStoreObjectId.IsDummyArchiveFolder(value))
                 {
                     return(userContext3.GetArchiveRootFolderId());
                 }
                 return(OwaStoreObjectId.CreateFromString(value));
             }
             else
             {
                 this.ThrowParserException("Internal error: unknown type");
             }
         }
     }
     catch (FormatException)
     {
         this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Failed to parse type. Type = {0}, Value = {1}", new object[]
         {
             paramType,
             value
         }));
     }
     catch (OwaParsingErrorException)
     {
         this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Failed to parse type. Type = {0}, Value = {1}", new object[]
         {
             paramType,
             value
         }));
     }
     catch (OverflowException)
     {
         this.ThrowParserException(string.Format(CultureInfo.InvariantCulture, "Type overflow. Type = {0}, Value = {1}", new object[]
         {
             paramType,
             value
         }));
     }
     return(null);
 }
 // 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();
     }
 }
        private Stream LoadAttachmentDocument(bool isLoadingStream, out RightsManagedMessageDecryptionStatus decryptionStatus)
        {
            decryptionStatus = RightsManagedMessageDecryptionStatus.Success;
            StringBuilder       stringBuilder     = new StringBuilder();
            List <AttachmentId> list              = new List <AttachmentId>();
            UserContext         userContext       = this.owaContext.UserContext;
            string           queryStringParameter = Utilities.GetQueryStringParameter(this.owaContext.HttpContext.Request, "ewsid", false);
            bool             flag = string.IsNullOrEmpty(queryStringParameter);
            OwaStoreObjectId owaStoreObjectId;
            string           text;

            if (!flag)
            {
                stringBuilder.Append("service.svc/s/GetFileAttachment?id=");
                stringBuilder.Append(Utilities.UrlEncode(queryStringParameter));
                string canary15CookieValue = Utilities.GetCanary15CookieValue();
                if (canary15CookieValue != null)
                {
                    stringBuilder.Append("&X-OWA-CANARY=" + canary15CookieValue);
                }
                IdHeaderInformation idHeaderInformation = ServiceIdConverter.ConvertFromConcatenatedId(queryStringParameter, BasicTypes.Attachment, list);
                owaStoreObjectId = OwaStoreObjectId.CreateFromMailboxItemId(idHeaderInformation.ToStoreObjectId());
                text             = owaStoreObjectId.ToString();
            }
            else
            {
                text             = Utilities.GetQueryStringParameter(this.owaContext.HttpContext.Request, "id");
                owaStoreObjectId = OwaStoreObjectId.CreateFromString(text);
                stringBuilder.Append("attachment.ashx?attach=1&id=");
                stringBuilder.Append(Utilities.UrlEncode(text));
            }
            Stream result;

            using (Item item = Utilities.GetItem <Item>(userContext, owaStoreObjectId, new PropertyDefinition[]
            {
                ItemSchema.SentRepresentingDisplayName,
                ItemSchema.Subject
            }))
            {
                if (!Utilities.IsPublic(item) && userContext.IsIrmEnabled && isLoadingStream)
                {
                    item.OpenAsReadWrite();
                }
                if (Utilities.IsIrmRestricted(item))
                {
                    if (!userContext.IsIrmEnabled || userContext.IsBasicExperience)
                    {
                        decryptionStatus = RightsManagedMessageDecryptionStatus.FeatureDisabled;
                        return(null);
                    }
                    RightsManagedMessageItem rightsManagedMessageItem = (RightsManagedMessageItem)item;
                    if (!rightsManagedMessageItem.CanDecode)
                    {
                        decryptionStatus = RightsManagedMessageDecryptionStatus.NotSupported;
                        return(null);
                    }
                    try
                    {
                        Utilities.IrmDecryptIfRestricted(item, userContext, true);
                    }
                    catch (RightsManagementPermanentException exception)
                    {
                        decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception);
                        return(null);
                    }
                    catch (RightsManagementTransientException exception2)
                    {
                        decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception2);
                        return(null);
                    }
                }
                this.messageFrom    = ItemUtility.GetProperty <string>(item, ItemSchema.SentRepresentingDisplayName, string.Empty);
                this.messageSubject = ItemUtility.GetProperty <string>(item, ItemSchema.Subject, string.Empty);
                this.messageId      = text;
                if (flag)
                {
                    Utilities.FillAttachmentIdList(item, this.owaContext.HttpContext.Request, list);
                }
                using (StreamAttachment streamAttachment = Utilities.GetAttachment(item, list, userContext) as StreamAttachment)
                {
                    if (streamAttachment == null)
                    {
                        throw new OwaInvalidRequestException("Attachment is not a stream attachment");
                    }
                    this.mimeType     = (streamAttachment.ContentType ?? streamAttachment.CalculatedContentType);
                    this.fileName     = ((!string.IsNullOrEmpty(streamAttachment.DisplayName)) ? streamAttachment.DisplayName : streamAttachment.FileName);
                    this.fileSize     = streamAttachment.Size;
                    this.documentPath = this.fileName;
                    this.documentIdStringBuilder.Append(Convert.ToBase64String(userContext.MailboxSession.MailboxOwner.MailboxInfo.GetDatabaseGuid().ToByteArray()));
                    this.documentIdStringBuilder.Append("-");
                    for (int i = 0; i < list.Count; i++)
                    {
                        this.documentIdStringBuilder.Append(list[i].ToBase64String());
                        this.documentIdStringBuilder.Append("-");
                        if (flag)
                        {
                            stringBuilder.Append("&attid");
                            stringBuilder.Append(i.ToString(CultureInfo.InstalledUICulture));
                            stringBuilder.Append("=");
                            stringBuilder.Append(Utilities.UrlEncode(list[i].ToBase64String()));
                        }
                    }
                    if (flag)
                    {
                        stringBuilder.Append("&attcnt=");
                        stringBuilder.Append(list.Count);
                    }
                    this.documentIdStringBuilder.Append(streamAttachment.LastModifiedTime.UtcTicks);
                    this.openLink = stringBuilder.ToString();
                    if (isLoadingStream)
                    {
                        Stream       contentStream = streamAttachment.GetContentStream();
                        MsoIpiResult msoIpiResult  = MsoIpiResult.Unknown;
                        try
                        {
                            msoIpiResult = ProtectorsManager.Instance.IsProtected(this.fileName, contentStream);
                        }
                        catch (AttachmentProtectionException exception3)
                        {
                            decryptionStatus = new RightsManagedMessageDecryptionStatus(RightsManagementFailureCode.CorruptData, exception3);
                            return(null);
                        }
                        if (msoIpiResult == MsoIpiResult.Protected)
                        {
                            this.isIrmProtected = true;
                            contentStream.Dispose();
                            if (!userContext.IsIrmEnabled || userContext.IsBasicExperience)
                            {
                                decryptionStatus = RightsManagedMessageDecryptionStatus.FeatureDisabled;
                                result           = null;
                            }
                            else
                            {
                                UseLicenseAndUsageRights useLicenseAndUsageRights;
                                bool   flag2;
                                Stream stream;
                                try
                                {
                                    stream = StreamAttachment.OpenRestrictedAttachment(streamAttachment, this.owaContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.owaContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), this.owaContext.LogonIdentity.UserSid, this.owaContext.ExchangePrincipal.RecipientTypeDetails, out useLicenseAndUsageRights, out flag2);
                                }
                                catch (RightsManagementPermanentException exception4)
                                {
                                    decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception4);
                                    return(null);
                                }
                                catch (RightsManagementTransientException exception5)
                                {
                                    decryptionStatus = RightsManagedMessageDecryptionStatus.CreateFromException(exception5);
                                    return(null);
                                }
                                if (flag2 && ObjectClass.IsMessage(item.ClassName, false) && !Utilities.IsIrmRestricted(item))
                                {
                                    object obj = item.TryGetProperty(MessageItemSchema.IsDraft);
                                    if (obj is bool && !(bool)obj && !DrmClientUtils.IsCachingOfLicenseDisabled(useLicenseAndUsageRights.UseLicense))
                                    {
                                        streamAttachment[AttachmentSchema.DRMRights]     = useLicenseAndUsageRights.UsageRights;
                                        streamAttachment[AttachmentSchema.DRMExpiryTime] = useLicenseAndUsageRights.ExpiryTime;
                                        using (Stream stream2 = streamAttachment.OpenPropertyStream(AttachmentSchema.DRMServerLicenseCompressed, PropertyOpenMode.Create))
                                        {
                                            DrmEmailCompression.CompressUseLicense(useLicenseAndUsageRights.UseLicense, stream2);
                                        }
                                        streamAttachment[AttachmentSchema.DRMPropsSignature] = useLicenseAndUsageRights.DRMPropsSignature;
                                        streamAttachment.Save();
                                        item.Save(SaveMode.ResolveConflicts);
                                    }
                                }
                                string      conversationOwnerFromPublishLicense = DrmClientUtils.GetConversationOwnerFromPublishLicense(useLicenseAndUsageRights.PublishingLicense);
                                RmsTemplate rmsTemplate = RmsTemplate.CreateFromPublishLicense(useLicenseAndUsageRights.PublishingLicense);
                                this.isPrintRestricted = !useLicenseAndUsageRights.UsageRights.IsUsageRightGranted(ContentRight.Print);
                                this.isCopyRestricted  = !useLicenseAndUsageRights.UsageRights.IsUsageRightGranted(ContentRight.Extract);
                                SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder = new SanitizingStringBuilder <OwaHtml>();
                                string str = string.Format(LocalizedStrings.GetNonEncoded(-500320626), rmsTemplate.Name, rmsTemplate.Description);
                                sanitizingStringBuilder.Append(str);
                                if (!string.IsNullOrEmpty(conversationOwnerFromPublishLicense))
                                {
                                    sanitizingStringBuilder.Append("<br>");
                                    sanitizingStringBuilder.Append(string.Format(LocalizedStrings.GetNonEncoded(1670455506), conversationOwnerFromPublishLicense));
                                }
                                this.irmInfobarMessage = sanitizingStringBuilder.ToSanitizedString <SanitizedHtmlString>();
                                result = stream;
                            }
                        }
                        else
                        {
                            contentStream.Seek(0L, SeekOrigin.Begin);
                            result = contentStream;
                        }
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
        // Token: 0x06000796 RID: 1942 RVA: 0x00039B98 File Offset: 0x00037D98
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            applicationElement = ApplicationElement.Item;
            type   = null;
            action = "Open";
            state  = string.Empty;
            CalendarItemBase calendarItemBase     = null;
            string           queryStringParameter = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "id");
            UserContext      userContext          = owaContext.UserContext;
            OwaStoreObjectId preFormActionId      = OwaStoreObjectId.CreateFromString(queryStringParameter);
            bool             flag  = false;
            Item             item  = null;
            bool             flag2 = false;

            try
            {
                calendarItemBase = Utilities.GetItemForRequest <CalendarItemBase>(owaContext, out item, false, new PropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                });
                flag2 = (item != null);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.CalendarDataTracer.TraceDebug(0L, "calendar item could not be found.");
                string queryStringParameter2 = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "gid", false);
                if (string.IsNullOrEmpty(queryStringParameter2))
                {
                    throw;
                }
                byte[]      globalObjectIdBytes = null;
                VersionedId versionedId         = null;
                try
                {
                    globalObjectIdBytes = Convert.FromBase64String(queryStringParameter2);
                }
                catch (FormatException innerException)
                {
                    throw new OwaInvalidRequestException("Invalid global object id for conflicting calendar item", innerException);
                }
                string           queryStringParameter3 = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "fid", false);
                OwaStoreObjectId owaStoreObjectId      = null;
                if (!string.IsNullOrEmpty(queryStringParameter3))
                {
                    owaStoreObjectId = OwaStoreObjectId.CreateFromString(queryStringParameter3);
                }
                else
                {
                    owaStoreObjectId = userContext.CalendarFolderOwaId;
                }
                using (CalendarFolder folder = Utilities.GetFolder <CalendarFolder>(userContext, owaStoreObjectId, new PropertyDefinition[0]))
                {
                    versionedId = folder.GetCalendarItemId(globalObjectIdBytes);
                }
                if (versionedId == null)
                {
                    throw;
                }
                MailboxSession session = (MailboxSession)owaStoreObjectId.GetSession(userContext);
                calendarItemBase = CalendarItemBase.Bind(session, versionedId, new StorePropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                });
                flag = true;
            }
            finally
            {
                using (item)
                {
                    using (calendarItemBase)
                    {
                        if (calendarItemBase != null)
                        {
                            if (!Utilities.IsPublic(calendarItemBase) && calendarItemBase.IsMeeting && !calendarItemBase.IsOrganizer())
                            {
                                type = "IPM.Schedule.Meeting.Request";
                            }
                            else
                            {
                                type = "IPM.Appointment";
                                if (flag2 || !ItemUtility.UserCanEditItem(calendarItemBase) || Utilities.IsItemInExternalSharedInFolder(userContext, calendarItemBase))
                                {
                                    action = string.Empty;
                                }
                            }
                            if (!flag2)
                            {
                                if (flag)
                                {
                                    owaContext.PreFormActionId = OwaStoreObjectId.CreateFromStoreObject(calendarItemBase);
                                }
                                else
                                {
                                    owaContext.PreFormActionId = preFormActionId;
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }