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  
21  
22  package org.apache.james.pop3server;
23  
24  
25  import org.apache.james.services.MailRepository;
26  import org.apache.james.util.watchdog.Watchdog;
27  
28  import java.io.IOException;
29  import java.io.OutputStream;
30  import java.util.HashMap;
31  import java.util.List;
32  
33  /**
34   * All the handlers access this interface to communicate with
35   * POP3Handler object
36   */
37  
38  public interface POP3Session {
39  
40      /**
41       * Writes response string to the client
42       *
43       * @param respString String that needs to send to the client
44       */
45      void writeResponse(String respString);
46  
47      /**
48       * Reads a line of characters off the command line.
49       *
50       * @return the trimmed input line
51       * @throws IOException if an exception is generated reading in the input characters
52       */
53      String readCommandLine() throws IOException;
54  
55  
56      /**
57       * Returns ResponseBuffer, this optimizes the unecessary creation of resources
58       * by each handler object
59       *
60       * @return responseBuffer
61       */
62      StringBuffer getResponseBuffer();
63  
64      /**
65       * Clears the response buffer, returning the String of characters in the buffer.
66       *
67       * @return the data in the response buffer
68       */
69      String clearResponseBuffer();
70  
71      /**
72       * Returns currently process command name
73       *
74       * @return current command name
75       */
76      String getCommandName();
77  
78      /**
79       * Returns currently process command argument
80       *
81       * @return current command argument
82       */
83      String getCommandArgument();
84  
85      /**
86       * Returns host name of the client
87       *
88       * @return hostname of the client
89       */
90      String getRemoteHost();
91  
92      /**
93       * Returns host ip address of the client
94       *
95       * @return host ip address of the client
96       */
97      String getRemoteIPAddress();
98  
99      /**
100      * this makes the session to close
101      *
102      */
103     void endSession();
104 
105     /**
106      * Returns the session status
107      *
108      * @return if the session is open or closed
109      */
110     boolean isSessionEnded();
111 
112     /**
113      * Returns Map that consists of the state of the POP3Session
114      *
115      * @return map of the current POP3Session state
116      */
117     HashMap getState();
118 
119     /**
120      * Resets message-specific, but not authenticated user, state.
121      *
122      */
123     void resetState();
124 
125     /**
126      * Returns POP3Handler service wide configuration
127      *
128      * @return POP3HandlerConfigurationData
129      */
130     POP3HandlerConfigurationData getConfigurationData();
131 
132     /**
133      * Returns the user name associated with this POP3 interaction.
134      *
135      * @return the user name
136      */
137     String getUser();
138 
139     /**
140      * Sets the user name associated with this POP3 interaction.
141      *
142      * @param user the user name
143      */
144     void setUser(String user);
145 
146     /**
147      * Returns Watchdog object used for handling timeout
148      *
149      * @return Watchdog object
150      */
151     Watchdog getWatchdog();
152     
153     /**
154      * Returns the current handler state
155      *
156      * @return handler state
157      */
158     int getHandlerState();
159 
160     /**
161      * Sets the new handler state
162      * 
163      * @param handlerState state
164      */
165     void setHandlerState(int handlerState);
166 
167     /**
168      * Returns the current user inbox
169      *
170      * @return MailRepository
171      */
172     MailRepository getUserInbox();
173 
174     /**
175      * Sets the user's mail repository
176      * 
177      * @param userInbox userInbox
178      */
179     void setUserInbox(MailRepository userInbox);
180 
181     /**
182      * Returns the mail list contained in the mailbox
183      * 
184      * @return mailbox content
185      */
186     List getUserMailbox();
187 
188     /**
189      * Sets a new mailbox content
190      * 
191      * @param userMailbox mailbox
192      */
193     void setUserMailbox(List userMailbox);
194     
195     /**
196      * Returns the backup mailbox
197      * 
198      * @return list backup
199      */
200     List getBackupUserMailbox();
201 
202 
203     /**
204      * Sets a new backup mailbox content
205      * 
206      * @param backupUserMailbox the mailbox backup
207      */
208     void setBackupUserMailbox(List backupUserMailbox);
209 
210     /**
211      * Returns the raw output stream
212      *
213      * @return the raw outputstream
214      */
215     OutputStream getOutputStream();
216 
217 }
218