/** * 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; }
/** * 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; }
/** * 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; }
/** * Constructs a model with a provided chain validator. * @param validator The trust validator used to valid trust of a certificate with trust anchors. */ public TrustModel(TrustChainValidator validator) { certChainValidator = validator; try { this.policyFilter = PolicyFilterFactory.getInstance(); } catch (PolicyParseException e) { throw new AgentException(AgentError.Unexpected, "Failed to create policy filter object.", e); } }
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); }
/** * Constructs a model with a default validator. */ public TrustModel() { certChainValidator = new TrustChainValidator(); try { this.policyFilter = PolicyFilterFactory.getInstance(); } catch (PolicyParseException e) { throw new AgentException(AgentError.Unexpected, "Failed to create policy filter object.", e); } }
throw new AgentException(AgentError.MissingSenderCertificate); else throw new AgentException(AgentError.MissingRecipientCertificate);
throw new AgentException(AgentError.InvalidPolicy, processException);
throw new AgentException(AgentError.MissingRecipientCertificate); else throw new AgentException(AgentError.MissingSenderCertificate);
throw new AgentException(AgentError.InvalidPolicy, processException);
throw new AgentException(AgentError.MissingMessage); throw new AgentException(AgentError.UntrustedMessage);
/** * Constructs an envelope from a message. * @param message The mime message. */ public DefaultMessageEnvelope(Message message) { if (message == null) throw new IllegalArgumentException(); this.message = message; this.setRecipients(this.collectRecipients()); try { if (message.getFrom() == null || message.getFrom().length == 0) throw new AgentException(AgentError.MissingFrom); this.setSender(new NHINDAddress((InternetAddress)message.getFrom()[0], AddressSource.From)); } catch (MessagingException e) { throw new AgentException(AgentError.MissingFrom, e); } }
throw new AgentException(AgentError.Unexpected, "Failed to create policy filter object.", e);
throw new AgentException(AgentError.UntrustedMessage); throw new AgentException(AgentError.MissingSenderSignature);
throw new AgentException(AgentError.MessageTamperDectection, exceptionMessage); else
throw new AgentException(AgentError.MissingFrom); throw new AgentException(AgentError.MissingTo); if (!message.hasRecipients()) throw new AgentException(AgentError.NoTrustedRecipients);
throw new AgentException(AgentError.UnsignedMessage);
if (!message.hasDomainRecipients()) throw new AgentException(AgentError.NoTrustedRecipients);