2000-11-02 Daiki Ueno <ueno@unixuser.org>
+ * sasl.el (sasl-mechanisms): Add `LOGIN' and `ANONYMOUS'.
+ (sasl-mechanism-alist): Likewise.
+ (sasl-error): Define.
+ (sasl-login-continuations): New variable.
+ (sasl-login-response-1): New function.
+ (sasl-login-response-2): New function.
+ (sasl-anonymous-continuations): New variable.
+ (sasl-anonymous-response): New function.
+
+ * smtp.el (smtp-error): Define.
+ (smtp-via-smtp): Use it.
+
+2000-11-02 Daiki Ueno <ueno@unixuser.org>
+
* smtp.el (smtp-via-smtp): Mark as obsolete.
(smtp-send-buffer): Rename from `smtp-via-smtp'.
(require 'poe)
(defvar sasl-mechanisms
- '("CRAM-MD5" "DIGEST-MD5" "PLAIN"))
+ '("CRAM-MD5" "DIGEST-MD5" "PLAIN" "LOGIN" "ANONYMOUS"))
(defvar sasl-mechanism-alist
'(("CRAM-MD5" sasl-cram)
("DIGEST-MD5" sasl-digest)
- ("PLAIN" sasl-plain)))
+ ("PLAIN" sasl-plain)
+ ("LOGIN" sasl-login)
+ ("ANONYMOUS" sasl-anonymous)))
(defvar sasl-unique-id-function #'sasl-unique-id-function)
(defmacro sasl-principal-server (principal)
`(aref ,principal 3))
+(put 'sasl-error 'error-message "SASL error")
+(put 'sasl-error 'error-conditions '(sasl-error error))
+
+(defun sasl-error (datum)
+ (signal 'sasl-error (list datum)))
+
(defun sasl-make-authenticator (mechanism continuations)
"Make an authenticator.
MECHANISM is a IANA registered SASL mechanism name.
(char-to-string (aref "zyxwvutsrqponmlkjihgfedcba9876543210"
(% num 36))))))
-;;; PLAIN SASL mechanism (RFC2595 Section 6)
+;;; PLAIN (RFC2595 Section 6)
(defconst sasl-plain-continuations
'(sasl-plain-response))
(provide 'sasl-plain)
+;;; LOGIN (No specification exists)
+(defconst sasl-login-continuations
+ '(ignore ;no initial response
+ sasl-login-response-1
+ sasl-login-response-2))
+
+(defun sasl-login-response-1 (principal challenge)
+ (unless (string= (nth 1 challenge) "Username:")
+ (sasl-error (format "Unexpected response: %s" (nth 1 challenge))))
+ (sasl-principal-name principal))
+
+(defun sasl-login-response-2 (principal challenge)
+ (unless (string= (nth 1 challenge) "Password:")
+ (sasl-error (format "Unexpected response: %s" (nth 1 challenge))))
+ (sasl-read-passphrase
+ (format "LOGIN passphrase for %s: " (sasl-principal-name principal))))
+
+(put 'sasl-login 'sasl-authenticator
+ (sasl-make-authenticator "LOGIN" sasl-login-continuations))
+
+(provide 'sasl-login)
+
+;;; ANONYMOUS (RFC2245)
+(defconst sasl-anonymous-continuations
+ '(identity ;no initial response
+ sasl-anonymous-response))
+
+(defun sasl-anonymous-response (principal challenge)
+ (concat (sasl-principal-name principal)))
+
+(put 'sasl-anonymous 'sasl-authenticator
+ (sasl-make-authenticator "ANONYMOUS" sasl-anonymous-continuations))
+
+(provide 'sasl-anonymous)
+
(provide 'sasl)
;;; sasl.el ends here
(progn
(smtp-send-buffer sender recipients buffer)
t)
- (smtp-response-error)))
+ (smtp-error)))
(make-obsolete 'smtp-via-smtp "It's old API.")
(goto-char (point-max))
(insert output)))
+(put 'smtp-error 'error-message "SMTP error")
+(put 'smtp-error 'error-conditions '(smtp-error error))
+
(put 'smtp-response-error 'error-message "SMTP response error")
-(put 'smtp-response-error 'error-conditions '(smtp-response-error error))
+(put 'smtp-response-error 'error-conditions '(smtp-response-error smtp-error error))
(defun smtp-response-error (response)
(signal 'smtp-response-error response))