コード例 #1
0
        public int GetBytes(byte[] array, int offset)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if (0 > offset)
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            if (this.address == null)
            {
                return(0);
            }
            int length = this.Length;

            if (length == 0)
            {
                return(0);
            }
            if (length > array.Length - offset)
            {
                throw new ArgumentException(DataStrings.InsufficientSpace);
            }
            return(MimeInternalHelpers.StringToBytes(this.address, 0, length, array, offset, MimeInternalHelpers.IsEaiEnabled()));
        }
コード例 #2
0
        private TransportMailItem CreateMailItem()
        {
            TransportMailItem transportMailItem = TransportMailItem.NewSideEffectMailItem(this.context.MbxTransportMailItem, this.context.RecipientCache.OrganizationId, LatencyComponent.MailboxRules, MailDirectionality.Originating, this.context.MbxTransportMailItem.ExternalOrganizationId);

            base.CopyContentTo(transportMailItem);
            base.DecorateMessage(transportMailItem);
            base.ApplySecurityAttributesTo(transportMailItem);
            transportMailItem.PrioritizationReason = this.context.PrioritizationReason;
            transportMailItem.Priority             = this.context.Priority;
            ClassificationUtils.PromoteStoreClassifications(transportMailItem.RootPart.Headers);
            SubmissionItemUtils.PatchQuarantineSender(transportMailItem, base.QuarantineOriginalSender);
            HeaderList headers = transportMailItem.RootPart.Headers;

            if (headers.FindFirst(HeaderId.MessageId) == null)
            {
                headers.AppendChild(new AsciiTextHeader("Message-Id", string.Concat(new string[]
                {
                    "<",
                    Guid.NewGuid().ToString("N"),
                    "@",
                    this.SourceServerFqdn,
                    ">"
                })));
            }
            MimeInternalHelpers.CopyHeaderBetweenList(this.context.RootPart.Headers, headers, "X-MS-Exchange-Moderation-Loop");
            transportMailItem.UpdateCachedHeaders();
            return(transportMailItem);
        }
コード例 #3
0
 public byte[] GetBytes()
 {
     if (this.address == null)
     {
         return(null);
     }
     return(MimeInternalHelpers.StringToBytes(this.address, MimeInternalHelpers.IsEaiEnabled()));
 }
コード例 #4
0
 public static bool IsValidDomain(string domain)
 {
     if (domain == null)
     {
         throw new ArgumentNullException("domain");
     }
     return(MimeInternalHelpers.IsValidDomain(domain, 0, true, MimeInternalHelpers.IsEaiEnabled()) && !SmtpAddress.IsDomainIPLiteral(domain));
 }
コード例 #5
0
        public static bool IsValidSmtpAddress(string address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            int domainStart;

            return((MimeInternalHelpers.IsValidSmtpAddress(address, true, out domainStart, MimeInternalHelpers.IsEaiEnabled()) && !SmtpAddress.IsDomainIPLiteral(address, domainStart)) || address == SmtpAddress.NullReversePath.address);
        }
コード例 #6
0
        internal void WriteHeader(HeaderId id, ExDateTime data)
        {
            if (this.hasAllHeaders)
            {
                return;
            }
            DateHeader header = (DateHeader)Header.Create(id);

            MimeInternalHelpers.SetDateHeaderValue(header, data.UniversalTime, data.Bias);
            this.WriteHeader(header);
        }
コード例 #7
0
        private static bool IsMessageOpaqueSigned(ICoreItem coreItem, StreamAttachment attachment)
        {
            Util.ThrowOnNullArgument(coreItem, "coreItem");
            string valueOrDefault = coreItem.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (!ObjectClass.IsSmime(valueOrDefault))
            {
                return(false);
            }
            coreItem.PropertyBag.Load(new PropertyDefinition[]
            {
                InternalSchema.NamedContentType
            });
            string valueOrDefault2 = coreItem.PropertyBag.GetValueOrDefault <string>(InternalSchema.NamedContentType);

            if (valueOrDefault2 != null)
            {
                byte[]            bytes  = CTSGlobals.AsciiEncoding.GetBytes(valueOrDefault2);
                ContentTypeHeader header = (ContentTypeHeader)Header.Create(HeaderId.ContentType);
                MimeInternalHelpers.SetHeaderRawValue(header, bytes);
                string headerParameter = MimeHelpers.GetHeaderParameter(header, "smime-type", 100);
                if (headerParameter == null || (!ConvertUtils.MimeStringEquals(headerParameter, "signed-data") && !ConvertUtils.MimeStringEquals(headerParameter, "certs-only")))
                {
                    return(false);
                }
            }
            string contentType = attachment.ContentType;

            if (string.Compare(contentType, "application/pkcs7-mime", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(contentType, "application/x-pkcs7-mime", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return(true);
            }
            if (string.Compare(contentType, "application/octet-stream", StringComparison.OrdinalIgnoreCase) == 0)
            {
                string fileName = attachment.FileName;
                string strA     = string.Empty;
                if (fileName != null)
                {
                    string[] array = fileName.Split(new char[]
                    {
                        '.'
                    });
                    if (array.Length > 0)
                    {
                        strA = array[array.Length - 1];
                    }
                }
                return(string.Compare(strA, "p7m", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(strA, "p7c", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(strA, "p7s", StringComparison.OrdinalIgnoreCase) == 0);
            }
            return(false);
        }
コード例 #8
0
        public void Submit(MessageTrackingSource messageTrackingSource, MemorySubmissionItem.OnConvertedToTransportMailItemDelegate transportMailItemHandler, MbxTransportMailItem relatedMailItem)
        {
            TransportMailItem transportMailItem;

            if (relatedMailItem == null)
            {
                transportMailItem = TransportMailItem.NewMailItem(this.organizationId, LatencyComponent.StoreDriverSubmit, MailDirectionality.Originating, default(Guid));
            }
            else
            {
                transportMailItem = TransportMailItem.NewSideEffectMailItem(relatedMailItem, this.organizationId, LatencyComponent.StoreDriverSubmit, MailDirectionality.Originating, relatedMailItem.ExternalOrganizationId);
            }
            base.CopyContentTo(transportMailItem);
            base.DecorateMessage(transportMailItem);
            base.ApplySecurityAttributesTo(transportMailItem);
            if (relatedMailItem != null)
            {
                transportMailItem.PrioritizationReason = relatedMailItem.PrioritizationReason;
                transportMailItem.Priority             = relatedMailItem.Priority;
            }
            SubmissionItemUtils.CopySenderTo(this, transportMailItem);
            List <string> invalidRecipients = null;
            List <string> list = null;

            SubmissionItemUtils.CopyRecipientsTo(this, transportMailItem, null, ref invalidRecipients, ref list);
            ClassificationUtils.PromoteStoreClassifications(transportMailItem.RootPart.Headers);
            SubmissionItemUtils.PatchQuarantineSender(transportMailItem, base.QuarantineOriginalSender);
            bool flag = transportMailItem.Recipients.Count > 0;

            if (relatedMailItem != null)
            {
                MimeInternalHelpers.CopyHeaderBetweenList(relatedMailItem.RootPart.Headers, transportMailItem.RootPart.Headers, "X-MS-Exchange-Moderation-Loop");
            }
            bool flag2 = transportMailItemHandler(transportMailItem, flag);

            if (flag && flag2)
            {
                MsgTrackReceiveInfo msgTrackInfo = new MsgTrackReceiveInfo(StoreDriverDelivery.LocalIPAddress, (relatedMailItem != null) ? new long?(relatedMailItem.RecordId) : null, transportMailItem.MessageTrackingSecurityInfo, invalidRecipients);
                MessageTrackingLog.TrackReceive(messageTrackingSource, transportMailItem, msgTrackInfo);
                Utils.SubmitMailItem(transportMailItem, false);
            }
        }
コード例 #9
0
 public SmtpAddress(byte[] address)
 {
     this.address = ((address != null && address.Length != 0) ? MimeInternalHelpers.BytesToString(address, true) : null);
 }
コード例 #10
0
 public static bool IsUTF8Address(string address)
 {
     return(!MimeInternalHelpers.IsPureASCII(address));
 }