/** * Indicates if the address's domain matches the provided domain. The domain check is case insensitive. * @param domain The domain to match. * @return True if the address's domain matches the provided domain. False otherwise. */ public boolean domainEquals(String domain) { return getHost().equalsIgnoreCase(domain); }
/** * Gets the certificates (anchors) for the address's domain. * @param address The address used to search for trust anchors. This method uses the address's domain to search * for trust anchors. Domain search is case insensitive. * @return A collection of certificates (anchors) for the address's domain. */ public Collection<X509Certificate> getCertificates(InternetAddress address) { if (address == null) { throw new IllegalArgumentException(); } // get the certificates for this address's domain String domain = NHINDAddress.getHost(address); // convert to upper case for lookup domain = domain.toUpperCase(Locale.getDefault()); Collection<X509Certificate> retCerts = certs.get(domain); if (retCerts == null) retCerts = Collections.emptyList(); // return an empty list of no certs are found return retCerts; } }
/** * Gets the policies for a given email address. The email address's domain name is used * to look up the policy collection. * @param address The email address used to lookup policies. * @param incoming Indicates if the incoming or outgoing policy map should be searched. true for incoming messages, false for outgoing * @return */ protected Collection<PolicyExpression> getPolicies(InternetAddress address, boolean incoming) { if (address == null) { throw new IllegalArgumentException("Address cannot be null"); } final Map<String, Collection<PolicyExpression>> searchPolicies = (incoming) ? this.incomingPolicies : this.outgoingPolicies; // get the certificates for this address's domain and convert to upper case final String domain = NHINDAddress.getHost(address).toUpperCase(Locale.getDefault()); Collection<PolicyExpression> retPolocies = searchPolicies.get(domain); if (retPolocies == null) retPolocies = Collections.emptyList(); // return an empty list of no policies are found return retPolocies; } }
protected Map<String, Collection<InternetAddress>> groupByDomain(Collection<InternetAddress> recipients) { final HashMultimap<String, InternetAddress> groupByServerMultimap = HashMultimap.create(); for (InternetAddress recipient : recipients) { final NHINDAddress addr = new NHINDAddress(recipient); groupByServerMultimap.put(addr.getHost(), recipient); } return groupByServerMultimap.asMap(); } }
final InternetAddress postmaster = new InternetAddress(postmasterMailbox + "@" + failedRecipeint.getHost().toLowerCase(Locale.getDefault())); Collection<NHINDAddress> group = postmasterToFailed.get(postmaster); if (group == null)
if (senderAddr != null && senderAddr.length > 0) domain = NHINDAddress.getHost((InternetAddress)senderAddr[0]).toUpperCase(Locale.getDefault());
final String domainName = new NHINDAddress(smtpMessage.getRecipientAddresses().get(0)).getHost();
/** * {@inheritDoc} */ protected Notification createAck(InternetAddress address) { Notification notification = new Notification(NotificationType.Dispatched); if (settings.hasText()) { notification.setExplanation(settings.getText()); } notification.setReportingAgent(new ReportingUserAgent(NHINDAddress.getHost(address), settings.getProductName())); notification.setExtensions(Arrays.asList(MDNStandard.DispositionOption_TimelyAndReliable)); return notification; } }
protected void findSenderSignatures(IncomingMessage message) { message.setSenderSignatures(null); NHINDAddress sender = message.getSender(); Collection<DefaultMessageSignatureImpl> senderSignatures = new ArrayList<DefaultMessageSignatureImpl>(); // check for signatures at an individual level Collection<SignerCertPair> individualSenders = CryptoExtensions.findSignersByName(message.getSignature(), sender.getAddress(), null); // check for signatures at an org level Collection<SignerCertPair> orgSenders = CryptoExtensions.findSignersByName(message.getSignature(), sender.getHost(), Arrays.asList(new String[] {sender.getAddress()})); for (SignerCertPair pair : individualSenders) senderSignatures.add(new DefaultMessageSignatureImpl(pair.getSigner(), false, pair.getCertificate())); for (SignerCertPair pair : orgSenders) senderSignatures.add(new DefaultMessageSignatureImpl(pair.getSigner(), true, pair.getCertificate())); message.setSenderSignatures(senderSignatures); }
protected Notification createAck(InternetAddress address) { Notification notification = new Notification(NotificationType.Processed); if (settings.hasText()) { notification.setExplanation(settings.getText()); } notification.setReportingAgent(new ReportingUserAgent(NHINDAddress.getHost(address), settings.getProductName())); return notification; }