class Protocol
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
apopChallenge |
private java.util.Map<java.lang.String,java.lang.String> |
capabilities |
private static java.lang.String |
CRLF |
private static char[] |
digits |
private java.lang.String |
host |
private java.io.BufferedReader |
input |
private MailLogger |
logger |
private boolean |
noauthdebug |
private java.io.PrintWriter |
output |
private boolean |
pipelining |
private static int |
POP3_PORT |
private java.lang.String |
prefix |
private java.util.Properties |
props |
private static int |
SLOP |
private java.net.Socket |
socket |
private TraceInputStream |
traceInput |
private MailLogger |
traceLogger |
private TraceOutputStream |
traceOutput |
private boolean |
traceSuspended |
Constructor and Description |
---|
Protocol(java.lang.String host,
int port,
MailLogger logger,
java.util.Properties props,
java.lang.String prefix,
boolean isSSL)
Open a connection to the POP3 server.
|
Modifier and Type | Method and Description |
---|---|
private void |
batchCommandContinue(java.lang.String command) |
private void |
batchCommandEnd() |
private void |
batchCommandStart(java.lang.String command) |
(package private) java.io.InputStream |
capa()
Get server capabilities using CAPA command specified by RFC 2449.
|
private static java.io.IOException |
cleanupAndThrow(java.net.Socket socket,
java.io.IOException ife) |
(package private) void |
close()
Close the connection without sending any commands.
|
(package private) boolean |
dele(int msg)
Delete (permanently) the specified message.
|
protected void |
finalize() |
private boolean |
getBoolProp(java.util.Properties props,
java.lang.String prop)
Get the value of a boolean property.
|
(package private) java.util.Map<java.lang.String,java.lang.String> |
getCapabilities()
Return the map of capabilities returned by the server.
|
private java.lang.String |
getDigest(java.lang.String password)
Gets the APOP message digest.
|
(package private) boolean |
hasCapability(java.lang.String c)
Check whether the given capability is supported by
this server.
|
private void |
initStreams() |
private static boolean |
isRecoverable(java.lang.Throwable t) |
(package private) boolean |
isSSL()
Is this connection using SSL?
|
private void |
issueCommand(java.lang.String cmd)
Send the specified command.
|
protected boolean |
isTracing()
Is protocol tracing enabled?
|
(package private) java.io.InputStream |
list()
Return the size of all messages using the LIST command.
|
(package private) int |
list(int msg)
Return the size of the message using the LIST command.
|
(package private) java.lang.String |
login(java.lang.String user,
java.lang.String password)
Login to the server, using the USER and PASS commands.
|
private Response |
multilineCommand(java.lang.String cmd,
int size)
Issue a POP3 command that expects a multi-line response.
|
private void |
multilineCommandEnd() |
private void |
multilineCommandStart(java.lang.String command) |
(package private) boolean |
noop()
Do a NOOP.
|
(package private) boolean |
quit()
Close down the connection, sending the QUIT command.
|
private java.io.InputStream |
readMultilineResponse(int size)
Read the response to a multiline command after the command response.
|
private Response |
readResponse()
Read the response to a command.
|
private void |
resumeTracing()
Resume protocol tracing, if it was enabled to begin with.
|
(package private) java.io.InputStream |
retr(int msg,
int size)
Retrieve the specified message.
|
(package private) boolean |
retr(int msg,
java.io.OutputStream os)
Retrieve the specified message and stream the content to the
specified OutputStream.
|
(package private) boolean |
rset()
Do an RSET.
|
(package private) void |
setCapabilities(java.io.InputStream in)
Parse the capabilities from a CAPA response.
|
private Response |
simpleCommand(java.lang.String cmd)
Issue a simple POP3 command and return the response.
|
private void |
simpleCommandEnd() |
private void |
simpleCommandStart(java.lang.String command) |
(package private) Status |
stat()
Return the total number of messages and mailbox size,
using the STAT command.
|
(package private) boolean |
stls()
Start TLS using STLS command specified by RFC 2595.
|
private void |
suspendTracing()
Temporarily turn off protocol tracing, e.g., to prevent
tracing the authentication sequence, including the password.
|
private static java.lang.String |
toHex(byte[] bytes)
Convert a byte array to a string of hex digits representing the bytes.
|
(package private) java.io.InputStream |
top(int msg,
int n)
Return the message header and the first n lines of the message.
|
(package private) java.lang.String |
uidl(int msg)
Return the UIDL string for the message.
|
(package private) boolean |
uidl(java.lang.String[] uids)
Return the UIDL strings for all messages.
|
private java.net.Socket socket
private java.lang.String host
private java.util.Properties props
private java.lang.String prefix
private java.io.BufferedReader input
private java.io.PrintWriter output
private TraceInputStream traceInput
private TraceOutputStream traceOutput
private MailLogger logger
private MailLogger traceLogger
private java.lang.String apopChallenge
private java.util.Map<java.lang.String,java.lang.String> capabilities
private boolean pipelining
private boolean noauthdebug
private boolean traceSuspended
private static final int POP3_PORT
private static final java.lang.String CRLF
private static final int SLOP
private static char[] digits
Protocol(java.lang.String host, int port, MailLogger logger, java.util.Properties props, java.lang.String prefix, boolean isSSL) throws java.io.IOException
java.io.IOException
private static java.io.IOException cleanupAndThrow(java.net.Socket socket, java.io.IOException ife)
private static boolean isRecoverable(java.lang.Throwable t)
private final boolean getBoolProp(java.util.Properties props, java.lang.String prop)
private void initStreams() throws java.io.IOException
java.io.IOException
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
void setCapabilities(java.io.InputStream in)
boolean hasCapability(java.lang.String c)
true
if so, otherwise
returns false.java.util.Map<java.lang.String,java.lang.String> getCapabilities()
java.lang.String login(java.lang.String user, java.lang.String password) throws java.io.IOException
java.io.IOException
private java.lang.String getDigest(java.lang.String password)
password
- The APOP passwordprivate static java.lang.String toHex(byte[] bytes)
boolean quit() throws java.io.IOException
java.io.IOException
void close()
Status stat() throws java.io.IOException
java.io.IOException
int list(int msg) throws java.io.IOException
java.io.IOException
java.io.InputStream list() throws java.io.IOException
java.io.IOException
java.io.InputStream retr(int msg, int size) throws java.io.IOException
java.io.IOException
boolean retr(int msg, java.io.OutputStream os) throws java.io.IOException
java.io.IOException
java.io.InputStream top(int msg, int n) throws java.io.IOException
java.io.IOException
boolean dele(int msg) throws java.io.IOException
java.io.IOException
java.lang.String uidl(int msg) throws java.io.IOException
java.io.IOException
boolean uidl(java.lang.String[] uids) throws java.io.IOException
java.io.IOException
boolean noop() throws java.io.IOException
java.io.IOException
boolean rset() throws java.io.IOException
java.io.IOException
boolean stls() throws java.io.IOException
java.io.IOException
boolean isSSL()
java.io.InputStream capa() throws java.io.IOException
java.io.IOException
private Response simpleCommand(java.lang.String cmd) throws java.io.IOException
java.io.IOException
private void issueCommand(java.lang.String cmd) throws java.io.IOException
java.io.IOException
private Response readResponse() throws java.io.IOException
java.io.IOException
private Response multilineCommand(java.lang.String cmd, int size) throws java.io.IOException
size
is an estimate of the response size.java.io.IOException
private java.io.InputStream readMultilineResponse(int size) throws java.io.IOException
java.io.IOException
protected boolean isTracing()
private void suspendTracing()
private void resumeTracing()
private void simpleCommandStart(java.lang.String command)
private void simpleCommandEnd()
private void multilineCommandStart(java.lang.String command)
private void multilineCommandEnd()
private void batchCommandStart(java.lang.String command)
private void batchCommandContinue(java.lang.String command)
private void batchCommandEnd()