From c605a4dcada0082285620e52cb105ecc0d0506aa Mon Sep 17 00:00:00 2001 From: okada Date: Mon, 20 Nov 2000 00:07:02 +0000 Subject: [PATCH] rewrite elmo-imap4.el, elmo-pop3.el --- ChangeLog | 7 +++ elmo/elmo-imap4.el | 78 +++++++----------------- elmo/elmo-pop3.el | 166 ++++++++++++++++------------------------------------ 3 files changed, 80 insertions(+), 171 deletions(-) diff --git a/ChangeLog b/ChangeLog index 503c167..56df04e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-11-20 Kenichi OKADA + + * utils/sasl/sasl.el: sync up to flim-1_14. + * utils/sasl/sasl-cram.el: New file. + * utils/sasl/sasl-digest.el: New file. + * utils/sasl/digest-md5.el: Delete. + 2000-10-31 Tetsuo Tsukamoto * WL-MK: Require "backquote" before dealing with the custom issue. diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index e027e89..a3a130a 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -1152,22 +1152,6 @@ If optional argument UNMARK is non-nil, unmark." (elmo-get-passwd (elmo-network-session-password-key session)))))) (signal 'elmo-authenticate-error '(login))))) -;;; dirty hack -;;;(defconst sasl-imap4-login-steps -;;; '(sasl-imap4-login-response)) -;;; -;;;(defun sasl-imap4-login-response (client step) -;;; (concat -;;; (sasl-client-name client) -;;; " " -;;; (sasl-read-passphrase -;;; (format "LOGIN passphrase for %s: " (sasl-client-name client))))) -;;; -;;;(put 'sasl-imap4-login 'sasl-mechanism -;;; (sasl-make-mechanism "IMAP4-LOGIN" sasl-imap4-login-steps)) -;;; -;;;(provide 'sasl-imap4-login) - (luna-define-method elmo-network-initialize-session-buffer :after ((session elmo-imap4-session) buffer) @@ -1216,42 +1200,29 @@ If optional argument UNMARK is non-nil, unmark." (with-current-buffer (process-buffer (elmo-network-session-process-internal session)) (let* ((auth (elmo-network-session-auth-internal session)) -; (auth (mapcar '(lambda (a) -; (if (eq a 'plain) -; 'imap4-login -; a)) -; (if (listp auth) auth (list auth))))) (auth (if (listp auth) auth (list auth)))) (unless (or (eq elmo-imap4-status 'auth) (null auth)) (if (eq 'plain (car auth)) (elmo-imap4-login session) (let* ((elmo-imap4-debug-inhibit-logging t) -; (sasl-mechanism-alist -; (append -; sasl-mechanism-alist -; (list '("IMAP4-LOGIN" sasl-imap4-login)))) - (sasl-mechanisms -; (append - (delq nil - (mapcar '(lambda (cap) - (if (string-match "^auth=\\(.*\\)$" - (symbol-name cap)) - (match-string 1 (upcase (symbol-name cap))))) - (elmo-imap4-session-capability-internal session)))) -; (list "IMAP4-LOGIN"))) - (mechanism -; (if (eq auth 'any) -; (sasl-find-mechanism sasl-mechanisms) + (sasl-mechanisms + (delq nil + (mapcar '(lambda (cap) + (if (string-match "^auth=\\(.*\\)$" + (symbol-name cap)) + (match-string 1 (upcase (symbol-name cap))))) + (elmo-imap4-session-capability-internal session)))) + (mechanism (sasl-find-mechanism (delq nil (mapcar '(lambda (cap) (upcase (symbol-name cap))) (if (listp auth) auth - (list auth))))));) - client name step response tag - sasl-read-passphrase) - (unless mechanism + (list auth)))))) ;) + client name step response tag + sasl-read-passphrase) + (unless mechanism (if (or elmo-imap4-force-login (y-or-n-p (format @@ -1278,21 +1249,16 @@ If optional argument UNMARK is non-nil, unmark." (lambda (prompt) (elmo-get-passwd (elmo-network-session-password-key session))))) -; (if (string= name "IMAP4-LOGIN") -; (setq tag -; (elmo-imap4-send-command -; session -; (concat "LOGIN " (sasl-step-data step)))) - (setq tag - (elmo-imap4-send-command - session - (concat "AUTHENTICATE " name - (and (sasl-step-data step) - (concat - " " - (elmo-base64-encode-string - (sasl-step-data step) - 'no-lin-break))))));) + (setq tag + (elmo-imap4-send-command + session + (concat "AUTHENTICATE " name + (and (sasl-step-data step) + (concat + " " + (elmo-base64-encode-string + (sasl-step-data step) + 'no-lin-break)))))) ;) (catch 'done (while t (setq response (elmo-imap4-read-untagged diff --git a/elmo/elmo-pop3.el b/elmo/elmo-pop3.el index 1c0bee6..18328aa 100644 --- a/elmo/elmo-pop3.el +++ b/elmo/elmo-pop3.el @@ -195,46 +195,6 @@ '(elmo-pop3-auth-apop)))) (signal 'elmo-open-error '(elmo-pop-auth-apop)))) -;;; dirty hack -;;;(defconst sasl-pop3-user-steps -;;; '(ignore -;;; sasl-pop3-user-response-1 -;;; sasl-pop3-user-response-2)) -;;; -;;;(defun sasl-pop3-user-response-1 (client step) -;;; (sasl-client-name client)) -;;; -;;;(defun sasl-pop3-user-response-2 (client step) -;;; (format "PASS %s" -;;; (sasl-read-passphrase -;;; (format "LOGIN passphrase for %s: " -;;; (sasl-client-name client))))) -;;; -;;;(put 'sasl-pop3-user 'sasl-mechanism -;;; (sasl-make-mechanism "USER" sasl-pop3-user-steps)) -;;; -;;;(provide 'sasl-pop3-user) -;;; -;;;(defconst sasl-pop3-apop-steps -;;; '(ignore -;;; sasl-pop3-apop-response)) -;;; -;;;(defun sasl-pop3-apop-response (client step) -;;; (require 'md5) -;;; (format "%s %s" -;;; (sasl-client-name client) -;;; (md5 -;;; (concat -;;; (sasl-step-data step) -;;; (sasl-read-passphrase -;;; (format "LOGIN passphrase for %s: " -;;; (sasl-client-name client))))))) -;;; -;;;(put 'sasl-pop3-apop 'sasl-mechanism -;;; (sasl-make-mechanism "APOP" sasl-pop3-apop-steps)) -;;; -;;;(provide 'sasl-pop3-apop) - (luna-define-method elmo-network-initialize-session-buffer :after ((session elmo-pop3-session) buffer) (with-current-buffer buffer @@ -270,13 +230,6 @@ (auth (elmo-network-session-auth-internal session)) (auth (mapcar '(lambda (mechanism) (upcase (symbol-name mechanism))) (if (listp auth) auth (list auth)))) -;;; (sasl-mechanism-alist -;;; (append -;;; sasl-mechanism-alist -;;; (list '("USER" sasl-pop3-user) -;;; '("APOP" sasl-pop3-apop)))) -;;; (sasl-mechanisms -;;; (append sasl-mechanisms (list "USER" "APOP"))) client name step response mechanism sasl-read-passphrase) (or (and (string= "USER" (car auth)) @@ -284,76 +237,59 @@ (and (string= "APOP" (car auth)) (elmo-pop3-auth-apop session)) (progn - (setq mechanism (sasl-find-mechanism auth)) - (unless mechanism - (signal 'elmo-authenticate-error '(elmo-pop3-auth-no-mechanisms))) - (setq client - (sasl-make-client - mechanism - (elmo-network-session-user-internal session) - "pop" - (elmo-network-session-host-internal session))) + (setq mechanism (sasl-find-mechanism auth)) + (unless mechanism + (signal 'elmo-authenticate-error '(elmo-pop3-auth-no-mechanisms))) + (setq client + (sasl-make-client + mechanism + (elmo-network-session-user-internal session) + "pop" + (elmo-network-session-host-internal session))) ;;; (if elmo-pop3-auth-user-realm ;;; (sasl-client-set-property client 'realm elmo-pop3-auth-user-realm)) - (setq name (sasl-mechanism-name mechanism)) - (elmo-network-session-set-auth-internal session - (intern (downcase name))) - (setq sasl-read-passphrase - (function - (lambda (prompt) - (elmo-get-passwd - (elmo-network-session-password-key session))))) - (setq step (sasl-next-step client nil)) -;;; (if (string= "APOP" name) -;;; (if (string-match "^\+OK .*\\(<[^\>]+>\\)" -;;; (elmo-network-session-greeting-internal session)) -;;; (sasl-step-set-data -;;; step -;;; (match-string -;;; 1 -;;; (elmo-network-session-greeting-internal session))) -;;; (signal 'elmo-authenticate-error '(elmo-pop3-no-capability-apop)))) -;;; (if (or (string= name "USER") -;;; (string= name "APOP")) -;;; (progn -;;; (setq step (sasl-next-step client step)) -;;; (elmo-pop3-send-command -;;; process -;;; (format "%s %s" name -;;; (sasl-step-data step)))) - (elmo-pop3-send-command - process - (concat "AUTH " name - (and (sasl-step-data step) - (concat - " " - (elmo-base64-encode-string - (sasl-step-data step) 'no-line-break)))));) - (catch 'done - (while t - (unless (setq response (elmo-pop3-read-response process t)) - (signal 'elmo-authenticate-error - (list (intern - (concat "elmo-pop3-auth-" - (downcase name)))))) - (if (string-match "^\+OK" response) - (if (sasl-next-step client step) - (signal 'elmo-authenticate-error - (list (intern - (concat "elmo-pop3-auth-" - (downcase name))))) - (throw 'done nil))) - (sasl-step-set-data - step - (elmo-base64-decode-string - (cadr (split-string response " ")))) - (setq step (sasl-next-step client step)) - (elmo-pop3-send-command - process - (if (sasl-step-data step) - (elmo-base64-encode-string (sasl-step-data step) - 'no-line-break) - ""))))))))) + (setq name (sasl-mechanism-name mechanism)) + (elmo-network-session-set-auth-internal session + (intern (downcase name))) + (setq sasl-read-passphrase + (function + (lambda (prompt) + (elmo-get-passwd + (elmo-network-session-password-key session))))) + (setq step (sasl-next-step client nil)) + (elmo-pop3-send-command + process + (concat "AUTH " name + (and (sasl-step-data step) + (concat + " " + (elmo-base64-encode-string + (sasl-step-data step) 'no-line-break))))) ;) + (catch 'done + (while t + (unless (setq response (elmo-pop3-read-response process t)) + (signal 'elmo-authenticate-error + (list (intern + (concat "elmo-pop3-auth-" + (downcase name)))))) + (if (string-match "^\+OK" response) + (if (sasl-next-step client step) + (signal 'elmo-authenticate-error + (list (intern + (concat "elmo-pop3-auth-" + (downcase name))))) + (throw 'done nil))) + (sasl-step-set-data + step + (elmo-base64-decode-string + (cadr (split-string response " ")))) + (setq step (sasl-next-step client step)) + (elmo-pop3-send-command + process + (if (sasl-step-data step) + (elmo-base64-encode-string (sasl-step-data step) + 'no-line-break) + ""))))))))) (luna-define-method elmo-network-setup-session ((session elmo-pop3-session)) -- 1.7.10.4