Beispiel #1
0
        /// <summary>
        /// Categorize recipients as follows:
        /// - are they in the local domain or are they external
        /// </summary>
        /// <param name="domains"></param>
        internal void CategorizeRecipientsByDomain(AgentDomains domains)
        {
            DirectAddressCollection recipients       = Recipients;
            DirectAddressCollection domainRecipients = null;
            MailAddressCollection   otherRecipients  = null;

            for (int i = 0, count = recipients.Count; i < count; ++i)
            {
                DirectAddress address = recipients[i];
                if (domains.IsManaged(address))
                {
                    if (domains.HsmEnabled(address))
                    {
                        address.HsmEnabled = true;
                    }

                    if (domainRecipients == null)
                    {
                        domainRecipients = new DirectAddressCollection();
                    }
                    domainRecipients.Add(address);
                }
                else
                {
                    if (otherRecipients == null)
                    {
                        otherRecipients = new MailAddressCollection();
                    }
                    otherRecipients.Add(address);
                }
            }

            this.DomainRecipients = domainRecipients;
            this.OtherRecipients  = otherRecipients;
        }
Beispiel #2
0
        void ProcessMessage(OutgoingMessage message)
        {
            if (!WrappedMessage.IsWrapped(message.Message))
            {
                message.Message = message.HasRawMessage ? this.WrapMessage(message.RawMessage) : this.WrapMessage(message.Message);
            }

            if (message.Sender == null)
            {
                throw new OutgoingAgentException(AgentError.NoSender);
            }
            if (!message.HasRecipients)
            {
                throw new OutgoingAgentException(AgentError.NoRecipients);
            }
            //
            // Ensure we support this sender's domain
            //
            if (!m_managedDomains.IsManaged(message.Sender))
            {
                throw new OutgoingAgentException(AgentError.UntrustedSender);
            }
            //
            // Categorize recipients as local/external
            //
            message.EnsureRecipientsCategorizedByDomain(m_managedDomains);
            //
            //
            //
            message.EnsureSenderClassified(m_managedDomains);
            //
            // Bind addresses to Certs etc
            //
            this.BindAddresses(message);
            if (!message.HasRecipients)
            {
                throw new OutgoingAgentException(AgentError.MissingTo);
            }
            //
            // Enforce the trust model.
            //
            m_trustModel.Enforce(message);
            //
            // Remove any non-trusted recipients
            //
            message.CategorizeRecipientsByTrust(m_minTrustRequirement);
            if (!message.HasRecipients)
            {
                throw new OutgoingAgentException(AgentError.NoTrustedRecipients);
            }
            //
            // And update routing headers to remove any recipients we had yanked
            //
            message.UpdateRoutingHeaders();
            //
            // Finally, sign and encrypt the message
            //
            this.SignAndEncryptMessage(message);
        }
Beispiel #3
0
 /// <summary>
 /// Classify security level of sender
 /// </summary>
 /// <remarks>
 /// This will allow a consumer to decide how to handle decryption and digital signing.
 /// </remarks>
 /// <param name="domains"></param>
 public void EnsureSenderClassified(AgentDomains domains)
 {
     if (domains.IsManaged(Sender))
     {
         if (domains.HsmEnabled(Sender))
         {
             Sender.HsmEnabled = true;
         }
     }
 }
Beispiel #4
0
        /// <summary>
        /// Categorize recipients as follows:
        /// - are they in the local domain or are they external
        /// </summary>
        /// <param name="domains"></param>
        internal void CategorizeRecipientsByDomain(AgentDomains domains)
        {
            DirectAddressCollection recipients = Recipients;
            DirectAddressCollection domainRecipients = null;
            MailAddressCollection otherRecipients = null;

            for (int i = 0, count = recipients.Count; i < count; ++i)
            {
                DirectAddress address = recipients[i];
                if (domains.IsManaged(address))
                {
                    if (domainRecipients == null)
                    {
                        domainRecipients = new DirectAddressCollection();
                    }
                    domainRecipients.Add(address);
                }
                else
                {
                    if (otherRecipients == null)
                    {
                        otherRecipients = new MailAddressCollection();
                    }
                    otherRecipients.Add(address);
                }
            }

            this.DomainRecipients = domainRecipients;
            this.OtherRecipients = otherRecipients;
        }