View Javadoc

1   /************************************************************************
2    * Copyright (c) 1999-2006 The Apache Software Foundation.             *
3    * All rights reserved.                                                *
4    * ------------------------------------------------------------------- *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you *
6    * may not use this file except in compliance with the License. You    *
7    * may obtain a copy of the License at:                                *
8    *                                                                     *
9    *     http://www.apache.org/licenses/LICENSE-2.0                      *
10   *                                                                     *
11   * Unless required by applicable law or agreed to in writing, software *
12   * distributed under the License is distributed on an "AS IS" BASIS,   *
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
14   * implied.  See the License for the specific language governing       *
15   * permissions and limitations under the License.                      *
16   ***********************************************************************/
17  
18  package org.apache.james.smtpserver;
19  
20  
21  import org.apache.james.util.watchdog.Watchdog;
22  import org.apache.mailet.Mail;
23  
24  import java.io.IOException;
25  import java.io.InputStream;
26  import java.util.HashMap;
27  
28  /***
29   * All the handlers access this interface to communicate with
30   * SMTPHandler object
31   */
32  
33  public interface SMTPSession {
34  
35      // Keys used to store/lookup data in the internal state hash map
36      public final static String MESG_FAILED = "MESG_FAILED";   // Message failed flag
37      public final static String SENDER = "SENDER_ADDRESS";     // Sender's email address
38      public final static String RCPT_LIST = "RCPT_LIST";   // The message recipients
39      public final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; // HELO or EHLO
40  
41      /***
42       * Writes response string to the client
43       *
44       * @param respString String that needs to send to the client
45       */
46      void writeResponse(String respString);
47  
48      /***
49       * Reads a line of characters off the command line.
50       *
51       * @return the trimmed input line
52       * @throws IOException if an exception is generated reading in the input characters
53       */
54      String readCommandLine() throws IOException;
55  
56  
57      /***
58       * Returns ResponseBuffer, this optimizes the unecessary creation of resources
59       * by each handler object
60       *
61       * @return responseBuffer
62       */
63      StringBuffer getResponseBuffer();
64  
65      /***
66       * Clears the response buffer, returning the String of characters in the buffer.
67       *
68       * @return the data in the response buffer
69       */
70      String clearResponseBuffer();
71  
72      /***
73       * Returns Inputstream for handling messages and commands
74       *
75       * @return InputStream object
76       */
77      InputStream getInputStream();
78  
79      /***
80       * Returns currently process command name
81       *
82       * @return current command name
83       */
84      String getCommandName();
85  
86      /***
87       * Returns currently process command argument
88       *
89       * @return current command argument
90       */
91      String getCommandArgument();
92  
93      /***
94       * Returns Mail object for message handlers to process
95       *
96       * @return Mail object
97       */
98      Mail getMail();
99  
100     /***
101      * Sets the MailImpl object for further processing
102      *
103      * @param mail MailImpl object
104      */
105     void setMail(Mail mail);
106 
107     /***
108      * Returns host name of the client
109      *
110      * @return hostname of the client
111      */
112     String getRemoteHost();
113 
114     /***
115      * Returns host ip address of the client
116      *
117      * @return host ip address of the client
118      */
119     String getRemoteIPAddress();
120 
121     /***
122      * this makes the message to be dropped inprotocol
123      *
124      */
125     void abortMessage();
126 
127     /***
128      * this makes the session to close
129      *
130      */
131     void endSession();
132 
133     /***
134      * Returns the session status
135      *
136      * @return if the session is open or closed
137      */
138     boolean isSessionEnded();
139 
140     /***
141      * Returns Map that consists of the state of the SMTPSession
142      *
143      * @return map of the current SMTPSession state
144      */
145     HashMap getState();
146 
147     /***
148      * Resets message-specific, but not authenticated user, state.
149      *
150      */
151     void resetState();
152 
153     /***
154      * Returns SMTPHandler service wide configuration
155      *
156      * @return SMTPHandlerConfigurationData
157      */
158     SMTPHandlerConfigurationData getConfigurationData();
159 
160     /***
161      * Sets the blocklisted value
162      *
163      * @param blocklisted
164      */
165     void setBlockListed(boolean blocklisted);
166 
167     /***
168      * Returns the blocklisted status
169      *
170      * @return blocklisted
171      */
172     boolean isBlockListed();
173 
174     /***
175      * Returns whether Relaying is allowed or not
176      *
177      * @return the relaying status
178      */
179     boolean isRelayingAllowed();
180 
181     /***
182      * Returns whether Authentication is required or not
183      *
184      * @return authentication required or not
185      */
186     boolean isAuthRequired();
187     
188     /***
189      * Returns whether remote server needs to send HELO/EHLO
190      *
191      * @return HELO/EHLO required or not
192      */
193     boolean useHeloEhloEnforcement();
194 
195     /***
196      * Returns the user name associated with this SMTP interaction.
197      *
198      * @return the user name
199      */
200     String getUser();
201 
202     /***
203      * Sets the user name associated with this SMTP interaction.
204      *
205      * @param userID the user name
206      */
207     void setUser(String user);
208 
209     /***
210      * Returns Watchdog object used for handling timeout
211      *
212      * @return Watchdog object
213      */
214     Watchdog getWatchdog();
215 
216     /***
217      * Returns the SMTP session id
218      *
219      * @return SMTP session id
220      */
221     String getSessionID();
222 
223 }
224