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
 /// <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 #3
0
        /// <summary>
        /// If recipients have  not been categorized by domain, categorizes by domain.
        /// </summary>
        /// <param name="domains">Domains to treat as  domain recipients.</param>
        public void EnsureRecipientsCategorizedByDomain(AgentDomains domains)
        {
            // We only want to categorize if we haven't done it already
            // Do NOT change these to IsNullOrEmpty
            if (this.DomainRecipients != null || this.OtherRecipients != null)
            {
                return;
            }

            this.CategorizeRecipientsByDomain(domains);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a DirectAgent instance, specifying private, external and trust anchor certificate stores, and
        /// trust and cryptography models.
        /// </summary>
        /// <param name="domainResolver">
        /// An <see cref="IDomainResolver"/> instance providing array of local domain name managed by this agent.
        /// </param>
        /// <param name="privateCerts">
        /// An <see cref="ICertificateResolver"/> instance providing private certificates
        /// for senders of outgoing messages and receivers of incoming messages.
        /// </param>
        /// <param name="publicCerts">
        /// An <see cref="ICertificateResolver"/> instance providing public certificates
        /// for receivers of outgoing messages and senders of incoming messages.
        /// </param>
        /// <param name="anchors">
        /// An <see cref="ITrustAnchorResolver"/> instance providing trust anchors.
        /// </param>
        /// <param name="trustModel">
        /// An instance or subclass of <see cref="SMIMECryptographer"/> providing a custom trust model.
        /// </param>
        /// <param name="cryptographer">
        /// An instance or subclass of <see cref="Health.Direct.Agent"/> providing a custom cryptography model.
        /// </param>
        /// <param name="certPolicyResolvers">Certificate <see cref="ICertPolicyResolvers">policy container</see></param>
        public DirectAgent(IDomainResolver domainResolver,
                           ICertificateResolver privateCerts,
                           ICertificateResolver publicCerts,
                           ITrustAnchorResolver anchors,
                           TrustModel trustModel,
                           ISmimeCryptographer cryptographer,
                           ICertPolicyResolvers certPolicyResolvers)
        {
            m_managedDomains = new AgentDomains(domainResolver);

            if (privateCerts == null)
            {
                throw new ArgumentNullException("privateCerts");
            }
            if (publicCerts == null)
            {
                throw new ArgumentNullException("publicCerts");
            }
            if (anchors == null)
            {
                throw new ArgumentNullException("anchors");
            }
            if (trustModel == null)
            {
                throw new ArgumentNullException("trustModel");
            }
            if (cryptographer == null)
            {
                throw new ArgumentNullException("cryptographer");
            }

            m_privateCertResolver = privateCerts;
            m_publicCertResolver  = publicCerts;
            m_cryptographer       = cryptographer;
            m_trustAnchors        = anchors;
            m_trustModel          = trustModel;
            if (!m_trustModel.CertChainValidator.HasCertificateResolver)
            {
                m_trustModel.CertChainValidator.IssuerResolver = m_publicCertResolver;
            }

            m_minTrustRequirement = TrustEnforcementStatus.Success;

            m_privatePolicyResolver = certPolicyResolvers.PrivateResolver;
            m_publicPolicyResolver  = certPolicyResolvers.PublicResolver;
        }
        /// <summary>
        /// Creates a DirectAgent instance, specifying private, external and trust anchor certificate stores, and 
        /// trust and cryptography models.
        /// </summary>
        /// <param name="domainResolver">
        /// An <see cref="IDomainResolver"/> instance providing array of local domain name managed by this agent.
        /// </param>
        /// <param name="privateCerts">
        /// An <see cref="ICertificateResolver"/> instance providing private certificates
        /// for senders of outgoing messages and receivers of incoming messages.
        /// </param>
        /// <param name="publicCerts">
        /// An <see cref="ICertificateResolver"/> instance providing public certificates 
        /// for receivers of outgoing messages and senders of incoming messages. 
        /// </param>
        /// <param name="anchors">
        /// An <see cref="ITrustAnchorResolver"/> instance providing trust anchors.
        /// </param>
        /// <param name="trustModel">
        /// An instance or subclass of <see cref="SMIMECryptographer"/> providing a custom trust model.
        /// </param>
        /// <param name="cryptographer">
        /// An instance or subclass of <see cref="Health.Direct.Agent"/> providing a custom cryptography model.
        /// </param>
        public DirectAgent(IDomainResolver domainResolver, ICertificateResolver privateCerts, ICertificateResolver publicCerts, ITrustAnchorResolver anchors, TrustModel trustModel, SMIMECryptographer cryptographer)
        {
            m_managedDomains = new AgentDomains(domainResolver);

            if (privateCerts == null)
            {
                throw new ArgumentNullException("privateCerts");
            }
            if (publicCerts == null)
            {
                throw new ArgumentNullException("publicCerts");
            }
            if (anchors == null)
            {
                throw new ArgumentNullException("anchors");
            }
            if (trustModel == null)
            {
                throw new ArgumentNullException("trustModel");
            }
            if (cryptographer == null)
            {
                throw new ArgumentNullException("cryptographer");
            }

            m_privateCertResolver = privateCerts;
            m_publicCertResolver = publicCerts;
            m_cryptographer = cryptographer;
            m_trustAnchors = anchors;
            m_trustModel = trustModel;
            if (!m_trustModel.CertChainValidator.HasCertificateResolver)
            {
                m_trustModel.CertChainValidator.IssuerResolver = m_publicCertResolver;
            }
            
            m_minTrustRequirement = TrustEnforcementStatus.Success;
        }
Beispiel #6
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;
        }
Beispiel #7
0
 /// <summary>
 /// If recipients have  not been categorized by domain, categorizes by domain.
 /// </summary>
 /// <param name="domains">Domains to treat as  domain recipients.</param>
 public void EnsureRecipientsCategorizedByDomain(AgentDomains domains)
 {
     // We only want to categorize if we haven't done it already
     // Do NOT change these to IsNullOrEmpty
     if (this.DomainRecipients != null || this.OtherRecipients != null)
     {
         return;
     }
     
     this.CategorizeRecipientsByDomain(domains);
 }