Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail
In directory sc8-pr-cvs1:/tmp/cvs-serv21920
Modified Files:
HotmailMailSession.java
Log Message:
Implemented MD5 Hash for UIDL fix
Index: HotmailMailSession.java
===================================================================
RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail/HotmailMailSession.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** HotmailMailSession.java 10 May 2003 04:54:46 -0000 1.26
--- HotmailMailSession.java 28 Jul 2003 11:28:12 -0000 1.27
***************
*** 34,37 ****
--- 34,40 ----
//import com.sonalb.net.http.cookie.Cookie;
+ import gnu.crypto.hash.MD5;
+ import gnu.crypto.util.Util;
+
import org.mrbook.mrpostman.MailSessionException;
import org.mrbook.mrpostman.ModuleInfo;
***************
*** 52,56 ****
Based on 'GotMail' perl script by Peter Hawkins <pet...@oz...>
and the YahooMainSession by Hector Urtubia <ur...@mr...>
! Uses jCookie by Sonal Bansal.
Note: Unfortunately Hotmail send an invalid cookie to us (now there's a surprise)
--- 55,59 ----
Based on 'GotMail' perl script by Peter Hawkins <pet...@oz...>
and the YahooMainSession by Hector Urtubia <ur...@mr...>
! Uses jCookie by Sonal Bansal and MD5 from the GNU Crypto Project.
Note: Unfortunately Hotmail send an invalid cookie to us (now there's a surprise)
***************
*** 299,303 ****
logger.finest(cj.toString());
logger.finest("done");
!
// PATCH login url to use http so we can snoop...
//loginURL = loginURL.substring(0, 4) + loginURL.substring(5);
--- 302,306 ----
logger.finest(cj.toString());
logger.finest("done");
!
// PATCH login url to use http so we can snoop...
//loginURL = loginURL.substring(0, 4) + loginURL.substring(5);
***************
*** 837,840 ****
--- 840,846 ----
* We'll have to calculate our our UIDL for the circular messages :(
*/
+ /*
+ // Removed this pending further investigations, Message-IDs do not always
+ //appear and are not always unique. Replaced with the MD5 function below. - CH 28/7/03
public String getUniqueMessageId(int num) throws MailSessionException {
try {
***************
*** 864,867 ****
--- 870,902 ----
return Integer.toString(header.hashCode());
}
+ } catch (IOException i) {
+ logger.log(Level.SEVERE, "should not happen", i);
+ throw new MailSessionException("IOException whilst attempting to read UIDL for message" + num);
+ }
+ }
+ */
+
+ /**
+ * Return hotmail's UIDL for this message. We can get this by generating the MD5 hash of the message
+ * header fields. Hopefully this is unique!
+ */
+ public String getUniqueMessageId(int num) throws MailSessionException {
+ //This is based on work by Peter Joanes
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(bos, true);
+ retrieveMessage(num, pw, 1);
+ bos.flush();
+ if(logger.isLoggable(Level.FINEST)) {
+ String header = bos.toString();
+ logger.finest("Returning a hashcode of header field: "
+ + header);
+ }
+ byte[] data = bos.toByteArray();
+ MD5 md5 = new MD5();
+ md5.update(data,0,data.length);
+ String hash = Util.toString(md5.digest());
+ logger.finest("Returning hash: " + hash);
+ return hash;
} catch (IOException i) {
logger.log(Level.SEVERE, "should not happen", i);
|