/** * Splits recipients into domain recipients and external recipients. The agent's domains are used to determine a recipients category. * @param domain A collection of local domains supported by the agent. */ protected void categorizeRecipients(Collection<String> domains) { if (domains == null || domains.size() == 0) { throw new IllegalArgumentException(); } NHINDAddressCollection recipients = this.getRecipients(); this.domainRecipients = new NHINDAddressCollection(); this.otherRecipients = new ArrayList<NHINDAddress>(); for (NHINDAddress address : recipients) { if (address.isInDomain(domains)) { this.domainRecipients.add(address); } else { this.otherRecipients.add(address); } } }
/** * Determines if a message is incoming or outgoing based on the domains available in the configured agent * and the sender of the message. * @param msg The message that is being processed. * @param sender The sender of the message. * @param agent The STA that contains the available domains. * @return true if the message is determined to be outgoing; false otherwise */ public static boolean isOutgoing(MimeMessage msg, NHINDAddress sender, NHINDAgent agent) { if (agent == null || agent.getDomains() == null) return false; // if the sender is not from our domain, then is has to be an incoming message if (!sender.isInDomain(agent.getDomains())) return false; else { // depending on the SMTP stack configuration, a message with a sender from our domain // may still be an incoming message... check if the message is encrypted if (SMIMEStandard.isEncrypted(msg)) { return false; } } return true; }
public boolean isOutgoing(MessageEnvelope envelope) { // if the sender is not from our domain, then is has to be an incoming message if (!envelope.getSender().isInDomain(agent.getDomains())) return false; else { // depending on the SMTP stack configuration, a message with a sender from our domain // may still be an incoming message... check if the message is encrypted if (SMIMEStandard.isEncrypted(envelope.getMessage())) { return false; } } return true; }