com.icegreen.greenmail.imap
Class ImapSessionImpl

java.lang.Object
  extended by com.icegreen.greenmail.imap.ImapSessionImpl
All Implemented Interfaces:
ImapSession

public final class ImapSessionImpl
extends Object
implements ImapSession

Version:
$Revision: 109034 $
Author:
Darrell DeBoer

Constructor Summary
ImapSessionImpl(ImapHostManager imapHost, UserManager users, ImapHandler handler, String clientHostName, String clientAddress)
           
 
Method Summary
 void closeConnection()
          Closes the connection for this session.
 void closeConnection(String byeMessage)
           
 void deselect()
          Moves the session out of ImapSessionState.SELECTED state and back into ImapSessionState.AUTHENTICATED state.
 String getClientHostname()
           
 String getClientIP()
           
 ImapHostManager getHost()
          Provides the Imap host for this server, which is used for all access to mail storage and subscriptions.
 ImapSessionFolder getSelected()
          Provides the selected mailbox for this session, or null if this session is not in ImapSessionState.SELECTED state.
 ImapSessionState getState()
           
 GreenMailUser getUser()
          Provides the authenticated user for this session, or null if this session is not in ImapSessionState.AUTHENTICATED or ImapSessionState.SELECTED state.
 UserManager getUserManager()
          Provides the UserManager for this session, to allow session to validate logins.
 boolean selectedIsReadOnly()
           
 void setAuthenticated(GreenMailUser user)
          Moves the session into ImapSessionState.AUTHENTICATED state with the supplied user.
 void setSelected(MailFolder folder, boolean readOnly)
          Moves this session into ImapSessionState.SELECTED state and sets the supplied mailbox to be the currently selected mailbox.
 void unsolicitedResponses(ImapResponse request)
          Sends any unsolicited responses to the client, such as EXISTS and FLAGS responses when the selected mailbox is modified by another user.
 void unsolicitedResponses(ImapResponse response, boolean omitExpunged)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImapSessionImpl

public ImapSessionImpl(ImapHostManager imapHost,
                       UserManager users,
                       ImapHandler handler,
                       String clientHostName,
                       String clientAddress)
Method Detail

getHost

public ImapHostManager getHost()
Description copied from interface: ImapSession
Provides the Imap host for this server, which is used for all access to mail storage and subscriptions.

Specified by:
getHost in interface ImapSession
Returns:
The ImapHost for this server.

unsolicitedResponses

public void unsolicitedResponses(ImapResponse request)
                          throws FolderException
Description copied from interface: ImapSession
Sends any unsolicited responses to the client, such as EXISTS and FLAGS responses when the selected mailbox is modified by another user.

Specified by:
unsolicitedResponses in interface ImapSession
Parameters:
request - The response to write to
Throws:
FolderException

unsolicitedResponses

public void unsolicitedResponses(ImapResponse response,
                                 boolean omitExpunged)
                          throws FolderException
Specified by:
unsolicitedResponses in interface ImapSession
Throws:
FolderException

closeConnection

public void closeConnection(String byeMessage)
Specified by:
closeConnection in interface ImapSession

closeConnection

public void closeConnection()
Description copied from interface: ImapSession
Closes the connection for this session.

Specified by:
closeConnection in interface ImapSession

getUserManager

public UserManager getUserManager()
Description copied from interface: ImapSession
Provides the UserManager for this session, to allow session to validate logins.

Specified by:
getUserManager in interface ImapSession
Returns:
The UserManager for this session.

getClientHostname

public String getClientHostname()
Specified by:
getClientHostname in interface ImapSession
Returns:
The hostname of the connected client.

getClientIP

public String getClientIP()
Specified by:
getClientIP in interface ImapSession
Returns:
The IP address of the connected client.

setAuthenticated

public void setAuthenticated(GreenMailUser user)
Description copied from interface: ImapSession
Moves the session into ImapSessionState.AUTHENTICATED state with the supplied user.

Specified by:
setAuthenticated in interface ImapSession
Parameters:
user - The user who is authenticated for this session.

getUser

public GreenMailUser getUser()
Description copied from interface: ImapSession
Provides the authenticated user for this session, or null if this session is not in ImapSessionState.AUTHENTICATED or ImapSessionState.SELECTED state.

Specified by:
getUser in interface ImapSession
Returns:
The user authenticated for this session

deselect

public void deselect()
Description copied from interface: ImapSession
Moves the session out of ImapSessionState.SELECTED state and back into ImapSessionState.AUTHENTICATED state. The selected mailbox is cleared.

Specified by:
deselect in interface ImapSession

setSelected

public void setSelected(MailFolder folder,
                        boolean readOnly)
Description copied from interface: ImapSession
Moves this session into ImapSessionState.SELECTED state and sets the supplied mailbox to be the currently selected mailbox.

Specified by:
setSelected in interface ImapSession
Parameters:
folder - The selected mailbox.
readOnly - If true, the selection is set to be read only.

getSelected

public ImapSessionFolder getSelected()
Description copied from interface: ImapSession
Provides the selected mailbox for this session, or null if this session is not in ImapSessionState.SELECTED state.

Specified by:
getSelected in interface ImapSession
Returns:
the currently selected mailbox.

selectedIsReadOnly

public boolean selectedIsReadOnly()

getState

public ImapSessionState getState()
Specified by:
getState in interface ImapSession
Returns:
Returns the current state of this session.