Esempio n. 1
0
        private static bool TryProcessUnprotectedAttachment(IExchangePrincipal exchangePrincipal, Item item, StreamAttachment streamAttachment, PropertyOpenMode openMode, WacUtilities.AttachmentProcessor attachmentProcessor)
        {
            if (openMode == PropertyOpenMode.Modify)
            {
                item.OpenAsReadWrite();
            }
            bool result;

            using (Stream contentStream = streamAttachment.GetContentStream(openMode))
            {
                bool flag = WacUtilities.IsContentProtected(streamAttachment.FileName, contentStream);
                if (flag)
                {
                    result = false;
                }
                else
                {
                    attachmentProcessor(exchangePrincipal, streamAttachment, contentStream, false);
                    if (openMode == PropertyOpenMode.Modify)
                    {
                        item.Save(SaveMode.NoConflictResolution);
                    }
                    result = true;
                }
            }
            return(result);
        }
Esempio n. 2
0
 internal StoreObjectStream(StoreObjectPropertyBag storePropertyBag, NativeStorePropertyDefinition property, PropertyOpenMode streamOpenMode)
 {
     Util.ThrowOnNullArgument(storePropertyBag, "storePropertyBag");
     Util.ThrowOnNullArgument(property, "property");
     this.storePropertyBag = storePropertyBag;
     this.property         = property;
     this.openMode         = streamOpenMode;
     this.CreateStream();
     this.disposeTracker = this.GetDisposeTracker();
 }
Esempio n. 3
0
        public static void ProcessAttachment(IStoreSession session, string ewsAttachmentId, IExchangePrincipal exchangePrincipal, PropertyOpenMode openMode, WacUtilities.AttachmentProcessor attachmentProcessor)
        {
            IdConverterDependencies converterDependencies = new IdConverterDependencies.FromRawData(false, false, null, null, exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), session as MailboxSession, session as MailboxSession, session as PublicFolderSession);

            using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(ewsAttachmentId, converterDependencies))
            {
                bool flag = WacUtilities.IsIrmRestricted(attachmentRetriever.RootItem);
                if (openMode == PropertyOpenMode.Modify)
                {
                    attachmentRetriever.RootItem.OpenAsReadWrite();
                }
                StreamAttachment streamAttachment = attachmentRetriever.Attachment as StreamAttachment;
                if (streamAttachment == null)
                {
                    attachmentProcessor(exchangePrincipal, attachmentRetriever.Attachment, null, flag);
                }
                else
                {
                    using (Stream contentStream = streamAttachment.GetContentStream(openMode))
                    {
                        bool flag2 = WacUtilities.IsContentProtected(attachmentRetriever.Attachment.FileName, contentStream);
                        attachmentProcessor(exchangePrincipal, streamAttachment, contentStream, flag || flag2);
                        if (openMode == PropertyOpenMode.Modify)
                        {
                            attachmentRetriever.RootItem.Save(SaveMode.NoConflictResolution);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public override Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
        {
            base.CheckDisposed("OpenPropertyStream");
            EnumValidator.AssertValid <PropertyOpenMode>(openMode);
            NativeStorePropertyDefinition nativeStorePropertyDefinition = propertyDefinition as NativeStorePropertyDefinition;

            if (nativeStorePropertyDefinition == null)
            {
                throw new InvalidOperationException(ServerStrings.ExPropertyNotStreamable(propertyDefinition.ToString()));
            }
            Stream result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                StoreObjectStream storeObjectStream = new StoreObjectStream(this, nativeStorePropertyDefinition, openMode);
                disposeGuard.Add <StoreObjectStream>(storeObjectStream);
                this.listOfStreams.Add(storeObjectStream);
                disposeGuard.Success();
                if (openMode == PropertyOpenMode.Create || openMode == PropertyOpenMode.Modify)
                {
                    this.TrackProperty(nativeStorePropertyDefinition, true);
                }
                result = storeObjectStream;
            }
            return(result);
        }
Esempio n. 5
0
 public override Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     base.CheckDisposed("OpenPropertyStream");
     EnumValidator.AssertValid <PropertyOpenMode>(openMode);
     this.OnOpenConnection();
     return(this.persistablePropertyBag.OpenPropertyStream(propertyDefinition, openMode));
 }
Esempio n. 6
0
 public Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     throw new NotSupportedException("Streams are not supported on Recipients.");
 }
Esempio n. 7
0
 public Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     throw new NotSupportedException(ServerStrings.ExPropertyNotStreamable(propertyDefinition.ToString()));
 }
Esempio n. 8
0
 public Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     throw new NotSupportedException();
 }
 public virtual Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     throw new NotImplementedException();
 }
Esempio n. 10
0
 internal Stream TryGetRawContentStream(PropertyOpenMode openMode)
 {
     base.CheckDisposed("TryGetRawContentStream");
     return(base.TryGetContentStream(openMode));
 }
Esempio n. 11
0
 public override Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     base.CheckDisposed("AcrPropertyBag::OpenPropertyStream");
     EnumValidator.AssertValid <PropertyOpenMode>(openMode);
     if (openMode != PropertyOpenMode.ReadOnly)
     {
         if (this.Mode == AcrPropertyBag.AcrMode.ReadOnly)
         {
             ExTraceGlobals.StorageTracer.TraceError <int, PropertyOpenMode>((long)this.GetHashCode(), "AcrPropertyBag::SetProperties {0}, OpenPropertyStream called for readonly AcrPropertyBag with opemMode = {1}", this.GetHashCode(), openMode);
             throw new AccessDeniedException(ServerStrings.ExItemIsOpenedInReadOnlyMode);
         }
         if (!this.propertiesWrittenAsStream.ContainsKey(propertyDefinition))
         {
             if (this.propertyTrackingCache.ContainsKey(propertyDefinition))
             {
                 ExTraceGlobals.StorageTracer.Information <int, string>((long)this.GetHashCode(), "AcrPropertyBag::OpenPropertyStream HashCode[{0}]: PropertyRemoved from acr {1}", this.GetHashCode(), propertyDefinition.Name);
                 this.propertyTrackingCache.Remove(propertyDefinition);
             }
             this.propertiesWrittenAsStream.Add(propertyDefinition, propertyDefinition);
         }
     }
     return(this.propertyBag.OpenPropertyStream(propertyDefinition, openMode));
 }
Esempio n. 12
0
 public Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     return(this.messageItem.OpenPropertyStream(propertyDefinition, openMode));
 }
Esempio n. 13
0
        public sealed override Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
        {
            EnumValidator.AssertValid <PropertyOpenMode>(openMode);
            NativeStorePropertyDefinition nativeStorePropertyDefinition = propertyDefinition as NativeStorePropertyDefinition;

            if (nativeStorePropertyDefinition == null)
            {
                throw new InvalidOperationException(ServerStrings.ExPropertyNotStreamable(propertyDefinition.ToString()));
            }
            return(new FolderPropertyStream(base.MapiPropertyBag, nativeStorePropertyDefinition, openMode));
        }
 internal FolderPropertyStream(MapiPropertyBag mapiPropertyBag, NativeStorePropertyDefinition property, PropertyOpenMode streamOpenMode)
 {
     Util.ThrowOnNullArgument(mapiPropertyBag, "mapiPropertyBag");
     Util.ThrowOnNullArgument(property, "property");
     EnumValidator.ThrowIfInvalid <PropertyOpenMode>(streamOpenMode, "streamOpenMode");
     this.mapiPropertyBag = mapiPropertyBag;
     this.property        = property;
     this.openMode        = streamOpenMode;
     this.CreateStream();
     this.disposeTracker = this.GetDisposeTracker();
 }
Esempio n. 15
0
 public override Stream TryGetContentStream(PropertyOpenMode openMode)
 {
     base.CheckDisposed("TryGetContentStream");
     return(new MemoryStream());
 }
Esempio n. 16
0
 public Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     return(this.mailboxStoreObject.OpenPropertyStream(propertyDefinition, openMode));
 }
Esempio n. 17
0
 public virtual Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     this.CheckDisposed("OpenProperyStream");
     EnumValidator.ThrowIfInvalid <PropertyOpenMode>(openMode, "openMode");
     InternalSchema.ToStorePropertyDefinition(propertyDefinition);
     if (!(propertyDefinition is NativeStorePropertyDefinition))
     {
         throw new NotSupportedException(ServerStrings.ExCalculatedPropertyStreamAccessNotSupported(propertyDefinition.Name));
     }
     return(this.PropertyBag.OpenPropertyStream(propertyDefinition, openMode));
 }
Esempio n. 18
0
 internal AnchorAttachment(AnchorContext anchorContext, StreamAttachment attachment, PropertyOpenMode openMode) : this(anchorContext, attachment.GetContentStream(openMode), attachment.LastModifiedTime, null)
 {
     this.attachment = attachment;
 }
        internal static AnchorAttachment GetAttachment(AnchorContext context, MessageItem message, string name, PropertyOpenMode openMode)
        {
            AnchorUtil.ThrowOnNullArgument(message, "message");
            AnchorUtil.ThrowOnNullOrEmptyArgument(name, "name");
            if (openMode != PropertyOpenMode.ReadOnly && openMode != PropertyOpenMode.Modify)
            {
                throw new ArgumentException("Invalid OpenMode for GetAttachment", "openMode");
            }
            AnchorAttachment anchorAttachment = null;

            foreach (AttachmentHandle handle in message.AttachmentCollection)
            {
                StreamAttachment streamAttachment = null;
                try
                {
                    AttachmentType type = AttachmentType.Stream;
                    streamAttachment = (StreamAttachment)message.AttachmentCollection.Open(handle, type);
                    if (streamAttachment.FileName.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        anchorAttachment = new AnchorAttachment(context, streamAttachment, openMode);
                        streamAttachment = null;
                        break;
                    }
                }
                finally
                {
                    if (streamAttachment != null)
                    {
                        streamAttachment.Dispose();
                        streamAttachment = null;
                    }
                }
            }
            if (anchorAttachment == null)
            {
                throw new MigrationAttachmentNotFoundException(name);
            }
            return(anchorAttachment);
        }
 public virtual Stream GetContentStream(PropertyOpenMode openMode)
 {
     base.CheckDisposed("GetContentStream");
     EnumValidator.ThrowIfInvalid <PropertyOpenMode>(openMode, "openMode");
     return(base.PropertyBag.OpenPropertyStream(this.ContentStreamProperty, openMode));
 }
 // Token: 0x06000258 RID: 600 RVA: 0x00008E7B File Offset: 0x0000707B
 public AnchorAttachment GetAttachment(string name, PropertyOpenMode openMode)
 {
     base.CheckDisposed();
     return(AnchorMessageHelper.GetAttachment(base.AnchorContext, this.Message, name, openMode));
 }
 public abstract Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode);
Esempio n. 23
0
 internal Stream OpenPropertyStream(NativeStorePropertyDefinition propertyDefinition, PropertyOpenMode openMode)
 {
     return(this.OpenPropertyStream(propertyDefinition, openMode, true));
 }
        public override Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
        {
            Stream stream = null;
            StorePropertyDefinition storePropertyDefinition = InternalSchema.ToStorePropertyDefinition(propertyDefinition);

            if (openMode != PropertyOpenMode.Create)
            {
                object        value         = ((IDirectPropertyBag)this.memoryPropertyBag).GetValue(storePropertyDefinition);
                PropertyError propertyError = value as PropertyError;
                if (propertyError == null)
                {
                    stream = this.WrapValueInStream(value);
                }
                else if (propertyError.PropertyErrorCode == PropertyErrorCode.RequireStreamed)
                {
                    stream = this.streamList[storePropertyDefinition];
                }
                else if (openMode == PropertyOpenMode.ReadOnly)
                {
                    throw new ObjectNotFoundException(ServerStrings.StreamPropertyNotFound(storePropertyDefinition.ToString()));
                }
            }
            if (stream == null)
            {
                stream = new MemoryStream();
                ((IDirectPropertyBag)this.memoryPropertyBag).SetValue(storePropertyDefinition, new PropertyError(storePropertyDefinition, PropertyErrorCode.RequireStreamed));
                this.streamList[storePropertyDefinition] = stream;
            }
            if (openMode != PropertyOpenMode.ReadOnly)
            {
                this.isDirty = true;
            }
            stream.Seek(0L, SeekOrigin.Begin);
            return(new StreamWrapper(stream, false));
        }