
    .                     r    d Z ddlmZmZ ddlZddlmZ ddlmZ  ej                  e
      Z G d d	e      Zy)
zoauthlib.oauth1.rfc5849.endpoints.signature_only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module is an implementation of the signing logic of OAuth 1.0 RFC 5849.
    )absolute_importunicode_literalsN   )errors   )BaseEndpointc                       e Zd ZdZddZy)SignatureOnlyEndpointz>An endpoint only responsible for verifying an oauth signature.Nc                    	 | j                  ||||      }	 | j                  |       | j                  |       | j                  j                  |j                  |j                  |j                  |      st        j                  d       d|fS | j                  j                  |j                  |      }|s| j                  j                  |_	        | j                  |      }||j                   d<   ||j                   d<   t#        ||f      }	|	sAt        j	                  d       t        j	                  d	|       t        j	                  d
|       |	|fS # t        j                  $ r"}t        j	                  d|z         Y d}~yd}~ww xY w# t        j                  $ r&}t        j	                  d|z         d|fcY d}~S d}~ww xY w)a  Validate a signed OAuth request.

        :param uri: The full URI of the token request.
        :param http_method: A valid HTTP verb, i.e. GET, POST, PUT, HEAD, etc.
        :param body: The request body as a string.
        :param headers: The request headers as a dict.
        :returns: A tuple of 2 elements.
                  1. True if valid, False otherwise.
                  2. An oauthlib.common.Request object.
        z.Exception caught while validating request, %s.N)FNFz.[Failure] verification failed: timestamp/nonceclient	signaturez&[Failure] request verification failed.zValid client: %szValid signature: %s)_create_requestr   OAuth1Errorloginfo_check_transport_security_check_mandatory_parametersrequest_validatorvalidate_timestamp_and_nonce
client_key	timestampnoncedebugvalidate_client_keydummy_client_check_signaturevalidator_logall)
selfurihttp_methodbodyheadersrequesterrvalid_clientvalid_signaturevs
             Clib/third_party/oauthlib/oauth1/rfc5849/endpoints/signature_only.pyvalidate_requestz&SignatureOnlyEndpoint.validate_request   s   $$S+tWEg

$$W-
&&w/
 !!>>G--w}}gG	ii@AG^ ))==G%L11>>g++G4O '3G(#)8G+& 	\?+,A	hh78	hh!<0	hh$o6g:[  	hh?#EF  	hh?#EFG^s4   E "F F	'FF	GG :G G)GETNN)__name__
__module____qualname____doc__r*        r)   r
   r
      s
    F:r1   r
   )r/   
__future__r   r   logging r   baser   	getLoggerr,   r   r
   r0   r1   r)   <module>r7      s6   
 9   g!=L =r1   