Search in sources :

Example 1 with OutgoingMessage

use of org.nhindirect.stagent.OutgoingMessage in project nhin-d by DirectProject.

the class DefaultSmtpAgent method postProcessMessage.

private void postProcessMessage(MessageProcessResult result) {
    boolean isOutgoing = (result.getProcessedMessage() instanceof OutgoingMessage);
    // check for rejected recipients
    if (auditor != null && result.getProcessedMessage().getRejectedRecipients() != null && result.getProcessedMessage().getRejectedRecipients().size() > 0) {
        Collection<AuditContext> contexts = createContextCollectionFromMessage(result.getProcessedMessage(), Arrays.asList(AuditEvents.DEFAULT_HEADER_CONTEXT));
        StringBuffer rejectedRecips = new StringBuffer();
        int cnt = 0;
        for (NHINDAddress address : result.getProcessedMessage().getRejectedRecipients()) {
            rejectedRecips.append(address.getAddress());
            if (++cnt < result.getProcessedMessage().getRejectedRecipients().size())
                rejectedRecips.append(", ");
        }
        contexts.add(new DefaultAuditContext(AuditEvents.REJECTED_RECIPIENTS_CONTEXT, rejectedRecips.toString()));
        auditor.audit(PRINICPAL, new AuditEvent(AuditEvents.REJECTED_RECIP_NAME, AuditEvents.EVENT_TYPE), contexts);
    }
    if (isOutgoing)
        postProcessOutgoingMessage(result);
    else
        postProcessIncomingMessage(result);
}
Also used : DefaultAuditContext(org.nhindirect.common.audit.DefaultAuditContext) NHINDAddress(org.nhindirect.stagent.NHINDAddress) OutgoingMessage(org.nhindirect.stagent.OutgoingMessage) AuditEvent(org.nhindirect.common.audit.AuditEvent) AuditContext(org.nhindirect.common.audit.AuditContext) DefaultAuditContext(org.nhindirect.common.audit.DefaultAuditContext)

Example 2 with OutgoingMessage

use of org.nhindirect.stagent.OutgoingMessage in project nhin-d by DirectProject.

the class WrappedMessageTest method testCopyNHINDStandard_encyrptMessage_assertPromotedInvalidCCHeaders.

public void testCopyNHINDStandard_encyrptMessage_assertPromotedInvalidCCHeaders() throws Exception {
    DefaultNHINDAgent agent = TestUtils.getStockAgent(Arrays.asList(new String[] { "cerner.com" }));
    String testMessage = TestUtils.readResource("CCTestMessage.txt");
    OutgoingMessage SMIMEenvMessage = agent.processOutgoing(testMessage);
    String ccHeader = SMIMEenvMessage.getMessage().getHeader(MailStandard.Headers.CC, ",");
    assertNotNull(ccHeader);
    assertEquals("User1@Cerner.com", ccHeader);
}
Also used : OutgoingMessage(org.nhindirect.stagent.OutgoingMessage) DefaultNHINDAgent(org.nhindirect.stagent.DefaultNHINDAgent)

Aggregations

OutgoingMessage (org.nhindirect.stagent.OutgoingMessage)2 AuditContext (org.nhindirect.common.audit.AuditContext)1 AuditEvent (org.nhindirect.common.audit.AuditEvent)1 DefaultAuditContext (org.nhindirect.common.audit.DefaultAuditContext)1 DefaultNHINDAgent (org.nhindirect.stagent.DefaultNHINDAgent)1 NHINDAddress (org.nhindirect.stagent.NHINDAddress)1