View Javadoc

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