rev 280 - in offlineimap/head: debian offlineimap

[email protected] Mon, 4 Nov 2002 12:38:39 -0500 (EST)
Newsgroups gmane.mail.imap.offlineimap.subversion
Message-ID <[email protected]>
Author: jgoerzen
Date: 2002-11-04 12:38:39 -0500 (Mon, 04 Nov 2002)
New Revision: 280

Modified:
   offlineimap/head/debian/changelog
   offlineimap/head/offlineimap/imapserver.py
Log:
  * Falls back to plain-text auth if CRAM-MD5 fails.  Fixes [complete.org #42]



Modified: offlineimap/head/debian/changelog
==============================================================================
--- offlineimap/head/debian/changelog	(original)
+++ offlineimap/head/debian/changelog	Mon Nov  4 12:38:39 2002
@@ -3,6 +3,7 @@
   * Moved password promting into imapserver.py.  Passwords are now asked
     for on-demand and typos will no longer crash the program (the user
     will be re-prompted).  Closes: #162672.
+  * Falls back to plain-text auth if CRAM-MD5 fails.  Fixes [complete.org #42]
 
  -- John Goerzen <[email protected]>  Mon,  4 Nov 2002 11:16:11 -0600
 

Modified: offlineimap/head/offlineimap/imapserver.py
==============================================================================
--- offlineimap/head/offlineimap/imapserver.py	(original)
+++ offlineimap/head/offlineimap/imapserver.py	Mon Nov  4 12:38:39 2002
@@ -115,6 +115,12 @@
                      reply.hexdigest()
         return retval
 
+    def plainauth(self, imapobj):
+        UIBase.getglobalui().debug('imap',
+                                   'Attempting plain authentication')
+        imapobj.login(self.username, self.getpassword())
+        
+
     def acquireconnection(self):
         """Fetches a connection from the pool, making sure to create a new one
         if needed, to obey the maximum connection limits, etc.
@@ -164,11 +170,12 @@
                     if 'AUTH=CRAM-MD5' in imapobj.capabilities:
                         UIBase.getglobalui().debug('imap',
                                                    'Attempting CRAM-MD5 authentication')
-                        imapobj.authenticate('CRAM-MD5', self.md5handler)
+                        try:
+                            imapobj.authenticate('CRAM-MD5', self.md5handler)
+                        except imapobj.error, val:
+                            self.plainauth(imapobj)
                     else:
-                        UIBase.getglobalui().debug('imap',
-                                                   'Attempting plain authentication')
-                        imapobj.login(self.username, self.getpassword())
+                        self.plainauth(imapobj)
                     # Would bail by here if there was a failure.
                     success = 1
                 except imapobj.error, val: