
,Jc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d Z d Z	 d Z
 d e f d     YZ d d	  Z d
   Z d   Z d   Z d d  Z d d  Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d  e f d!     YZ d S("   s1  
The MIT License

Copyright (c) 2007 Leah Culver

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
iNs   1.0t   GETt	   PLAINTEXTt
   OAuthErrorc           B   s   e  Z d  Z d d  Z RS(   s   Generic exception class.s   OAuth error occured.c         C   s   | |  _  d  S(   N(   t   message(   t   selfR   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   __init__)   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   '   s   t    c         C   s   i d |  d 6S(   s,   Optional WWW-Authenticate header (401 error)s   OAuth realm="%s"s   WWW-Authenticate(    (   t   realm(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   build_authenticate_header,   s    c         C   s   t  j |  d d S(   s   Escape a URL including any /.t   safet   ~(   t   urllibt   quote(   t   s(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   escape0   s    c         C   s*   t  |  t  r |  j d  St |   Sd S(   s   Convert unicode to utf-8.s   utf-8N(   t
   isinstancet   unicodet   encodet   str(   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt	   _utf8_str4   s    c           C   s   t  t j    S(   s   Get seconds since epoch (UTC).(   t   intt   time(    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   generate_timestamp;   s    i   c         C   s8   d j  g  t |   D] } t t j d d   ^ q  S(   s   Generate pseudorandom number.R	   i    i	   (   t   joint   rangeR   t   randomt   randint(   t   lengtht   i(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   generate_nonce?   s    c         C   s8   d j  g  t |   D] } t t j d d   ^ q  S(   s   Generate pseudorandom number.R	   i    i	   (   R   R   R   R   R   (   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   generate_verifierC   s    t   OAuthConsumerc           B   s#   e  Z d  Z d Z d Z d   Z RS(   s   Consumer of OAuth authentication.

    OAuthConsumer is a data type that represents the identity of the Consumer
    via its shared secret with the Service Provider.

    c         C   s   | |  _  | |  _ d  S(   N(   t   keyt   secret(   R   R#   R$   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   R   s    	N(   R   R   R   t   NoneR#   R$   R   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR"   H   s   t
   OAuthTokenc           B   sz   e  Z d  Z d Z d Z d Z d Z d Z d   Z	 d   Z
 d d  Z d   Z d   Z d   Z e e  Z d   Z RS(	   s   OAuthToken is a data type that represents an End User via either an access
    or request token.
    
    key -- the token
    secret -- the token secret

    c         C   s   | |  _  | |  _ d  S(   N(   R#   R$   (   R   R#   R$   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   e   s    	c         C   s   | |  _  d |  _ d  S(   Nt   true(   t   callbackt   callback_confirmed(   R   R(   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   set_callbacki   s    	c         C   s(   | d  k	 r | |  _ n t   |  _ d  S(   N(   R%   t   verifierR!   (   R   R+   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   set_verifierm   s    c         C   s   |  j  r |  j r t j |  j   } | d  \ } } } } } } | r\ d | |  j f } n d |  j } t j | | | | | | f  S|  j  S(   Ni   s   %s&oauth_verifier=%ss   oauth_verifier=%s(   R(   R+   t   urlparset
   urlunparse(   R   t   partst   schemet   netloct   patht   paramst   queryt   fragment(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   get_callback_urls   s    c         C   sF   i |  j  d 6|  j d 6} |  j d  k	 r9 |  j | d <n  t j |  S(   Nt   oauth_tokent   oauth_token_secrett   oauth_callback_confirmed(   R#   R$   R)   R%   R   t	   urlencode(   R   t   data(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt	   to_string   s    
c         C   sm   t  j |  d t } | d d } | d d } t | |  } y | d d | _ Wn t k
 rh n X| S(   s]    Returns a token from something like:
        oauth_token_secret=xxx&oauth_token=xxx
        t   keep_blank_valuesR7   i    R8   R9   (   t   cgit   parse_qst   FalseR&   R)   t   KeyError(   R   R3   R#   R$   t   token(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   from_string   s    c         C   s
   |  j    S(   N(   R<   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   __str__   s    N(   R   R   R   R%   R#   R$   R(   R)   R+   R   R*   R,   R6   R<   RC   t   staticmethodRD   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR&   W   s   						t   OAuthRequestc           B   s7  e  Z d  Z d Z e Z d Z e Z	 e d d d  Z
 d   Z d   Z d   Z d   Z d d  Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d d d d  Z e e  Z d d d e d d d  Z e e  Z d e d d d  Z e e  Z d   Z e e  Z d   Z e e  Z RS(   ss  OAuthRequest represents the request and can be serialized.

    OAuth parameters:
        - oauth_consumer_key 
        - oauth_token
        - oauth_signature_method
        - oauth_signature 
        - oauth_timestamp 
        - oauth_nonce
        - oauth_version
        - oauth_verifier
        ... any additional parameters, as defined by the Service Provider.
    c         C   s%   | |  _  | |  _ | p i  |  _ d  S(   N(   t   http_methodt   http_urlt
   parameters(   R   RG   RH   RI   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR      s    		c         C   s   | |  j  | <d  S(   N(   RI   (   R   t	   parametert   value(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   set_parameter   s    c         C   s-   y |  j  | SWn t d |   n Xd  S(   Ns   Parameter not found: %s(   RI   R   (   R   RJ   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   get_parameter   s    c         C   s   |  j  d  |  j  d  f S(   Nt   oauth_timestampt   oauth_nonce(   RM   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   _get_timestamp_nonce   s    c         C   sL   i  } x? |  j  j   D]. \ } } | j d  d k  r | | | <q q W| S(   s   Get any non-OAuth parameters.t   oauth_i    (   RI   t	   iteritemst   find(   R   RI   t   kt   v(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   get_nonoauth_parameters   s
    R	   c         C   st   d | } |  j  ri xS |  j  j   D]? \ } } | d  d k r# | d | t t |   f 7} q# q# Wn  i | d 6S(   s.   Serialize as a header for an HTTPAuth request.s   OAuth realm="%s"i   RQ   s	   , %s="%s"t   Authorization(   RI   RR   R   R   (   R   R
   t   auth_headerRT   RU   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt	   to_header   s    
	*c         C   sQ   d j  g  |  j j   D]4 \ } } d t t |   t t |   f ^ q  S(   s*   Serialize as post data for a POST request.t   &s   %s=%s(   R   RI   RR   R   R   (   R   RT   RU   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   to_postdata   s    	c         C   s   d |  j    |  j   f S(   s%   Serialize as a URL for a GET request.s   %s?%s(   t   get_normalized_http_urlR[   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   to_url   s    c         C   s   |  j  } y | d =Wn n Xg  | j   D]0 \ } } t t |   t t |   f ^ q+ } | j   d j g  | D] \ } } d | | f ^ qx  S(   sA   Return a string that contains the parameters that must be signed.t   oauth_signatureRZ   s   %s=%s(   RI   t   itemsR   R   t   sortR   (   R   R3   RT   RU   t
   key_values(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   get_normalized_parameters   s    	@
c         C   s   |  j  j   S(   s   Uppercases the http method.(   RG   t   upper(   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   get_normalized_http_method   s    c         C   s   t  j  |  j  } | d  \ } } } | d k rN | d d k rN | d  } n) | d k rw | d d k rw | d  } n  d | | | f S(	   s8   Parses the URL and rebuilds it to be scheme://host/path.i   t   httpis   :80t   httpsis   :443s	   %s://%s%s(   R-   RH   (   R   R/   R0   R1   R2   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR\      s    c         C   s9   |  j  d | j    |  j  d |  j | | |   d S(   s=   Set the signature parameter to the result of build_signature.t   oauth_signature_methodR^   N(   RL   t   get_namet   build_signature(   R   t   signature_methodt   consumerRB   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   sign_request   s    		c         C   s   | j  |  | |  S(   s=   Calls the build signature method within the signature method.(   Ri   (   R   Rj   Rk   RB   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRi     s    c   
      C   s   | d k r i  } n  | r d | k r | d } | d  d k r | d } y  t j |  } | j |  Wq t d   q Xq n  | r t j |  } | j |  n  t j |  d } t j |  }	 | j |	  | r t |  | |  Sd S(   s$   Combines multiple parameter sources.RW   i   s   OAuth s;   Unable to parse OAuth parameters from Authorization header.i   N(   R%   RF   t   _split_headert   updateR   t   _split_url_stringR-   (
   RG   RH   t   headersRI   t   query_stringRX   t   header_paramst   query_paramst	   param_strt
   url_params(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   from_request	  s(    	

c         C   s   | s i  } n  i |  j  d 6t   d 6t   d 6t j d 6} | j |  | } | r | j  | d <| j r| | j | d <n  | r | | d <q n | r | | d <n  t | | |  S(   Nt   oauth_consumer_keyRN   RO   t   oauth_versionR7   t   oauth_callbackt   oauth_verifier(   R#   R   R    RF   t   versionRn   R(   (   t   oauth_consumerRB   R(   R+   RG   RH   RI   t   defaults(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   from_consumer_and_token-  s$    	


	c         C   s?   | s i  } n  |  j  | d <| r/ | | d <n  t | | |  S(   NR7   Ry   (   R#   RF   (   RB   R(   RG   RH   RI   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   from_token_and_callbackK  s    	c         C   s   i  } |  j  d  } xk | D]c } | j d  d k r= q n  | j   } | j  d d  } t j | d j d   | | d <q W| S(   s+   Turn Authorization: header into parameters.t   ,R
   it   =i   s   "i    (   t   splitRS   t   stripR   t   unquote(   t   headerR3   R/   t   paramt   param_parts(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRm   X  s    (c         C   sM   t  j |  d t } x1 | j   D]# \ } } t j | d  | | <q" W| S(   s    Turn URL string into parameters.R=   i    (   R>   R?   R@   RR   R   R   (   Rt   RI   RT   RU   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRo   i  s    N(   R   R   R   R%   RI   t   HTTP_METHODRG   RH   t   VERSIONR{   R   RL   RM   RP   RV   RY   R[   R]   Rb   Rd   R\   Rl   Ri   Rv   RE   R~   R   Rm   Ro   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRF      s@   					
								!	
		t   OAuthServerc           B   s   e  Z d  Z d Z e Z d Z d Z d d d  Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d	   Z d
   Z d d  Z d   Z d   Z d   Z d d  Z d   Z d   Z d   Z d   Z RS(   sA   A worker to check the validity of a request against a data store.i,  c         C   s   | |  _  | p i  |  _ d  S(   N(   t
   data_storet   signature_methods(   R   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   x  s    	c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   set_data_store|  s    c         C   s   |  j  S(   N(   R   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   get_data_store  s    c         C   s   | |  j  | j   <|  j  S(   N(   R   Rh   (   R   Rj   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   add_signature_method  s    c         C   s   y |  j  | d  } Wn t k
 r |  j |  } |  j |  } y |  j |  } Wn t k
 rp d } n X|  j | | d  |  j j | |  } n X| S(   s\   Processes a request_token request and returns the
        request token on success.
        t   requestN(	   t
   _get_tokenR   t   _get_versiont   _get_consumert   get_callbackR%   t   _check_signatureR   t   fetch_request_token(   R   t   oauth_requestRB   R{   Rk   R(   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    
c         C   s   |  j  |  } |  j |  } y |  j |  } Wn t k
 rJ d } n X|  j | d  } |  j | | |  |  j j | | |  } | S(   s[   Processes an access_token request and returns the
        access token on success.
        R   N(	   R   R   t   _get_verifierR   R%   R   R   R   t   fetch_access_token(   R   R   R{   Rk   R+   RB   t	   new_token(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    
c         C   s\   |  j  |  } |  j |  } |  j | d  } |  j | | |  | j   } | | | f S(   s3   Verifies an api call and checks all the parameters.t   access(   R   R   R   R   RV   (   R   R   R{   Rk   RB   RI   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   verify_request  s    c         C   s   |  j  j | |  S(   s   Authorize a request token.(   R   t   authorize_request_token(   R   RB   t   user(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   authorize_token  s    c         C   s   | j  d  S(   s   Get the callback URL.Ry   (   RM   (   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    R	   c         C   s   i d | d 6S(   s-   Optional support for the authenticate header.s   OAuth realm="%s"s   WWW-Authenticate(    (   R   R
   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    c         C   sU   y | j  d  } Wn t } n X| rQ | |  j k rQ t d t |    n  | S(   s3   Verify the correct version request for this server.Rx   s   OAuth version %s not supported.(   RM   R   R{   R   R   (   R   R   R{   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    
c         C   sp   y | j  d  } Wn t } n Xy |  j | } Wn5 d j |  j j    } t d | | f   n X| S(   s,   Figure out the signature with some defaults.Rg   s   , s>   Signature method %s not supported try one of the following: %s(   RM   t   SIGNATURE_METHODR   R   t   keysR   (   R   R   Rj   t   signature_method_names(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   _get_signature_method  s    
c         C   s:   | j  d  } |  j j |  } | s6 t d   n  | S(   NRw   s   Invalid consumer.(   RM   R   t   lookup_consumerR   (   R   R   t   consumer_keyRk   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s
    R   c         C   sG   | j  d  } |  j j | |  } | sC t d | | f   n  | S(   s9   Try to find the token for the provided request token key.R7   s   Invalid %s token: %s(   RM   R   t   lookup_tokenR   (   R   R   t
   token_typet   token_fieldRB   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s
    c         C   s   | j  d  S(   NRz   (   RM   (   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    c         C   s   | j    \ } } |  j |  |  j | | |  |  j |  } y | j d  } Wn t d   n X| j | | | |  } | s | j | | |  \ }	 }
 t d |
   n  | j | | |  } d  S(   NR^   s   Missing signature.s5   Invalid signature. Expected signature base string: %s(	   RP   t   _check_timestampt   _check_nonceR   RM   R   t   check_signaturet   build_signature_base_stringRi   (   R   R   Rk   RB   t	   timestampt   nonceRj   t	   signaturet	   valid_sigR#   t   baset   built(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s     c         C   sZ   t  |  } t  t j    } | | } | |  j k rV t d | | |  j f   n  d S(   s#   Verify that timestamp is recentish.sQ   Expired timestamp: given %d and now %s has a greater difference than threshold %dN(   R   R   t   timestamp_thresholdR   (   R   R   t   nowt   lapsed(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    
c         C   s;   |  j  j | | |  } | r7 t d t |    n  d S(   s#   Verify that the nonce is uniqueish.s   Nonce already used: %sN(   R   t   lookup_nonceR   R   (   R   Rk   RB   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    N(   R   R   R   R   R   R{   R%   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   q  s.   									
					
t   OAuthClientc           B   sP   e  Z d  Z d Z d Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   s8   OAuthClient is a worker to attempt to execute a request.c         C   s   | |  _  | |  _ d  S(   N(   Rk   RB   (   R   R|   R7   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    	c         C   s   |  j  S(   N(   Rk   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   get_consumer  s    c         C   s   |  j  S(   N(   RB   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt	   get_token  s    c         C   s
   t   d S(   s   -> OAuthToken.N(   t   NotImplementedError(   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   !  s    c         C   s
   t   d S(   s   -> OAuthToken.N(   R   (   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   %  s    c         C   s
   t   d S(   s   -> Some protected resource.N(   R   (   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   access_resource)  s    N(   R   R   R   R%   Rk   RB   R   R   R   R   R   R   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s   					t   OAuthDataStorec           B   sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s;   A database abstraction used to lookup consumers and tokens.c         C   s
   t   d S(   s   -> OAuthConsumer.N(   R   (   R   R#   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   1  s    c         C   s
   t   d S(   s   -> OAuthToken.N(   R   (   R   R|   R   t   token_token(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   5  s    c         C   s
   t   d S(   s   -> OAuthToken.N(   R   (   R   R|   R7   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   9  s    c         C   s
   t   d S(   s   -> OAuthToken.N(   R   (   R   R|   Ry   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   =  s    c         C   s
   t   d S(   s   -> OAuthToken.N(   R   (   R   R|   R7   Rz   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   A  s    c         C   s
   t   d S(   s   -> OAuthToken.N(   R   (   R   R7   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   E  s    (	   R   R   R   R   R   R   R   R   R   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   .  s   					t   OAuthSignatureMethodc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s4   A strategy class that implements a signature method.c         C   s
   t   d S(   s   -> str.N(   R   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRh   L  s    c         C   s
   t   d S(   s   -> str key, str raw.N(   R   (   R   R   R|   R7   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   P  s    c         C   s
   t   d S(   s   -> str.N(   R   (   R   R   R|   R7   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRi   T  s    c         C   s   |  j  | | |  } | | k S(   N(   Ri   (   R   R   Rk   RB   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   X  s    (   R   R   R   Rh   R   Ri   R   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   J  s
   			t   OAuthSignatureMethod_HMAC_SHA1c           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   d S(   Ns	   HMAC-SHA1(    (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRh   _  s    c         C   s{   t  | j    t  | j    t  | j    f } d t  | j  } | rb | t  | j  7} n  d j |  } | | f S(   Ns   %s&RZ   (   R   Rd   R\   Rb   R$   R   (   R   R   Rk   RB   t   sigR#   t   raw(    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   b  s    c   	      C   s   |  j  | | |  \ } } y( d d l } t j | | | j  } Wn( d d l } t j | | |  } n Xt j | j    d  S(   s!   Builds the base signature string.iN(	   R   t   hashlibt   hmact   newt   sha1t   shat   binasciit
   b2a_base64t   digest(	   R   R   Rk   RB   R#   R   R   t   hashedR   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRi   o  s    (   R   R   Rh   R   Ri   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR   ]  s   		t   OAuthSignatureMethod_PLAINTEXTc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   d S(   NR   (    (   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRh     s    c         C   s9   d t  | j  } | r/ | t  | j  } n  | | f S(   s)   Concatenates the consumer key and secret.s   %s&(   R   R$   (   R   R   Rk   RB   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s    c         C   s   |  j  | | |  \ } } | S(   N(   R   (   R   R   Rk   RB   R#   R   (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyRi     s    (   R   R   Rh   R   Ri   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyR     s   		(   R   R>   R   R   R   R-   R   R   R   R   R   t   RuntimeErrorR   R   R   R   R   R    R!   t   objectR"   R&   RF   R   R   R   R   R   R   (    (    (    s/   /usr/lib/python2.7/dist-packages/oauth/oauth.pyt   <module>   s4   			E#