use of org.apache.mailet.MailAddress in project nhin-d by DirectProject.
the class RecipientIsLocalAndSMTPAuthUserIs method match.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Collection<MailAddress> match(Mail mail) throws MessagingException {
LOGGER.info("Servicing RecipientIsLocalAndSMTPAuthUserIs matcher");
String authUser = (String) mail.getAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME);
if (authUser == null || !StringUtils.equalsIgnoreCase(user, authUser)) {
LOGGER.info("Auth user is not " + user + ", skipping");
return Collections.<MailAddress>emptyList();
}
MailetContext mailetContext = getMailetContext();
Collection<MailAddress> recipients = new ArrayList<MailAddress>();
for (MailAddress recipient : (Collection<MailAddress>) mail.getRecipients()) {
if (mailetContext.isLocalServer(recipient.getHost()) && mailetContext.isLocalUser(recipient.getUser()))
recipients.add(recipient);
}
if (recipients.isEmpty())
LOGGER.info("Matched no recipients");
else
for (MailAddress addr : recipients) LOGGER.info("Matched recipient " + addr.toString());
return recipients;
}
use of org.apache.mailet.MailAddress in project nhin-d by DirectProject.
the class RecipientIsNotXd method match.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Collection<MailAddress> match(Mail mail) throws MessagingException {
LOGGER.info("Attempting to match non-XD recipients");
Collection<MailAddress> recipients = new ArrayList<MailAddress>();
for (MailAddress addr : (Collection<MailAddress>) mail.getRecipients()) {
if (!routingResolver.isXdEndpoint(addr.toString())) {
recipients.add(addr);
}
}
if (recipients.isEmpty())
LOGGER.info("Matched no recipients");
else
for (MailAddress addr : recipients) LOGGER.info("Matched recipient " + addr.toString());
return recipients;
}
use of org.apache.mailet.MailAddress in project nhin-d by DirectProject.
the class RecipientIsXdAndNotSMIME method match.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Collection<MailAddress> match(Mail mail) throws MessagingException {
LOGGER.info("Attempting to match XD recipients");
Collection<MailAddress> recipients = new ArrayList<MailAddress>();
MimeMessage message = mail.getMessage();
if (message.isMimeType("application/x-pkcs7-mime") || message.isMimeType("application/pkcs7-mime")) {
LOGGER.info("MimeMessage is SMIME, skipping");
return Collections.<MailAddress>emptyList();
}
for (MailAddress addr : (Collection<MailAddress>) mail.getRecipients()) {
if (routingResolver.isXdEndpoint(addr.toString())) {
recipients.add(addr);
}
}
if (recipients.isEmpty()) {
LOGGER.info("Matched no recipients");
} else {
for (MailAddress addr : recipients) {
LOGGER.info("Matched recipient " + addr.toString());
}
}
return recipients;
}
Aggregations