IncomingMessage CreateEnvelope() { Message message = Message.Load(MultiToMessage); IncomingMessage envelope = new IncomingMessage(message); envelope.EnsureRecipientsCategorizedByDomain(m_agent.Domains); this.AssignTypesToRecipients(envelope.DomainRecipients); return(envelope); }
/// <summary> /// Ensure that domain recipients are KNOWN - i.e. registered with the Config System /// If not, remove them. /// </summary> /// <param name="message"></param> void VerifyDomainRecipientsRegistered(IncomingMessage message) { message.EnsureRecipientsCategorizedByDomain(this.SecurityAgent.Domains); if (!message.HasDomainRecipients) { throw new AgentException(AgentError.NoRecipients); } DirectAddressCollection recipients = message.DomainRecipients; if (this.Settings.MaxIncomingDomainRecipients > 0 && recipients.Count > this.Settings.MaxIncomingDomainRecipients) { throw new AgentException(AgentError.MaxDomainRecipients); } if (!m_settings.HasAddressManager) { // Address validation is turned off return; } Address[] resolved = m_configService.GetAddresses(recipients); if (resolved.IsNullOrEmpty()) { throw new AgentException(AgentError.NoDomainRecipients); } // Remove any addresses that could not be resolved // Yes, this is currently n^2, but given the typical # of addresses, cost should be insignificant int i = 0; while (i < recipients.Count) { DirectAddress recipient = recipients[i]; int iAddress = Array.FindIndex <Address>(resolved, x => x.Match(recipient)); if (iAddress >= 0) { ++i; // Found recipient.Tag = resolved[iAddress]; } else { recipients.RemoveAt(i); } } }