public class Protocol
extends java.lang.Object
The Protocol object is multithread safe.
Constructor and Description |
---|
Protocol(java.io.InputStream in,
java.io.PrintStream out,
java.util.Properties props,
boolean debug)
Constructor for debugging.
|
Protocol(java.lang.String host,
int port,
java.util.Properties props,
java.lang.String prefix,
boolean isSSL,
MailLogger logger)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addResponseHandler(ResponseHandler h)
Adds a response handler.
|
Response[] |
command(java.lang.String command,
Argument args)
Send a command to the server.
|
java.nio.channels.SocketChannel |
getChannel()
Return the SocketChannel associated with this connection, if any.
|
java.net.InetAddress |
getInetAddress()
Return the address the socket connected to.
|
long |
getTimestamp()
Returns the timestamp.
|
void |
handleResult(Response response)
Convenience routine to handle OK, NO, BAD and BYE responses.
|
boolean |
hasResponse()
Is another response available in our buffer?
|
boolean |
isSSL()
Is this connection using an SSL socket?
|
void |
notifyResponseHandlers(Response[] responses)
Notify response handlers
|
Response |
readResponse() |
void |
removeResponseHandler(ResponseHandler h)
Removed the specified response handler.
|
void |
simpleCommand(java.lang.String cmd,
Argument args)
Convenience routine to handle simple IAP commands
that do not have responses specific to that command.
|
void |
startCompression(java.lang.String cmd)
Start compression on the current connection.
|
void |
startTLS(java.lang.String cmd)
Start TLS on the current connection.
|
boolean |
supportsUtf8()
Does the server support UTF-8?
This implementation returns false.
|
java.lang.String |
writeCommand(java.lang.String command,
Argument args) |
public Protocol(java.lang.String host, int port, java.util.Properties props, java.lang.String prefix, boolean isSSL, MailLogger logger) throws java.io.IOException, ProtocolException
Opens a connection to the given host at given port.
host
- host to connect toport
- portnumber to connect toprops
- Properties object used by this protocolprefix
- Prefix to prepend to property keysisSSL
- use SSL?logger
- log messages herejava.io.IOException
- for I/O errorsProtocolException
- for protocol failurespublic Protocol(java.io.InputStream in, java.io.PrintStream out, java.util.Properties props, boolean debug) throws java.io.IOException
in
- the InputStream to read fromout
- the PrintStream to write toprops
- Properties object used by this protocoldebug
- true to enable debugging outputjava.io.IOException
- for I/O errorspublic long getTimestamp()
public void addResponseHandler(ResponseHandler h)
h
- the response handlerpublic void removeResponseHandler(ResponseHandler h)
h
- the response handlerpublic void notifyResponseHandlers(Response[] responses)
responses
- the responsespublic Response readResponse() throws java.io.IOException, ProtocolException
java.io.IOException
ProtocolException
public boolean hasResponse()
public java.lang.String writeCommand(java.lang.String command, Argument args) throws java.io.IOException, ProtocolException
java.io.IOException
ProtocolException
public Response[] command(java.lang.String command, Argument args)
command
- the commandargs
- the argumentspublic void handleResult(Response response) throws ProtocolException
response
- the responseProtocolException
- for protocol failurespublic void simpleCommand(java.lang.String cmd, Argument args) throws ProtocolException
cmd
- the commandargs
- the argumentsProtocolException
- for protocol failurespublic void startTLS(java.lang.String cmd) throws java.io.IOException, ProtocolException
cmd
is the command to issue to start TLS negotiation.
If the command succeeds, we begin TLS negotiation.
If the socket is already an SSLSocket this is a nop and the command
is not issued.cmd
- the command to issuejava.io.IOException
- for I/O errorsProtocolException
- for protocol failurespublic void startCompression(java.lang.String cmd) throws java.io.IOException, ProtocolException
cmd
is the command to issue to start compression.
If the command succeeds, we begin compression.cmd
- the command to issuejava.io.IOException
- for I/O errorsProtocolException
- for protocol failurespublic boolean isSSL()
public java.net.InetAddress getInetAddress()
public java.nio.channels.SocketChannel getChannel()
public boolean supportsUtf8()
Copyright © 2010 - 2020 Adobe. All Rights Reserved