comparison lisp/gnus/auth-source.el @ 94837:55eb2a3c59b4

Merge from gnus--devo--0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1153
author Miles Bader <miles@gnu.org>
date Sat, 10 May 2008 05:34:55 +0000
parents f42ef85caf91
children 51e9d65c90fc
comparison
equal deleted inserted replaced
94836:3cb546529dde 94837:55eb2a3c59b4
37 ;; (require 'epa-file) 37 ;; (require 'epa-file)
38 ;; (epa-file-mode) 38 ;; (epa-file-mode)
39 39
40 ;; before you put some data in ~/.authinfo.gpg (the default place) 40 ;; before you put some data in ~/.authinfo.gpg (the default place)
41 41
42 ;;; For url-auth authentication (HTTP/HTTPS), you need to use:
43
44 ;;; machine yourmachine.com:80 port http login testuser password testpass
45
46 ;;; This will match any realm and authentication method (basic or
47 ;;; digest). If you want finer controls, explore the url-auth source
48 ;;; code and variables.
49
42 ;;; Code: 50 ;;; Code:
51
52 (require 'gnus-util)
43 53
44 (eval-when-compile (require 'cl)) 54 (eval-when-compile (require 'cl))
45 (eval-when-compile (require 'netrc)) 55 (eval-when-compile (require 'netrc))
46 56
47 (defgroup auth-source nil 57 (defgroup auth-source nil
133 (unless fallback 143 (unless fallback
134 (auth-source-pick host protocol t))))) 144 (auth-source-pick host protocol t)))))
135 145
136 (defun auth-source-user-or-password (mode host protocol) 146 (defun auth-source-user-or-password (mode host protocol)
137 "Find user or password (from the string MODE) matching HOST and PROTOCOL." 147 "Find user or password (from the string MODE) matching HOST and PROTOCOL."
148 (gnus-message 9
149 "auth-source-user-or-password: get %s for %s (%s)"
150 mode host protocol)
138 (let (found) 151 (let (found)
139 (dolist (choice (auth-source-pick host protocol)) 152 (dolist (choice (auth-source-pick host protocol))
140 (setq found (netrc-machine-user-or-password 153 (setq found (netrc-machine-user-or-password
141 mode 154 mode
142 (plist-get choice :source) 155 (plist-get choice :source)
143 (list host) 156 (list host)
144 (list (format "%s" protocol)) 157 (list (format "%s" protocol))
145 (auth-source-protocol-defaults protocol))) 158 (auth-source-protocol-defaults protocol)))
146 (when found 159 (when found
160 (gnus-message 9
161 "auth-source-user-or-password: found %s=%s for %s (%s)"
162 mode
163 ;; don't show the password
164 (if (equal mode "password") "SECRET" found)
165 host protocol)
147 (return found))))) 166 (return found)))))
148 167
149 (defun auth-source-protocol-defaults (protocol) 168 (defun auth-source-protocol-defaults (protocol)
150 "Return a list of default ports and names for PROTOCOL." 169 "Return a list of default ports and names for PROTOCOL."
151 (cdr-safe (assoc protocol auth-source-protocols))) 170 (cdr-safe (assoc protocol auth-source-protocols)))