| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class IMAPProtocol extends Protocol
This class extends the iap.Protocol object and implements IMAP
semantics. In general, there is a method corresponding to each
IMAP protocol command. The typical implementation issues the
appropriate protocol command, collects all responses, processes
those responses that are specific to this command and then
dispatches the rest (the unsolicited ones) to the dispatcher
using the notifyResponseHandlers(r)
.
Field Summary |
---|
Fields inherited from class com.sun.mail.iap.Protocol |
---|
debug, host, out, prefix, props, quote |
Constructor Summary | |
---|---|
IMAPProtocol(String name, String host, int port, boolean debug, PrintStream out, Properties props, boolean isSSL) Constructor. |
Method Summary | |
---|---|
void |
APPEND Command. |
AppendUID |
APPEND Command, return uid from APPENDUID response code. |
AppendUID |
|
void |
The AUTHENTICATE command with AUTH=LOGIN authenticate scheme |
void |
The AUTHENTICATE command with AUTH=PLAIN authentication scheme. |
void |
CAPABILITY command. |
void |
check() CHECK Command. |
void |
close() CLOSE Command. |
void |
|
void |
copy(MessageSet[] msgsets, String mbox) COPY command. |
void |
CREATE Command. |
void |
DELETE Command. |
void |
DELETEACL Command. |
void |
Close socket connection. |
MailboxInfo |
EXAMINE Command. |
void |
expunge() EXPUNGE Command. |
Response[] |
|
Response[] |
|
Response[] |
fetch(MessageSet[] msgsets, String what) |
BODY |
Fetch given BODY section. |
protected BODY |
|
BODY |
Partial FETCH of given BODY section. |
protected BODY |
|
BODY |
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. |
RFC822DATA |
fetchRFC822(int msgno, String what) Fetch the specified RFC822 Data item. |
UID |
fetchSequenceNumber(long uid) Get the sequence number for the given UID. |
UID[] |
fetchSequenceNumbers(long start, long end) Get the sequence numbers for UIDs ranging from start till end. |
UID[] |
fetchSequenceNumbers(long[] uids) 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 Command. |
Map |
Return the map of capabilities returned by the server. |
Quota[] |
GETQUOTA Command. |
Quota[] |
getQuotaRoot(String mbox) GETQUOTAROOT Command. |
protected ByteArray |
Return a buffer to read a response into. |
boolean |
Check whether the given capability is supported by this server. |
void |
Abort an IDLE command. |
void |
IDLE Command. |
boolean |
Returns true if the connection has been authenticated,
either due to a successful login, or due to a PREAUTH greeting response.
|
boolean |
isREV1() Returns true if this is a IMAP4rev1 server
|
ListInfo[] |
LIST Command. |
Rights[] |
listRights(String mbox, String user) LISTRIGHTS Command. |
void |
LOGIN Command. |
void |
logout() LOGOUT Command. |
ListInfo[] |
LSUB Command. |
Rights |
MYRIGHTS Command. |
Namespaces |
NAMESPACE Command. |
void |
noop() The NOOP command. |
protected void |
Parse the capabilities from a CAPABILITY response or from a CAPABILITY response code attached to (e.g.) an OK response. |
BODY |
Fetch given BODY section, without marking the message as SEEN. |
BODY |
Partial FETCH of given BODY section, without setting SEEN flag. |
BODY |
Partial FETCH of given BODY section, without setting SEEN flag. |
protected void |
Check the greeting when first connecting; look for PREAUTH response. |
boolean |
Process a response returned by readIdleResponse(). |
void |
PROXYAUTH Command. |
Response |
While an IDLE command is in progress, read a response sent from the server. |
Response |
Read a response from the server. |
void |
RENAME Command. |
void |
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 Command. |
void |
SETACL Command. |
protected void |
If the response contains a CAPABILITY response code, extract it and save the capabilities. |
void |
SETQUOTA Command. |
void |
startTLS() STARTTLS Command. |
Status |
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 Command. |
protected boolean |
Returns whether this Protocol supports non-synchronizing literals. |
void |
uidexpunge(UIDSet[] set) UID EXPUNGE Command. |
void |
unsubscribe(String mbox) UNSUBSCRIBE Command. |
Methods inherited from class com.sun.mail.iap.Protocol |
---|
addResponseHandler, command, disconnect, finalize, getInputStream, getOutputStream, getResponseBuffer, getTimestamp, handleResult, notifyResponseHandlers, processGreeting, readResponse, removeResponseHandler, simpleCommand, startTLS, supportsNonSyncLiterals, writeCommand |
Constructor Detail |
---|
public IMAPProtocol(String name, String host, int port, boolean debug, PrintStream out, Properties props, boolean isSSL) throws IOException, ProtocolException
name
host
- host to connect toport
- portnumber to connect todebug
- debug modeout
props
- Properties object used by this protocolisSSL
IOException
ProtocolException
Method Detail |
---|
public void append(String mbox, Flags f, Date d, Literal data) throws ProtocolException
mbox
f
d
data
ProtocolException
public AppendUID appenduid(String mbox, Flags f, Date d, Literal data) throws ProtocolException
mbox
f
d
data
ProtocolException
public AppendUID appenduid(String mbox, Flags f, Date d, Literal data, boolean uid) throws ProtocolException
mbox
f
d
data
uid
ProtocolException
public synchronized void authlogin(String u, String p) throws ProtocolException
u
p
ProtocolException
public synchronized void authplain(String authzid, String u, String p) throws ProtocolException
authzid
- the authorization idu
- the usernamep
- the passwordProtocolException
- as thrown by {@link Protocol#handleResult}.public void capability() throws ProtocolException
ProtocolException
public void check() throws ProtocolException
ProtocolException
public void close() throws ProtocolException
ProtocolException
public void copy(int start, int end, String mbox) throws ProtocolException
start
end
mbox
ProtocolException
public void copy(MessageSet[] msgsets, String mbox) throws ProtocolException
msgsets
mbox
ProtocolException
public void create(String mbox) throws ProtocolException
mbox
ProtocolException
public void delete(String mbox) throws ProtocolException
mbox
ProtocolException
public void deleteACL(String mbox, String user) throws ProtocolException
mbox
user
ProtocolException
public void disconnect()
disconnect
in class Protocol
public MailboxInfo examine(String mbox) throws ProtocolException
mbox
ProtocolException
public void expunge() throws ProtocolException
ProtocolException
public Response[] fetch(int start, int end, String what) throws ProtocolException
start
end
what
ProtocolException
public Response[] fetch(int msg, String what) throws ProtocolException
msg
what
ProtocolException
public Response[] fetch(MessageSet[] msgsets, String what) throws ProtocolException
msgsets
what
ProtocolException
public BODY fetchBody(int msgno, String section) throws ProtocolException
msgno
section
ProtocolException
protected BODY fetchBody(int msgno, String section, boolean peek) throws ProtocolException
msgno
section
peek
ProtocolException
public BODY fetchBody(int msgno, String section, int start, int size) throws ProtocolException
msgno
section
start
size
ProtocolException
protected BODY fetchBody(int msgno, String section, int start, int size, boolean peek, ByteArray ba) throws ProtocolException
msgno
section
start
size
peek
ba
ProtocolException
public BODY fetchBody(int msgno, String section, int start, int size, ByteArray ba) throws ProtocolException
msgno
section
start
size
ba
ProtocolException
public BODYSTRUCTURE fetchBodyStructure(int msgno) throws ProtocolException
msgno
ProtocolException
public Flags fetchFlags(int msgno) throws ProtocolException
msgno
ProtocolException
public RFC822DATA fetchRFC822(int msgno, String what) throws ProtocolException
null
to fetch the whole message.
msgno
what
ProtocolException
public UID fetchSequenceNumber(long uid) throws ProtocolException
null
is returned.
uid
ProtocolException
public UID[] fetchSequenceNumbers(long start, long end) throws ProtocolException
start
end
ProtocolException
public UID[] fetchSequenceNumbers(long[] uids) throws ProtocolException
uids
ProtocolException
public UID fetchUID(int msgno) throws ProtocolException
msgno
ProtocolException
public ACL[] getACL(String mbox) throws ProtocolException
mbox
ProtocolException
public Map getCapabilities()
public Quota[] getQuota(String root) throws ProtocolException
root
ProtocolException
public Quota[] getQuotaRoot(String mbox) throws ProtocolException
mbox
ProtocolException
protected ByteArray getResponseBuffer()
getResponseBuffer
in class Protocol
public boolean hasCapability(String c)
true
if so, otherwise
returns false.
c
public void idleAbort() throws ProtocolException
ProtocolException
public synchronized 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.
ProtocolException
public 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 server
public ListInfo[] list(String ref, String pattern) throws ProtocolException
ref
pattern
ProtocolException
public Rights[] listRights(String mbox, String user) throws ProtocolException
mbox
user
ProtocolException
public void login(String u, String p) throws ProtocolException
u
p
ProtocolException
public void logout() throws ProtocolException
ProtocolException
public ListInfo[] lsub(String ref, String pattern) throws ProtocolException
ref
pattern
ProtocolException
public Rights myRights(String mbox) throws ProtocolException
mbox
ProtocolException
public Namespaces namespace() throws ProtocolException
ProtocolException
public void noop() throws ProtocolException
ProtocolException
protected void parseCapabilities(Response r)
r
public BODY peekBody(int msgno, String section) throws ProtocolException
msgno
section
ProtocolException
public BODY peekBody(int msgno, String section, int start, int size) throws ProtocolException
msgno
section
start
size
ProtocolException
public BODY peekBody(int msgno, String section, int start, int size, ByteArray ba) throws ProtocolException
msgno
section
start
size
ba
ProtocolException
protected void processGreeting(Response r) throws ProtocolException
processGreeting
in class Protocol
r
ProtocolException
public boolean processIdleResponse(Response r) throws ProtocolException
r
ProtocolException
public void proxyauth(String u) throws ProtocolException
u
ProtocolException
public synchronized Response readIdleResponse()
public Response readResponse() throws IOException, ProtocolException
readResponse
in class Protocol
IOException
ProtocolException
public void rename(String o, String n) throws ProtocolException
o
n
ProtocolException
public void sasllogin(String[] allowed, String realm, String authzid, String u, String p) throws ProtocolException
allowed
realm
authzid
u
p
ProtocolException
public int[] search(MessageSet[] msgsets, SearchTerm term) throws ProtocolException, SearchException
msgsets
- array of MessageSetsterm
- SearchTermProtocolException
SearchException
public int[] search(SearchTerm term) throws ProtocolException, SearchException
term
- SearchTermProtocolException
SearchException
public MailboxInfo select(String mbox) throws ProtocolException
mbox
ProtocolException
public void setACL(String mbox, char modifier, ACL acl) throws ProtocolException
mbox
modifier
acl
ProtocolException
protected void setCapabilities(Response r)
r
public void setQuota(Quota quota) throws ProtocolException
quota
ProtocolException
public void startTLS() throws ProtocolException
ProtocolException
public Status status(String mbox, String[] items) throws ProtocolException
mbox
items
ProtocolException
public void storeFlags(int msg, Flags flags, boolean set) throws ProtocolException
msg
flags
set
ProtocolException
public void storeFlags(int start, int end, Flags flags, boolean set) throws ProtocolException
start
end
flags
set
ProtocolException
public void storeFlags(MessageSet[] msgsets, Flags flags, boolean set) throws ProtocolException
msgsets
flags
set
ProtocolException
public void subscribe(String mbox) throws ProtocolException
mbox
ProtocolException
protected boolean supportsNonSyncLiterals()
supportsNonSyncLiterals
in class Protocol
public void uidexpunge(UIDSet[] set) throws ProtocolException
set
ProtocolException
public void unsubscribe(String mbox) throws ProtocolException
mbox
ProtocolException
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |