PageRenderTime 156ms CodeModel.GetById 61ms app.highlight 2ms RepoModel.GetById 58ms app.codeStats 0ms

/src/core/signature.lisp

http://github.com/skypher/cl-oauth
Lisp | 26 lines | 21 code | 5 blank | 0 comment | 0 complexity | 016005060a04cb54390c3ba4e4f29020 MD5 | raw file
 1
 2(in-package :oauth)
 3
 4(defun signature-base-string (&key (uri (request-uri))
 5                                   (request-method (request-method))
 6                                   (parameters (normalized-parameters)))
 7  (concatenate 'string (string-upcase (princ-to-string request-method))
 8                       "&" (url-encode
 9                             (normalize-uri uri))
10                       "&" (url-encode
11                             (alist->query-string parameters
12                                                  :url-encode t
13                                                  :include-leading-ampersand nil))))
14
15(declaim (notinline hmac-key)) ; we want to trace this when debugging. 
16(defun hmac-key (consumer-secret &optional token-secret)
17  "9.2"
18  (concatenate 'string (url-encode consumer-secret) "&" (url-encode (or token-secret ""))))
19
20(defun encode-signature (octets url-encode-p)
21  "9.2.1"
22  (let ((base64 (cl-base64:usb8-array-to-base64-string octets)))
23    (if url-encode-p
24      (url-encode base64)
25      base64)))
26