JavaMail: Passing specific command before login in IMAP

  4 posts   Feedicon  
Replies: 3 - Last Post: March 30, 2011 20:59
by: shannon
showing 1 - 4 of 4
 
Posted: March 29, 2011 16:17 by frerf
I have searched into JavaMail for a way to call a specific command before the LOGIN command in IMAP. But, it seams to me that the IMAP protocol doesn't allow such treatments...
On the call IMAPStore.connect(), the command LOGIN or AUTHENT PLAIN is launched, and after that we can get the default folder (or another) which allow passing specific command via the method doProtocolCommand().
But there isn't any method to do the same thing on the IMAPStore.

Does I missed something ? Is there any way to proceed ?
 
Posted: March 29, 2011 22:23 by shannon
You're right, there's no convenient way to do this.
There has been very little demand for this.

The solution I provided for the one other person who asked for this depends
on subclassing the existing IMAP provider classes. If you're willing to consider
that approach, you'll find a preLogin method on IMAPStore, and you can override
that method to do what you need.

Let me know if you want more guidance on how to do this.

BTW, what server are you using and what special command do you need to
execute before login?
 
Posted: March 30, 2011 08:52 by frerf
Thank you for this response... If I correctly undestood what you say, I have to subclass both the IMAPProvider classe and the IMAPStore classe ? Or only the IMAPStore ?
I have already watched on this way to do, but my JavaMail version is 1.4.1 and I don't have the preLogin() method defined. But, an upgrade to 1.4.4 may be examined.
Also, in the 1.4.4 Javadoc, I see "Note that if the connection is pre-authenticated, this method won't be called." : Does that meen that if I use a plain authentication, the preLogin() method will not be called ? If so, this way to do may not be the good way for me Frown
Maybe could I ovveride IMAPStore and create and explicitly call my own method ? But I'm not sure on the good way to retrieve an IMAPProtocol instance into subclass (the getStoreProtocol() method has "friendly" visibility in my version)... Frown

The server I used is a internally modified version of Cyrus (not modified by me).
And the command is used for adding specific item into the cyrus log during session.
 
Posted: March 30, 2011 20:59 by shannon
You should only need to subclass IMAPStore. You'll also need a javamail.providers file
to define a new "myimap" protocol and configure it to use your subclass. More details
are in the JavaMail Service Providers Guide.

Yes, you'll need 1.4.4.

A pre-authenticated connection is relatively rare in practice, and is unrelated
to plain authentication.
Replies: 3 - Last Post: March 30, 2011 20:59
by: shannon
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close