@Override /** * {@inheritDoc} */ protected void categorizeRecipients(TrustEnforcementStatus minTrustStatus) { super.categorizeRecipients(minTrustStatus); this.getDomainRecipients().removeUntrusted(minTrustStatus); } }
/** * Categorizes recipients as either trusted or untrusted (rejected). * @param minTrustStatus The minimum level of trust a recipient must have in order to be considered trusted. */ protected void categorizeRecipients(TrustEnforcementStatus minTrustStatus) { rejectedRecipients = NHINDAddressCollection.create(getRecipients().getUntrusted(minTrustStatus)); getRecipients().removeUntrusted(minTrustStatus); } }
/** * Indicates if the message has recipients that are in the agent's domain. * @return True if the message has recipients that are in the agent's domain. False otherwise. */ public boolean hasDomainRecipients() { NHINDAddressCollection dRecipients = this.getDomainRecipients(); return (dRecipients != null && dRecipients.size() > 0); }
/** * Removes all addresses from the collection that do not meet the minimum trust status. */ public void removeUntrusted(TrustEnforcementStatus minTrustStatus) { // Remove anybody who is not trusted for (int i = this.size() - 1; i >=0; --i) if (!this.get(i).isTrusted(minTrustStatus)) this.remove(i); }
protected void checkEnvelopeAddresses(NHINDAddressCollection recipients, NHINDAddress sender) { if (recipients == null || recipients.size() == 0) { throw new AgentException(AgentError.NoRecipients); } if (sender == null) { throw new AgentException(AgentError.NoSender); } recipients.setSource(AddressSource.RcptTo); sender.setSource(AddressSource.MailFrom); }
/** * Gets a list of recipients in the message that are part of the agent's domain. * @return A list of recipients in the agent's domain. */ public NHINDAddressCollection getDomainRecipients() { if (this.domainRecipients == null) { categorizeRecipients(getAgent().getDomains()); } return domainRecipients; }
protected void checkEnvelopeAddresses(MessageEnvelope envelope) { this.checkEnvelopeAddresses(envelope.getRecipients(), envelope.getSender()); }
/** * Indicates if the message has recipients that are not trusted by the address. * @return True if the message has recipients that are not trusted by the address. False otherwise. */ public boolean hasRejectedRecipients() { NHINDAddressCollection rejRecipients = this.getRejectedRecipients(); return (rejRecipients != null && rejRecipients.size() > 0); }
/** * Sets the collection of message recipients. * @param recipients The collection of message recipients. */ protected void setRecipients(NHINDAddressCollection recipients) { if (recipients == null || recipients.size() == 0) throw new AgentException(AgentError.NoRecipients); this.recipients = recipients; }
/** * Processes an incoming message represented by a raw string. The message will be decrypted and validated that it meets trust assertions. * @param messageText The raw contents of the incoming message that will be processed. * @param recipients The recipients of the message. This overrides the routing headers in the message. * @param sender The sender of the message. This overrides the to FROM routing header in the message. * @return An incoming messaging object that contains the unwrapped and decrypted message. */ public IncomingMessage processIncoming(String messageText, NHINDAddressCollection recipients, NHINDAddress sender) { this.checkEnvelopeAddresses(recipients, sender); IncomingMessage message = new IncomingMessage(messageText, recipients, sender); return this.processIncoming(message); }
/** * Gets a list of recipients in the message that are not trusted by the address. * @return A list of recipients in the message that are not trusted by the address. */ public NHINDAddressCollection getRejectedRecipients() { if (this.rejectedRecipients == null) { this.rejectedRecipients = new NHINDAddressCollection(); } return rejectedRecipients; }
/** * Sets the sender of the message. * @param sender The sender of the message. */ protected void setSender(NHINDAddress sender) { if (sender == null) { throw new AgentException(AgentError.NoSender); } this.sender = sender; }
/** * Indicates if the the address's domain is in the list of domains. The domain check is case insensitive. * @param domains The domain to check. * @return True if the address's domain is in the list of provided domains. False otherwise. */ public boolean isInDomain(Collection<String> domains) { for (String domain : domains) if (domainEquals(domain)) return true; return false; }
/** * Constructs an envelope from a message represented by a raw string.. * @param rawMessage The mime message. */ public DefaultMessageEnvelope(String rawMessage) { this(fromStringToMessage(rawMessage)); }
/** * The collection of message recipients. * @return Collection of message recipients. */ public NHINDAddressCollection getRecipients() { if (this.recipients == null) { this.collectRecipients(); } return recipients; }
/** * Removes all addresses from the collection that are note trusted. */ public void removeUntrusted() { this.removeUntrusted(NHINDAddressCollection.DefaultMinTrustStatus); }
/** * Gets all addresses in the collection that are trusted. * @return All addresses in the collection that are trusted. */ public Collection<NHINDAddress> getTrusted() { return this.getTrusted(NHINDAddressCollection.DefaultMinTrustStatus); }
/** * Indicates if the collection has any addresses that are trusted. * @return True if the collection contains any addresses that are trusted. False otherwise. */ public boolean isTrusted() { return this.isTrusted(NHINDAddressCollection.DefaultMinTrustStatus); }
/** * Gets a list of recipients in the message that are not part of the agent's domain. * @return A list of recipients that are not in the agent's domain. */ public Collection<NHINDAddress> getOtherRecipients() { if (this.otherRecipients == null) { categorizeRecipients(getAgent().getDomains()); } return this.otherRecipients; }
/** * Sets the mime message wrapped in the envelope. * @param message The mime message wrapped in the envelope. */ public void setMessage(Message message) { if (message == null) throw new AgentException(AgentError.MissingMessage); this.message = message; }