public class Session extends java.lang.Object implements java.lang.Runnable, MessageContext
Constructor and Description |
---|
Session(SMTPServer server,
org.subethamail.smtp.server.ServerThread serverThread,
java.net.Socket socket)
Creates the Runnable Session object.
|
Modifier and Type | Method and Description |
---|---|
void |
addRecipient(java.lang.String recipientAddress) |
void |
closeSocket()
Close the client socket if it is open
|
protected void |
endMessageHandler()
Safely calls done() on a message hander, if one exists
|
AuthenticationHandler |
getAuthenticationHandler() |
int |
getDeclaredMessageSize() |
boolean |
getHasMailFrom() |
java.lang.String |
getHelo()
Simple state
|
MessageHandler |
getMessageHandler() |
java.io.InputStream |
getRawInput() |
CRLFTerminatedReader |
getReader() |
int |
getRecipientCount() |
java.net.InetSocketAddress |
getRemoteAddress() |
SMTPServer |
getServer() |
java.lang.String |
getSessionId()
Returns an identifier of the session which is reasonably unique within
an extended time period.
|
java.lang.String |
getSingleRecipient()
Returns the first accepted recipient if there is exactly one accepted
recipient, otherwise it returns null.
|
SMTPServer |
getSMTPServer() |
java.net.Socket |
getSocket()
This method is only used by the start tls command
|
java.security.cert.Certificate[] |
getTlsPeerCertificates()
Returns the identity of the peer which was established as part of the TLS handshake
as defined by
SSLSession.getPeerCertificates() . |
boolean |
isAuthenticated() |
boolean |
isTLSStarted() |
void |
quit()
Triggers the shutdown of the thread and the closing of the connection.
|
void |
resetMessageState()
Some state is associated with each particular message (senders, recipients, the message handler).
|
void |
resetSmtpProtocol()
Reset the SMTP protocol to the initial state, which is the state after
a server issues a 220 service ready greeting.
|
void |
run()
The thread for each session runs on this and shuts down when the quitting
member goes true.
|
void |
sendResponse(java.lang.String response)
Sends the response to the client
|
void |
setAuthenticationHandler(AuthenticationHandler handler)
This is called by the AuthCommand when a session is successfully authenticated.
|
void |
setDeclaredMessageSize(int declaredMessageSize) |
void |
setHasMailFrom(boolean value) |
void |
setHelo(java.lang.String value) |
void |
setSocket(java.net.Socket socket)
Initializes our reader, writer, and the i/o filter chains based on
the specified socket.
|
void |
setTlsPeerCertificates(java.security.cert.Certificate[] tlsPeerCertificates) |
void |
setTlsStarted(boolean tlsStarted) |
void |
startMailTransaction() |
public Session(SMTPServer server, org.subethamail.smtp.server.ServerThread serverThread, java.net.Socket socket) throws java.io.IOException
server
- a link to our parentsocket
- is the socket to the clientjava.io.IOException
public SMTPServer getServer()
public void run()
run
in interface java.lang.Runnable
public void setSocket(java.net.Socket socket) throws java.io.IOException
java.io.IOException
public java.net.Socket getSocket()
public void closeSocket() throws java.io.IOException
java.io.IOException
public java.io.InputStream getRawInput()
public CRLFTerminatedReader getReader()
public void sendResponse(java.lang.String response) throws java.io.IOException
java.io.IOException
public java.lang.String getSessionId()
public java.net.InetSocketAddress getRemoteAddress()
getRemoteAddress
in interface MessageContext
public SMTPServer getSMTPServer()
getSMTPServer
in interface MessageContext
public MessageHandler getMessageHandler()
public java.lang.String getHelo()
getHelo
in interface MessageContext
public void setHelo(java.lang.String value)
public boolean getHasMailFrom()
public void setHasMailFrom(boolean value)
public void addRecipient(java.lang.String recipientAddress)
public int getRecipientCount()
public java.lang.String getSingleRecipient()
public boolean isAuthenticated()
public AuthenticationHandler getAuthenticationHandler()
getAuthenticationHandler
in interface MessageContext
public void setAuthenticationHandler(AuthenticationHandler handler)
public int getDeclaredMessageSize()
public void setDeclaredMessageSize(int declaredMessageSize)
declaredMessageSize
- the size that the client says the message will bepublic void resetSmtpProtocol()
public void resetMessageState()
public void startMailTransaction()
protected void endMessageHandler()
public void quit()
public boolean isTLSStarted()
public void setTlsStarted(boolean tlsStarted)
tlsStarted
- true when the TLS handshake was completed, false otherwisepublic void setTlsPeerCertificates(java.security.cert.Certificate[] tlsPeerCertificates)
public java.security.cert.Certificate[] getTlsPeerCertificates()
SSLSession.getPeerCertificates()
.
In order to get this information, override SMTPServer.createSSLSocket(java.net.Socket)
and call
setNeedClientAuth(true)
on the created socket.getTlsPeerCertificates
in interface MessageContext
SSLSession.getPeerCertificates()
Copyright © 2006–2013. All rights reserved.