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,
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.
|
long |
getTimestamp()
Returns the timestamp.
|
void |
handleResult(Response response)
Convenience routine to handle OK, NO, BAD and BYE responses.
|
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 |
startTLS(java.lang.String cmd)
Start TLS on the current connection.
|
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
ProtocolException
public Protocol(java.io.InputStream in, java.io.PrintStream out, boolean debug) throws java.io.IOException
java.io.IOException
public long getTimestamp()
public void addResponseHandler(ResponseHandler h)
public void removeResponseHandler(ResponseHandler h)
public void notifyResponseHandlers(Response[] responses)
public Response readResponse() throws java.io.IOException, ProtocolException
java.io.IOException
ProtocolException
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
ProtocolException
public void simpleCommand(java.lang.String cmd, Argument args) throws ProtocolException
ProtocolException
public 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.java.io.IOException
ProtocolException
public boolean isSSL()
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"