Beispiel #1
0
        public LoadedItemPart Load(StoreId objectId, IStorePropertyBag propertyBagFromTree, HtmlStreamOptionCallback htmlCallback, PropertyDefinition[] propertyDefinitions, long bytesLoadedForConversation, bool isSmimeSupported, string domainName)
        {
            LoadedItemPart result;

            using (IItem item = this.xsoFactory.BindToItem(this.mailboxSession, objectId, propertyDefinitions))
            {
                ItemPartIrmInfo itemPartIrmInfo = this.GetItemPartIrmInfo(item);
                bool            isIrmEnabled    = itemPartIrmInfo != ItemPartIrmInfo.NotRestricted && this.canOpenIrmMessage;
                result = this.CreateLoadedItemPart(item, propertyBagFromTree, htmlCallback, propertyDefinitions, itemPartIrmInfo, isIrmEnabled, bytesLoadedForConversation, isSmimeSupported, domainName);
            }
            return(result);
        }
Beispiel #2
0
        private void InitializeIrmInfo(IItem item, ItemPartIrmInfo itemPartIrmInfo, out AttachmentCollection attachmentCollection)
        {
            attachmentCollection = item.AttachmentCollection;
            RightsManagedMessageItem rightsManagedMessageItem = item as RightsManagedMessageItem;

            if (rightsManagedMessageItem != null && rightsManagedMessageItem.IsRestricted)
            {
                if (itemPartIrmInfo.DecryptionStatus.Failed || !rightsManagedMessageItem.IsDecoded)
                {
                    attachmentCollection = null;
                    return;
                }
                attachmentCollection       = rightsManagedMessageItem.ProtectedAttachmentCollection;
                itemPartIrmInfo.BodyFormat = rightsManagedMessageItem.ProtectedBody.Format;
            }
        }
Beispiel #3
0
        private ItemPartIrmInfo GetItemPartIrmInfo(IItem item)
        {
            RightsManagedMessageItem rightsManagedMessageItem = item as RightsManagedMessageItem;

            if (rightsManagedMessageItem == null || !rightsManagedMessageItem.IsRestricted)
            {
                return(ItemPartIrmInfo.NotRestricted);
            }
            ItemPartIrmInfo result = null;

            if (!this.canOpenIrmMessage || !rightsManagedMessageItem.CanDecode)
            {
                if (!this.canOpenIrmMessage)
                {
                    result = ItemPartIrmInfo.CreateForIrmDisabled();
                }
                else if (!rightsManagedMessageItem.CanDecode)
                {
                    result = ItemPartIrmInfo.CreateForUnsupportedScenario();
                }
            }
            else
            {
                try
                {
                    OutboundConversionOptions options = new OutboundConversionOptions(item.Session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), string.Empty);
                    rightsManagedMessageItem.Decode(options, true);
                    result = ItemPartIrmInfo.Create(rightsManagedMessageItem.UsageRights, rightsManagedMessageItem.Restriction.Name, rightsManagedMessageItem.Restriction.Description, rightsManagedMessageItem.ConversationOwner.EmailAddress, rightsManagedMessageItem.UserLicenseExpiryTime, rightsManagedMessageItem.Restriction.RequiresRepublishingWhenRecipientsChange, rightsManagedMessageItem.CanRepublish);
                }
                catch (RightsManagementPermanentException exception)
                {
                    result = ItemPartIrmInfo.CreateForDecryptionFailure(exception);
                }
                catch (RightsManagementTransientException exception2)
                {
                    result = ItemPartIrmInfo.CreateForDecryptionFailure(exception2);
                }
            }
            return(result);
        }
 internal LoadedItemPart(IItem item, IStorePropertyBag propertyBag, BodyFragmentInfo bodyFragmentInfo, PropertyDefinition[] loadedProperties, ItemPartIrmInfo irmInfo, bool didLoadSucceed, long bytesLoaded, AttachmentCollection attachmentCollection) : base(loadedProperties)
 {
     this.irmInfo = irmInfo;
     this.InitializeLoadedItemPart(item, propertyBag, bodyFragmentInfo, didLoadSucceed, bytesLoaded, attachmentCollection);
 }
Beispiel #5
0
        private LoadedItemPart CreateLoadedItemPart(IItem item, IStorePropertyBag propertyBagFromTree, HtmlStreamOptionCallback htmlCallback, PropertyDefinition[] additionalPropertyDefinitions, ItemPartIrmInfo itemPartIrmInfo, bool isIrmEnabled, long bytesLoadedForConversation, bool isSmimeSupported, string domainName)
        {
            ConversationBodyScanner bodyScanner = null;
            long bytesLoaded = 0L;

            PropertyDefinition[] loadedProperties = InternalSchema.Combine <PropertyDefinition>(this.queriedPropertyDefinitions, additionalPropertyDefinitions).ToArray <PropertyDefinition>();
            IStorePropertyBag    propertyBag      = this.CalculatePropertyBag(propertyBagFromTree, item, additionalPropertyDefinitions);
            BodyFragmentInfo     bodyFragmentInfo = null;
            bool didLoadSucceed = false;

            if (this.TryLoadBodyScanner(item, htmlCallback, bytesLoadedForConversation, isIrmEnabled, out bodyScanner, out bytesLoaded))
            {
                bodyFragmentInfo = new BodyFragmentInfo(bodyScanner);
                didLoadSucceed   = true;
            }
            AttachmentCollection attachmentCollection = item.AttachmentCollection;

            if (isIrmEnabled)
            {
                this.InitializeIrmInfo(item, itemPartIrmInfo, out attachmentCollection);
            }
            string itemClass = item.TryGetProperty(StoreObjectSchema.ItemClass) as string;

            if (isSmimeSupported && ObjectClass.IsSmimeClearSigned(itemClass))
            {
                this.InitializeSmimeInfo(item, domainName, out attachmentCollection);
            }
            return(new LoadedItemPart(item, propertyBag, bodyFragmentInfo, loadedProperties, itemPartIrmInfo, didLoadSucceed, bytesLoaded, attachmentCollection));
        }