; OAuth.lsp ; by Barce ; 25 February 2008 ; ; MIT License ; http://www.opensource.org/licenses/mit-license.php ; ; resources: ; ; http://oauth.net/ ; http://groups.google.com/group/oauth ; http://hueniverse.com/ ; ; eran@hueniverse.com ; /* does this work */ ; newlisp has no built-in url-encode and url-decode functions ; yet, so we use the noodles library (load "noodles.lsp") (set 'N NOODLES) ; Exception class (context 'OAuthException) (set 'RunTimeError nil) (define (oauth_error) (if (not nil?) RunTimeError (throw-error "OAuth error occured")) ) ; ; OAuthConsumer ; (context 'OAuthConsumer) (set 'key nil) (set 'secret nil) (set 'callback_url nil) ; ; OAuthToken ; (context 'OAuthToken);/*{{{*/ (set 'key nil) (set 'secret nil) (define (to_string) (append "oauth_token=" (N:url-encode key) "&oauth_token_secret=" (N:url-encode secret)) ) (define (from_string) ; get the query string's key and secret parameters and ; set key and secret accordingly );/*}}}*/ (context MAIN) ; ; OAuthSignatureMethod ; ;(context 'OAuthSignatureMethod) ; ; OAuthSignatureMethod_HMAC_SHA1 ; ; Try something like this ; (setq SHA1 (import "libssl.so.4" "SHA1")) ; (join (map (lambda (x) (format "%02x" (& x 0xff))) (unpack (dup "c" 20) (get-string (SHA1 "abc" 3 0))))) (context 'OAuthSignatureMethod_HMAC_SHA1) (define (get_name) (append "HMAC-SHA1") ) (define (build_signature request consumer token) (set 'base_string nil) ) (context MAIN) ; ; OAuthSignatureMethod_PLAINTEXT ; (context 'OAuthSignatureMethod_PLAINTEXT) (define (get_name) (append "PLAINTEXT") ) (define (build_signature request consumer token) ) (context MAIN) ; ; OAuthRequest ; ; look at using 'default' for handling passed objects (context 'OAuthRequest) (define (OAuthRequest:OAuthRequest _http_method _http_url _parameters) (setq http_method _http_method) (setq http_url _http_url) (set 'parameters _parameters) ) ; for debug purposes (set 'base_string "test") (set 'version "1.0") ; hi blaine (define (get-http-method) (append http_method) ) (define (get-http-url) (append http_url) ) ; ; attempt to build up a request from what was passed to the server ; (define (from_request _http_method _http_url _parameters) ) ; ; return either apache_request_headers or headers from ; somewhere else ; (define (get_headers) ) (context MAIN)