From: Thomas Fitzsimmons Date: Tue, 27 Oct 2015 02:15:01 +0000 (-0400) Subject: url-http-ntlm.el (url-ntlm-auth): Move defun near end of file X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/4128f4fb735e3a179420a8d3bc2bd5c89a889dfb url-http-ntlm.el (url-ntlm-auth): Move defun near end of file --- diff --git a/packages/url-http-ntlm/url-http-ntlm.el b/packages/url-http-ntlm/url-http-ntlm.el index 86649a67d..302915f9d 100644 --- a/packages/url-http-ntlm/url-http-ntlm.el +++ b/packages/url-http-ntlm/url-http-ntlm.el @@ -53,41 +53,6 @@ The username can contain the domain name, in the form \"user@domain\". Note that for any server, only one user and password is ever stored.") -(defun url-ntlm-auth (url &optional prompt overwrite realm args) - "Return an NTLM HTTP authorization header. -Get the contents of the Authorization header for a HTTP response -using NTLM authentication, to access URL. Because NTLM is a -two-step process, this function expects to be called twice, first -to generate the NTLM type 1 message (request), then to respond to -the server's type 2 message (challenge) with a suitable response. - -PROMPT, OVERWRITE, and REALM are ignored. - -ARGS is expected to contain the WWW-Authentication header from -the server's last response. These are used by -`url-http-get-stage' to determine what stage we are at." - (url-http-ntlm-ensure-keepalive) - (let ((stage (url-http-ntlm-get-stage args))) - (case stage - ;; NTLM Type 1 message: the request - (:request - (destructuring-bind (&optional server user hash) - (url-http-ntlm-authorisation url) - (when server - (url-http-ntlm-string - (ntlm-build-auth-request user server))))) - ;; NTLM Type 3 message: the response - (:response - (let ((challenge (url-http-ntlm-get-challenge))) - (destructuring-bind (server user hash) - (url-http-ntlm-authorisation url) - (url-http-ntlm-string - (ntlm-build-auth-response challenge - user - hash))))) - (:error - (url-http-ntlm-authorisation url :clear))))) - (defun url-http-ntlm-ensure-keepalive () "Report an error if `url-http-attempt-keepalives' is not set." (assert url-http-attempt-keepalives @@ -204,6 +169,41 @@ stored." "Return DATA encoded as an NTLM string." (concat "NTLM " (base64-encode-string data :nobreak))) +(defun url-ntlm-auth (url &optional prompt overwrite realm args) + "Return an NTLM HTTP authorization header. +Get the contents of the Authorization header for a HTTP response +using NTLM authentication, to access URL. Because NTLM is a +two-step process, this function expects to be called twice, first +to generate the NTLM type 1 message (request), then to respond to +the server's type 2 message (challenge) with a suitable response. + +PROMPT, OVERWRITE, and REALM are ignored. + +ARGS is expected to contain the WWW-Authentication header from +the server's last response. These are used by +`url-http-get-stage' to determine what stage we are at." + (url-http-ntlm-ensure-keepalive) + (let ((stage (url-http-ntlm-get-stage args))) + (case stage + ;; NTLM Type 1 message: the request + (:request + (destructuring-bind (&optional server user hash) + (url-http-ntlm-authorisation url) + (when server + (url-http-ntlm-string + (ntlm-build-auth-request user server))))) + ;; NTLM Type 3 message: the response + (:response + (let ((challenge (url-http-ntlm-get-challenge))) + (destructuring-bind (server user hash) + (url-http-ntlm-authorisation url) + (url-http-ntlm-string + (ntlm-build-auth-response challenge + user + hash))))) + (:error + (url-http-ntlm-authorisation url :clear))))) + (url-register-auth-scheme "ntlm" nil 8) (provide 'url-http-ntlm)