public class IMAPProtocol extends Protocol
notifyResponseHandlers(r).| Modifier and Type | Field and Description |
|---|---|
protected java.util.Set<java.lang.String> |
enabled |
protected java.lang.String[] |
searchCharsets |
protected SearchSequence |
searchSequence |
| Constructor and Description |
|---|
IMAPProtocol(java.lang.String name,
java.lang.String host,
int port,
java.util.Properties props,
boolean isSSL,
MailLogger logger)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(java.lang.String mbox,
Flags f,
java.util.Date d,
Literal data)
APPEND Command.
|
AppendUID |
appenduid(java.lang.String mbox,
Flags f,
java.util.Date d,
Literal data)
APPEND Command, return uid from APPENDUID response code.
|
AppendUID |
appenduid(java.lang.String mbox,
Flags f,
java.util.Date d,
Literal data,
boolean uid) |
void |
authlogin(java.lang.String u,
java.lang.String p)
The AUTHENTICATE command with AUTH=LOGIN authenticate scheme
|
void |
authntlm(java.lang.String authzid,
java.lang.String u,
java.lang.String p)
The AUTHENTICATE command with AUTH=NTLM authentication scheme.
|
void |
authplain(java.lang.String authzid,
java.lang.String u,
java.lang.String p)
The AUTHENTICATE command with AUTH=PLAIN authentication scheme.
|
void |
capability()
CAPABILITY command.
|
void |
check()
CHECK Command.
|
void |
close()
CLOSE Command.
|
void |
copy(int start,
int end,
java.lang.String mbox) |
void |
copy(MessageSet[] msgsets,
java.lang.String mbox)
COPY command.
|
CopyUID |
copyuid(int start,
int end,
java.lang.String mbox) |
CopyUID |
copyuid(MessageSet[] msgsets,
java.lang.String mbox)
COPY Command, return uid from COPYUID response code.
|
CopyUID |
copyuid(java.lang.String msgSequence,
java.lang.String mbox,
boolean uid) |
void |
create(java.lang.String mbox)
CREATE Command.
|
void |
delete(java.lang.String mbox)
DELETE Command.
|
void |
deleteACL(java.lang.String mbox,
java.lang.String user)
DELETEACL Command.
|
void |
disconnect()
Close socket connection.
|
protected ListInfo[] |
doList(java.lang.String cmd,
java.lang.String ref,
java.lang.String pat)
Execute the specified LIST-like command (e.g., "LIST" or "LSUB"),
using the reference and pattern.
|
void |
enable(java.lang.String cap)
ENABLE Command.
|
MailboxInfo |
examine(java.lang.String mbox)
EXAMINE Command.
|
MailboxInfo |
examine(java.lang.String mbox,
ResyncData rd)
EXAMINE Command with QRESYNC data.
|
void |
expunge()
EXPUNGE Command.
|
Response[] |
fetch(int start,
int end,
java.lang.String what) |
Response[] |
fetch(int msg,
java.lang.String what) |
Response[] |
fetch(MessageSet[] msgsets,
java.lang.String what) |
BODY |
fetchBody(int msgno,
java.lang.String section)
Fetch given BODY section.
|
protected BODY |
fetchBody(int msgno,
java.lang.String section,
boolean peek) |
BODY |
fetchBody(int msgno,
java.lang.String section,
int start,
int size)
Partial FETCH of given BODY section.
|
protected BODY |
fetchBody(int msgno,
java.lang.String section,
int start,
int size,
boolean peek,
ByteArray ba) |
BODY |
fetchBody(int msgno,
java.lang.String section,
int start,
int size,
ByteArray ba)
Partial FETCH of given BODY section.
|
BODYSTRUCTURE |
fetchBodyStructure(int msgno)
Fetch the BODYSTRUCTURE of the specified message.
|
Flags |
fetchFlags(int msgno)
Fetch the FLAGS for the given message.
|
MODSEQ |
fetchMODSEQ(int msgno)
Fetch the IMAP MODSEQ for the given message.
|
RFC822DATA |
fetchRFC822(int msgno,
java.lang.String what)
Fetch the specified RFC822 Data item.
|
UID |
fetchSequenceNumber(long uid)
Get the sequence number for the given UID.
|
UID[] |
fetchSequenceNumbers(long[] uids)
Get the sequence numbers for UIDs specified in the array.
|
UID[] |
fetchSequenceNumbers(long start,
long end)
Get the sequence numbers for UIDs ranging from start till end.
|
UID |
fetchUID(int msgno)
Fetch the IMAP UID for the given message.
|
ACL[] |
getACL(java.lang.String mbox)
GETACL Command.
|
java.util.Map |
getCapabilities()
Return the map of capabilities returned by the server.
|
FetchItem[] |
getFetchItems()
Return an array of FetchItem objects describing the
FETCH items supported by this protocol.
|
java.lang.String |
getProxyAuthUser()
Get the user name used with the PROXYAUTH command.
|
Quota[] |
getQuota(java.lang.String root)
GETQUOTA Command.
|
Quota[] |
getQuotaRoot(java.lang.String mbox)
GETQUOTAROOT Command.
|
protected ByteArray |
getResponseBuffer()
Return a buffer to read a response into.
|
protected SearchSequence |
getSearchSequence()
Get the SearchSequence object.
|
boolean |
hasCapability(java.lang.String c)
Check whether the given capability is supported by
this server.
|
java.util.Map<java.lang.String,java.lang.String> |
id(java.util.Map<java.lang.String,java.lang.String> clientParams)
ID Command.
|
void |
id(java.lang.String guid)
Deprecated.
As of JavaMail 1.5.1, replaced by
#id(Map |
void |
idleAbort()
Abort an IDLE command.
|
void |
idleStart()
IDLE Command.
|
boolean |
isAuthenticated()
Returns
true if the connection has been authenticated,
either due to a successful login, or due to a PREAUTH greeting response. |
boolean |
isEnabled(java.lang.String cap)
Is the capability/extension enabled?
|
boolean |
isREV1()
Returns
true if this is a IMAP4rev1 server |
ListInfo[] |
list(java.lang.String ref,
java.lang.String pattern)
LIST Command.
|
Rights[] |
listRights(java.lang.String mbox,
java.lang.String user)
LISTRIGHTS Command.
|
void |
login(java.lang.String u,
java.lang.String p)
LOGIN Command.
|
void |
logout()
LOGOUT Command.
|
ListInfo[] |
lsub(java.lang.String ref,
java.lang.String pattern)
LSUB Command.
|
Rights |
myRights(java.lang.String mbox)
MYRIGHTS Command.
|
Namespaces |
namespace()
NAMESPACE Command.
|
void |
noop()
The NOOP command.
|
protected void |
parseCapabilities(Response r)
Parse the capabilities from a CAPABILITY response or from
a CAPABILITY response code attached to (e.g.) an OK response.
|
BODY |
peekBody(int msgno,
java.lang.String section)
Fetch given BODY section, without marking the message
as SEEN.
|
BODY |
peekBody(int msgno,
java.lang.String section,
int start,
int size)
Partial FETCH of given BODY section, without setting SEEN flag.
|
BODY |
peekBody(int msgno,
java.lang.String section,
int start,
int size,
ByteArray ba)
Partial FETCH of given BODY section, without setting SEEN flag.
|
protected void |
processGreeting(Response r)
Check the greeting when first connecting; look for PREAUTH response.
|
boolean |
processIdleResponse(Response r)
Process a response returned by readIdleResponse().
|
void |
proxyauth(java.lang.String u)
PROXYAUTH Command.
|
Response |
readIdleResponse()
While an IDLE command is in progress, read a response
sent from the server.
|
Response |
readResponse()
Read a response from the server.
|
void |
rename(java.lang.String o,
java.lang.String n)
RENAME Command.
|
void |
sasllogin(java.lang.String[] allowed,
java.lang.String realm,
java.lang.String authzid,
java.lang.String u,
java.lang.String p)
SASL-based login.
|
int[] |
search(MessageSet[] msgsets,
SearchTerm term)
Issue the given search criterion on the specified message sets.
|
int[] |
search(SearchTerm term)
Issue the given search criterion on all messages in this folder.
|
MailboxInfo |
select(java.lang.String mbox)
SELECT Command.
|
MailboxInfo |
select(java.lang.String mbox,
ResyncData rd)
SELECT Command with QRESYNC data.
|
void |
setACL(java.lang.String mbox,
char modifier,
ACL acl)
SETACL Command.
|
protected void |
setCapabilities(Response r)
If the response contains a CAPABILITY response code, extract
it and save the capabilities.
|
void |
setQuota(Quota quota)
SETQUOTA Command.
|
int[] |
sort(SortTerm[] term,
SearchTerm sterm)
Sort messages in the folder according to the specified sort criteria.
|
void |
startTLS()
STARTTLS Command.
|
Status |
status(java.lang.String mbox,
java.lang.String[] items)
STATUS Command.
|
void |
storeFlags(int msg,
Flags flags,
boolean set)
Set the specified flags on this message.
|
void |
storeFlags(int start,
int end,
Flags flags,
boolean set) |
void |
storeFlags(MessageSet[] msgsets,
Flags flags,
boolean set) |
void |
subscribe(java.lang.String mbox)
SUBSCRIBE Command.
|
protected boolean |
supportsNonSyncLiterals()
Returns whether this Protocol supports non-synchronizing literals.
|
void |
uidexpunge(UIDSet[] set)
UID EXPUNGE Command.
|
int[] |
uidfetchChangedSince(long start,
long end,
long modseq)
Get the sequence numbers for messages changed since the given
modseq and with UIDs ranging from start till end.
|
void |
unauthenticate()
UNAUTHENTICATE Command.
|
void |
unselect()
UNSELECT Command.
|
void |
unsubscribe(java.lang.String mbox)
UNSUBSCRIBE Command.
|
addResponseHandler, command, finalize, getInputStream, getLocalHost, getOutputStream, getTimestamp, handleResult, isSSL, isTracing, notifyResponseHandlers, removeResponseHandler, resumeTracing, simpleCommand, startTLS, suspendTracing, writeCommandprotected SearchSequence searchSequence
protected java.lang.String[] searchCharsets
protected java.util.Set<java.lang.String> enabled
public IMAPProtocol(java.lang.String name,
java.lang.String host,
int port,
java.util.Properties props,
boolean isSSL,
MailLogger logger)
throws java.io.IOException,
ProtocolException
host - host to connect toport - portnumber to connect todebug - debug modeprops - Properties object used by this protocoljava.io.IOExceptionProtocolExceptionpublic FetchItem[] getFetchItems()
public void capability()
throws ProtocolException
ProtocolExceptionprotected void setCapabilities(Response r)
protected void parseCapabilities(Response r)
protected void processGreeting(Response r) throws ProtocolException
processGreeting in class ProtocolProtocolExceptionpublic boolean isAuthenticated()
true if the connection has been authenticated,
either due to a successful login, or due to a PREAUTH greeting response.public boolean isREV1()
true if this is a IMAP4rev1 serverprotected boolean supportsNonSyncLiterals()
supportsNonSyncLiterals in class Protocolpublic Response readResponse() throws java.io.IOException, ProtocolException
readResponse in class Protocoljava.io.IOExceptionProtocolExceptionpublic boolean hasCapability(java.lang.String c)
true if so, otherwise
returns false.public java.util.Map getCapabilities()
public void disconnect()
disconnect in class Protocolpublic void noop()
throws ProtocolException
ProtocolExceptionpublic void logout()
throws ProtocolException
ProtocolExceptionpublic void login(java.lang.String u,
java.lang.String p)
throws ProtocolException
ProtocolExceptionpublic void authlogin(java.lang.String u,
java.lang.String p)
throws ProtocolException
ProtocolExceptionpublic void authplain(java.lang.String authzid,
java.lang.String u,
java.lang.String p)
throws ProtocolException
authlogin(java.lang.String, java.lang.String) method.authzid - the authorization idu - the usernamep - the passwordProtocolException - as thrown by Protocol.handleResult(com.sun.mail.iap.Response).public void authntlm(java.lang.String authzid,
java.lang.String u,
java.lang.String p)
throws ProtocolException
authlogin(java.lang.String, java.lang.String) method.authzid - the authorization idu - the usernamep - the passwordProtocolException - as thrown by Protocol.handleResult(com.sun.mail.iap.Response).public void sasllogin(java.lang.String[] allowed,
java.lang.String realm,
java.lang.String authzid,
java.lang.String u,
java.lang.String p)
throws ProtocolException
ProtocolExceptionpublic void proxyauth(java.lang.String u)
throws ProtocolException
ProtocolExceptionpublic java.lang.String getProxyAuthUser()
public void unauthenticate()
throws ProtocolException
ProtocolExceptionpublic void id(java.lang.String guid)
throws ProtocolException
#id(Map) ProtocolExceptionpublic void startTLS()
throws ProtocolException
ProtocolExceptionpublic MailboxInfo select(java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic MailboxInfo select(java.lang.String mbox, ResyncData rd) throws ProtocolException
ProtocolExceptionpublic MailboxInfo examine(java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic MailboxInfo examine(java.lang.String mbox, ResyncData rd) throws ProtocolException
ProtocolExceptionpublic void enable(java.lang.String cap)
throws ProtocolException
ProtocolExceptionpublic boolean isEnabled(java.lang.String cap)
public void unselect()
throws ProtocolException
ProtocolExceptionpublic Status status(java.lang.String mbox, java.lang.String[] items) throws ProtocolException
ProtocolExceptionpublic void create(java.lang.String mbox)
throws ProtocolException
ProtocolExceptionpublic void delete(java.lang.String mbox)
throws ProtocolException
ProtocolExceptionpublic void rename(java.lang.String o,
java.lang.String n)
throws ProtocolException
ProtocolExceptionpublic void subscribe(java.lang.String mbox)
throws ProtocolException
ProtocolExceptionpublic void unsubscribe(java.lang.String mbox)
throws ProtocolException
ProtocolExceptionpublic ListInfo[] list(java.lang.String ref, java.lang.String pattern) throws ProtocolException
ProtocolExceptionpublic ListInfo[] lsub(java.lang.String ref, java.lang.String pattern) throws ProtocolException
ProtocolExceptionprotected ListInfo[] doList(java.lang.String cmd, java.lang.String ref, java.lang.String pat) throws ProtocolException
ProtocolExceptionpublic void append(java.lang.String mbox,
Flags f,
java.util.Date d,
Literal data)
throws ProtocolException
ProtocolExceptionpublic AppendUID appenduid(java.lang.String mbox, Flags f, java.util.Date d, Literal data) throws ProtocolException
ProtocolExceptionpublic AppendUID appenduid(java.lang.String mbox, Flags f, java.util.Date d, Literal data, boolean uid) throws ProtocolException
ProtocolExceptionpublic void check()
throws ProtocolException
ProtocolExceptionpublic void close()
throws ProtocolException
ProtocolExceptionpublic void expunge()
throws ProtocolException
ProtocolExceptionpublic void uidexpunge(UIDSet[] set) throws ProtocolException
ProtocolExceptionpublic BODYSTRUCTURE fetchBodyStructure(int msgno) throws ProtocolException
ProtocolExceptionpublic BODY peekBody(int msgno, java.lang.String section) throws ProtocolException
ProtocolExceptionpublic BODY fetchBody(int msgno, java.lang.String section) throws ProtocolException
ProtocolExceptionprotected BODY fetchBody(int msgno, java.lang.String section, boolean peek) throws ProtocolException
ProtocolExceptionpublic BODY peekBody(int msgno, java.lang.String section, int start, int size) throws ProtocolException
ProtocolExceptionpublic BODY fetchBody(int msgno, java.lang.String section, int start, int size) throws ProtocolException
ProtocolExceptionpublic BODY peekBody(int msgno, java.lang.String section, int start, int size, ByteArray ba) throws ProtocolException
ProtocolExceptionpublic BODY fetchBody(int msgno, java.lang.String section, int start, int size, ByteArray ba) throws ProtocolException
ProtocolExceptionprotected BODY fetchBody(int msgno, java.lang.String section, int start, int size, boolean peek, ByteArray ba) throws ProtocolException
ProtocolExceptionprotected ByteArray getResponseBuffer()
getResponseBuffer in class Protocolpublic RFC822DATA fetchRFC822(int msgno, java.lang.String what) throws ProtocolException
null
to fetch the whole message.ProtocolExceptionpublic Flags fetchFlags(int msgno) throws ProtocolException
ProtocolExceptionpublic UID fetchUID(int msgno) throws ProtocolException
ProtocolExceptionpublic MODSEQ fetchMODSEQ(int msgno) throws ProtocolException
ProtocolExceptionpublic UID fetchSequenceNumber(long uid) throws ProtocolException
null is returned.ProtocolExceptionpublic UID[] fetchSequenceNumbers(long start, long end) throws ProtocolException
ProtocolExceptionpublic UID[] fetchSequenceNumbers(long[] uids) throws ProtocolException
ProtocolExceptionpublic int[] uidfetchChangedSince(long start,
long end,
long modseq)
throws ProtocolException
ProtocolExceptionpublic Response[] fetch(MessageSet[] msgsets, java.lang.String what) throws ProtocolException
ProtocolExceptionpublic Response[] fetch(int start, int end, java.lang.String what) throws ProtocolException
ProtocolExceptionpublic Response[] fetch(int msg, java.lang.String what) throws ProtocolException
ProtocolExceptionpublic void copy(MessageSet[] msgsets, java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic void copy(int start,
int end,
java.lang.String mbox)
throws ProtocolException
ProtocolExceptionpublic CopyUID copyuid(MessageSet[] msgsets, java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic CopyUID copyuid(int start, int end, java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic CopyUID copyuid(java.lang.String msgSequence, java.lang.String mbox, boolean uid) throws ProtocolException
ProtocolExceptionpublic void storeFlags(MessageSet[] msgsets, Flags flags, boolean set) throws ProtocolException
ProtocolExceptionpublic void storeFlags(int start,
int end,
Flags flags,
boolean set)
throws ProtocolException
ProtocolExceptionpublic void storeFlags(int msg,
Flags flags,
boolean set)
throws ProtocolException
ProtocolExceptionpublic int[] search(MessageSet[] msgsets, SearchTerm term) throws ProtocolException, SearchException
msgsets - array of MessageSetsterm - SearchTermProtocolExceptionSearchExceptionpublic int[] search(SearchTerm term) throws ProtocolException, SearchException
term - SearchTermProtocolExceptionSearchExceptionprotected SearchSequence getSearchSequence()
public int[] sort(SortTerm[] term, SearchTerm sterm) throws ProtocolException, SearchException
term - sort criteriasterm - SearchTermProtocolExceptionSearchExceptionpublic Namespaces namespace() throws ProtocolException
ProtocolExceptionpublic Quota[] getQuotaRoot(java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic Quota[] getQuota(java.lang.String root) throws ProtocolException
ProtocolExceptionpublic void setQuota(Quota quota) throws ProtocolException
ProtocolExceptionpublic void setACL(java.lang.String mbox,
char modifier,
ACL acl)
throws ProtocolException
ProtocolExceptionpublic void deleteACL(java.lang.String mbox,
java.lang.String user)
throws ProtocolException
ProtocolExceptionpublic ACL[] getACL(java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic Rights[] listRights(java.lang.String mbox, java.lang.String user) throws ProtocolException
ProtocolExceptionpublic Rights myRights(java.lang.String mbox) throws ProtocolException
ProtocolExceptionpublic void idleStart()
throws ProtocolException
If the server supports the IDLE command extension, the IDLE command is issued and this method blocks until a response has been received. Once the first response has been received, the IDLE command is terminated and all responses are collected and handled and this method returns.
Note that while this method is blocked waiting for a response, no other threads may issue any commands to the server that would use this same connection.
ProtocolExceptionpublic Response readIdleResponse()
public boolean processIdleResponse(Response r) throws ProtocolException
ProtocolExceptionpublic void idleAbort()
throws ProtocolException
ProtocolExceptionpublic java.util.Map<java.lang.String,java.lang.String> id(java.util.Map<java.lang.String,java.lang.String> clientParams)
throws ProtocolException
ProtocolExceptionCopyright © 2013 Oracle. All Rights Reserved.