View Javadoc
1   /* 
2   Copyright (c) 2010, NHIN Direct Project
3   All rights reserved.
4   
5   Authors:
6      Umesh Madan     umeshma@microsoft.com
7      Greg Meyer      gm2552@cerner.com
8    
9   Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10  
11  Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 
13  in the documentation and/or other materials provided with the distribution.  Neither the name of the The NHIN Direct Project (nhindirect.org). 
14  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
16  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 
17  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
18  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
19  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
20  THE POSSIBILITY OF SUCH DAMAGE.
21  */
22  
23  package org.nhindirect.gateway.smtp;
24  
25  import javax.mail.internet.MimeMessage;
26  
27  import org.nhindirect.stagent.NHINDAddress;
28  import org.nhindirect.stagent.NHINDAddressCollection;
29  import org.nhindirect.stagent.NHINDAgent;
30  
31  
32  /**
33   * The SmtpAgent is a generic gateway to the security trust agent that handles message over the SMTP protocol.  It is intended to sit between an SMTP
34   * server implementation coupled with an server specific bridge and the security trust bridge.  Because each SMTP server potentially 
35   * handles custom message processing differently and creates server specific message/SMTP envelope wrappers, bridge implementations are specific
36   * to the servers that they are coupled with.  The bridges are responsible for intercepting messages through the SMTP stack, gathers routing information
37   * (either from the message routing headers or the SMTP envelope headers), calling the SmtpAgent, and moving processed messages forward through the SMTP
38   * stack.  Bridges are also responsible for relaying any bounce messages created by the SmtpAgent.  NOTE: Bounce messages are also processed by the 
39   * security and trust agent before being returned. 
40   * 
41   * @author Greg Meyer
42   *
43   */
44  public interface SmtpAgent 
45  {
46  	/**
47  	 * Processes an message from an SMTP stack.  The bridge component between the SMTP stack and the SMTP agent is responsible for
48  	 * extracting the message, the recipient list, and the sender.  In some cases, the routing headers may have different information than
49  	 * what is populated in the SMTP MAIL FROM and RCTP TO headers.  In these cases, the SMTP headers should be favored over the routing
50  	 * headers in the message and passed as the recipient collection and sender to this method.
51  	 * @param message The message in the SMTP envelope.
52  	 * @param recipients The recipients of the message.  The RCTP TO headers should be used over the message routing headers.
53  	 * @param sender The send of the message. The MAIL FROM header should be used over the From: routing header in the message.
54  	 */
55  	public MessageProcessResult processMessage(MimeMessage message, NHINDAddressCollection recipients, NHINDAddress sender);
56  	
57  	/**
58  	 * Gets a references to the security and trust agent used by the SmtpAgent.
59  	 * @return A references to the security and trust agent used by the SmtpAgent
60  	 */
61  	public NHINDAgent getAgent();
62  	
63  	/**
64  	 * Gets the configuration settings of the SmtpAgent.
65  	 * @return The configuration settings of the SmtpAgent.
66  	 */
67  	public SmtpAgentSettings getSmtpAgentSettings();
68  }