001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.smtpserver;
019:
020: import org.apache.james.util.watchdog.Watchdog;
021: import org.apache.mailet.Mail;
022:
023: import java.io.IOException;
024: import java.io.InputStream;
025: import java.util.HashMap;
026:
027: /**
028: * All the handlers access this interface to communicate with
029: * SMTPHandler object
030: */
031:
032: public interface SMTPSession {
033:
034: // Keys used to store/lookup data in the internal state hash map
035: public final static String MESG_FAILED = "MESG_FAILED"; // Message failed flag
036: public final static String SENDER = "SENDER_ADDRESS"; // Sender's email address
037: public final static String RCPT_LIST = "RCPT_LIST"; // The message recipients
038: public final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; // HELO or EHLO
039:
040: /**
041: * Writes response string to the client
042: *
043: * @param respString String that needs to send to the client
044: */
045: void writeResponse(String respString);
046:
047: /**
048: * Reads a line of characters off the command line.
049: *
050: * @return the trimmed input line
051: * @throws IOException if an exception is generated reading in the input characters
052: */
053: String readCommandLine() throws IOException;
054:
055: /**
056: * Returns ResponseBuffer, this optimizes the unecessary creation of resources
057: * by each handler object
058: *
059: * @return responseBuffer
060: */
061: StringBuffer getResponseBuffer();
062:
063: /**
064: * Clears the response buffer, returning the String of characters in the buffer.
065: *
066: * @return the data in the response buffer
067: */
068: String clearResponseBuffer();
069:
070: /**
071: * Returns Inputstream for handling messages and commands
072: *
073: * @return InputStream object
074: */
075: InputStream getInputStream();
076:
077: /**
078: * Returns currently process command name
079: *
080: * @return current command name
081: */
082: String getCommandName();
083:
084: /**
085: * Returns currently process command argument
086: *
087: * @return current command argument
088: */
089: String getCommandArgument();
090:
091: /**
092: * Returns Mail object for message handlers to process
093: *
094: * @return Mail object
095: */
096: Mail getMail();
097:
098: /**
099: * Sets the MailImpl object for further processing
100: *
101: * @param mail MailImpl object
102: */
103: void setMail(Mail mail);
104:
105: /**
106: * Returns host name of the client
107: *
108: * @return hostname of the client
109: */
110: String getRemoteHost();
111:
112: /**
113: * Returns host ip address of the client
114: *
115: * @return host ip address of the client
116: */
117: String getRemoteIPAddress();
118:
119: /**
120: * this makes the message to be dropped inprotocol
121: *
122: */
123: void abortMessage();
124:
125: /**
126: * this makes the session to close
127: *
128: */
129: void endSession();
130:
131: /**
132: * Returns the session status
133: *
134: * @return if the session is open or closed
135: */
136: boolean isSessionEnded();
137:
138: /**
139: * Returns Map that consists of the state of the SMTPSession
140: *
141: * @return map of the current SMTPSession state
142: */
143: HashMap getState();
144:
145: /**
146: * Resets message-specific, but not authenticated user, state.
147: *
148: */
149: void resetState();
150:
151: /**
152: * Returns SMTPHandler service wide configuration
153: *
154: * @return SMTPHandlerConfigurationData
155: */
156: SMTPHandlerConfigurationData getConfigurationData();
157:
158: /**
159: * Sets the blocklisted value
160: *
161: * @param blocklisted
162: */
163: void setBlockListed(boolean blocklisted);
164:
165: /**
166: * Returns the blocklisted status
167: *
168: * @return blocklisted
169: */
170: boolean isBlockListed();
171:
172: /**
173: * Returns whether Relaying is allowed or not
174: *
175: * @return the relaying status
176: */
177: boolean isRelayingAllowed();
178:
179: /**
180: * Returns whether Authentication is required or not
181: *
182: * @return authentication required or not
183: */
184: boolean isAuthRequired();
185:
186: /**
187: * Returns whether remote server needs to send HELO/EHLO
188: *
189: * @return HELO/EHLO required or not
190: */
191: boolean useHeloEhloEnforcement();
192:
193: /**
194: * Returns the user name associated with this SMTP interaction.
195: *
196: * @return the user name
197: */
198: String getUser();
199:
200: /**
201: * Sets the user name associated with this SMTP interaction.
202: *
203: * @param userID the user name
204: */
205: void setUser(String user);
206:
207: /**
208: * Returns Watchdog object used for handling timeout
209: *
210: * @return Watchdog object
211: */
212: Watchdog getWatchdog();
213:
214: /**
215: * Returns the SMTP session id
216: *
217: * @return SMTP session id
218: */
219: String getSessionID();
220:
221: }
|