%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/oauthlib/oauth1/rfc5849/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/oauthlib/oauth1/rfc5849/__pycache__/__init__.cpython-312.pyc

�

&�`hA����dZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZmZddl
mZmZej e�ZdZdZdZeZd	Zd
ZdZeZdZeeeeeeefZd
ZdZdZdZ Gd�d�Z!y)a�
oauthlib.oauth1.rfc5849
~~~~~~~~~~~~~~

This module is an implementation of various logic needed
for signing and checking OAuth 1.0 RFC 5849 requests.

It supports all three standard signature methods defined in RFC 5849:

- HMAC-SHA1
- RSA-SHA1
- PLAINTEXT

It also supports signature methods that are not defined in RFC 5849. These are
based on the standard ones but replace SHA-1 with the more secure SHA-256:

- HMAC-SHA256
- RSA-SHA256

�N)�Request�generate_nonce�generate_timestamp�
to_unicode�	urlencode�)�
parameters�	signaturez	HMAC-SHA1zHMAC-SHA256zHMAC-SHA512zRSA-SHA1z
RSA-SHA256z
RSA-SHA512�	PLAINTEXT�AUTH_HEADER�QUERY�BODY�!application/x-www-form-urlencodedc��eZdZdZeejeeje	ejeeje
ejeej eej$iZed��Zddddeedddddddf
d�Zd�Zd�Zd�Zdd	�Zdd
�Zy)
�Clientz2A client used to sign OAuth 1.0 RFC 5849 requests.c�"�||j|<y�N)�SIGNATURE_METHODS)�cls�method_name�method_callbacks   �B/usr/lib/python3/dist-packages/oauthlib/oauth1/rfc5849/__init__.py�register_signature_methodz Client.register_signature_methodWs��-<����k�*�N�utf-8c�|���fd�}||�|_||�|_||�|_||�|_||�|_||�|_||�|_||�|_||	�|_||
�|_	|��|_
||�|_||
�|_||�|_
y)a�Create an OAuth 1 client.

        :param client_key: Client key (consumer key), mandatory.
        :param resource_owner_key: Resource owner key (oauth token).
        :param resource_owner_secret: Resource owner secret (oauth token secret).
        :param callback_uri: Callback used when obtaining request token.
        :param signature_method: SIGNATURE_HMAC, SIGNATURE_RSA or SIGNATURE_PLAINTEXT.
        :param signature_type: SIGNATURE_TYPE_AUTH_HEADER (default),
                               SIGNATURE_TYPE_QUERY or SIGNATURE_TYPE_BODY
                               depending on where you want to embed the oauth
                               credentials.
        :param rsa_key: RSA key used with SIGNATURE_RSA.
        :param verifier: Verifier used when obtaining an access token.
        :param realm: Realm (scope) to which access is being requested.
        :param encoding: If you provide non-unicode input you may use this
                         to have oauthlib automatically convert.
        :param decoding: If you wish that the returned uri, headers and body
                         from sign be encoded back from unicode, then set
                         decoding to your preferred encoding, i.e. utf-8.
        :param nonce: Use this nonce instead of generating one. (Mainly for testing)
        :param timestamp: Use this timestamp instead of using current. (Mainly for testing)
        c�$���rt|��S|Sr)r)�x�encodings �r�<lambda>z!Client.__init__.<locals>.<lambda>|s���h�:�a��2��A�rN)�
client_key�
client_secret�resource_owner_key�resource_owner_secret�signature_method�signature_type�callback_uri�rsa_key�verifier�realmr�decoding�nonce�	timestamp)�selfr!r"r#r$r'r%r&r(r)r*rr+r,r-�encodes           `    r�__init__zClient.__init__[s����BF�� ��,���#�M�2���"(�);�"<���%+�,A�%B��"� &�'7� 8���$�^�4���"�<�0����g�����x�(��
��E�]��
��x�(��
��x�(��
��E�]��
��	�*��rc��t|�j�}|drdnd|d<|drdnd|d<|drdnd|d<djd�|j�D��}dj	|j
j|�S)Nr"z****r(r$z, c3�FK�|]\}}dj||����y�w)z{}={}N)�format)�.0�k�vs   r�	<genexpr>z"Client.__repr__.<locals>.<genexpr>�s����!Q�4�1�a�'�.�.��A�"6�!Q�s�!z<{} {}>)�vars�copy�join�itemsr3�	__class__�__name__)r.�attrs�
attribute_strs   r�__repr__zClient.__repr__�s����T�
���!��+0��+A��t��o��%*�9�%5�6�4��i��16�7N�1O�v�UY�	�#�	%��	�	�!Q�5�;�;�=�!Q�Q�
������� 7� 7��G�Grc��|jtk(r*tj|j|j
�S|j
|�\}}}tjtj|�j||��}tjdj|��tj|�}tj||jdd��}tjdj|��tjdj|��tj |j"||�}tjdj|��|j|j$vrt'd��|j$|j||�}	tjd	j|	��|	S)
awGet an OAuth signature to be used in signing a request

        To satisfy `section 3.4.1.2`_ item 2, if the request argument's
        headers dict attribute contains a Host item, its value will
        replace any netloc part of the request argument's uri attribute
        value.

        .. _`section 3.4.1.2`: https://tools.ietf.org/html/rfc5849#section-3.4.1.2
        )�	uri_query�body�headerszCollected params: {}�HostNzNormalized params: {}zNormalized URI: {}z"Signing: signature base string: {}zInvalid signature method.z
Signature: {})r%�SIGNATURE_PLAINTEXTr
�sign_plaintextr"r$�_render�collect_parameters�urlparse�query�log�debugr3�normalize_parameters�base_string_uri�get�signature_base_string�http_methodr�
ValueError)
r.�request�urirDrC�collected_params�normalized_params�normalized_uri�base_string�sigs
          r�get_oauth_signaturezClient.get_oauth_signature�s���� � �$7�7��+�+�D�,>�,>�,0�,F�,F�H�
H�"�\�\�'�2���W�d�$�7�7��'�'��,�2�2�����	�	�	�(�/�/�0@�A�B�%�:�:�;K�L��"�2�2�3����F�D�8Q�R���	�	�)�0�0�1B�C�D��	�	�&�-�-�n�=�>��5�5�g�6I�6I�6D�FW�Y��	�	�	�6�=�=�k�J�K�� � ��(>�(>�>��8�9�9�;�d�$�$�T�%:�%:�;�K��N���	�	�/�(�(��-�.��
rc
�,�|j�
t�n|j}|j�
t�n|j}d|fd|fdd|jfd|j
fg}|jr|jd|jf�|jr|jd|jf�|jr|jd	|jf�|jjd
d�}|xr|jd�dk}|j�q|ro|jd
tjt!j"|jj%d��j'��j)d�f�|S)zMGet the basic OAuth parameters to be used in generating a signature.
        N�oauth_nonce�oauth_timestamp)�
oauth_versionz1.0�oauth_signature_method�oauth_consumer_key�oauth_token�oauth_callback�oauth_verifier�Content-Typerr�oauth_body_hashr)r,rr-rr%r!r#�appendr'r)rDrP�findrC�base64�	b64encode�hashlib�sha1r/�digest�decode)r.rTr,r-�params�content_type�content_type_eligibles       r�get_oauth_paramszClient.get_oauth_params�sw���J�J�&� �!�,0�J�J�	����.�(�)�48�N�N�	��E�"�
�	�*�$�
%�t�'<�'<�=�
!�4�?�?�3�
���"�"��M�M�=�$�*A�*A�B�C�����M�M�+�T�->�->�?�@��=�=��M�M�+�T�]�]�;�<����*�*�>�4�@�� ,� k��1B�1B�Cf�1g�jk�1k���<�<�#�(=��M�M�,�f�.>�.>�w�|�|�G�L�L�L_�L_�`g�Lh�?i�?p�?p�?r�.s�.z�.z�|C�/D�E�
F��
rc��|j|j|j}}}|jtk(r-tj|j|j|��}n�|jtk(rI|j�=tj|j|j�}|rt|�}d|d<nI|jtk(r+tj|j|j�}ntd��|||fS)aRender a signed request according to signature type

        Returns a 3-tuple containing the request URI, headers, and body.

        If the formencode argument is True and the body contains parameters, it
        is escaped and returned as a valid formencoded string.
        )r*rrez!Unknown signature type specified.)rUrDrCr&�SIGNATURE_TYPE_AUTH_HEADERr	�prepare_headers�oauth_params�SIGNATURE_TYPE_BODY�decoded_body�prepare_form_encoded_bodyr�SIGNATURE_TYPE_QUERY�prepare_request_uri_queryrS)r.rT�
formencoder*rUrDrCs       rrHzClient._render�s���%�[�[�'�/�/�7�<�<�d�W�����"<�<� �0�0��$�$�g�o�o�U�D�G�
�
 �
 �$7�
7�G�<P�<P�<\��7�7��$�$�g�&:�&:�<�D�� ����&I�G�N�#�
�
 �
 �$8�
8��6�6��$�$�g�k�k�3�C��@�A�A��G�T�!�!rc�"�t|||||j��}|jjdd�}|xr|j	d�}|t
k(}	|jdu}
|r
|
rtd��|	r
|
std��|	s%|
r#tdj|xsdt
���|jtk(r|	r|
r|rtd	��|j�d
vr
|
rtd��|j|�|_
|jjd|j|�f�|j!|d
|xs|j"��\}}}|j$r�t&j)d|j$�|j+|j$�}|r|j+|j$�n|}i}|j-�D]<\}}
|
j+|j$�||j+|j$�<�>|}|||fS)aFSign a request

        Signs an HTTP request with the specified parts.

        Returns a 3-tuple of the signed request's URI, headers, and body.
        Note that http_method is not returned as it is unaffected by the OAuth
        signing process. Also worth noting is that duplicate parameters
        will be included in the signature, regardless of where they are
        specified (query, body).

        The body argument may be a dict, a list of 2-tuples, or a formencoded
        string. The Content-Type header must be 'application/x-www-form-urlencoded'
        if it is present.

        If the body argument is not one of the above, it will be returned
        verbatim as it is unaffected by the OAuth signing process. Attempting to
        sign a request with non-formencoded data using the OAuth body signature
        type is invalid and will raise an exception.

        If the body does contain parameters, it will be returned as a properly-
        formatted formencoded string.

        Body may not be included if the http_method is either GET or HEAD as
        this changes the semantic meaning of the request.

        All string data MUST be unicode or be encoded with the same encoding
        scheme supplied to the Client constructor, default utf-8. This includes
        strings inside body dicts, for example.
        )rreNz
multipart/z?Headers indicate a multipart body but body contains parameters.z?Headers indicate a formencoded body but body was not decodable.zEBody contains parameters but Content-Type header was {} instead of {}znot setz=Body signatures may only be used with form-urlencoded content)�GET�HEADz*GET/HEAD requests should not include body.�oauth_signatureT)r|r*z%Encoding URI, headers and body to %s.)rrrDrP�
startswith�CONTENT_TYPE_FORM_URLENCODEDrxrSr3r&rw�upperrrrvrgr[rHr*r+rLrMr/r;)r.rUrRrCrDr*rTrp�	multipart�should_have_params�
has_params�new_headersr5r6s              r�signzClient.signs��>�#�{�D�'�#'�=�=�2�����*�*�>�4�@�� �J�\�%<�%<�\�%J�	�)�-I�I���)�)��5�
�
���Q�S�
S�
 �
��Q�S�
S�$�
�� � &��|�'@�y�(D�!F�G�
G��
 �
 �$7�
7�"�z�)��O�Q�
Q��
�
�
 �O�
3�
��I�J�J� $�4�4�W�=���	���#�#�
�� 8� 8�� A�B�	D�"�\�\�'�d�16�1D�$�*�*�*�G���W�d��=�=��I�I�=�t�}�}�M��*�*�T�]�]�+�C�15�4�;�;�t�}�}�-�4�D��K��
�
��
O���1�78�x�x��
�
�7N��A�H�H�T�]�]�3�4�
O�!�G��G�T�!�!r)FN)r~NNN)r=�
__module__�__qualname__�__doc__�SIGNATURE_HMAC_SHA1r
�sign_hmac_sha1_with_client�SIGNATURE_HMAC_SHA256�sign_hmac_sha256_with_client�SIGNATURE_HMAC_SHA512�sign_hmac_sha512_with_client�SIGNATURE_RSA_SHA1�sign_rsa_sha1_with_client�SIGNATURE_RSA_SHA256�sign_rsa_sha256_with_client�SIGNATURE_RSA_SHA512�sign_rsa_sha512_with_clientrF�sign_plaintext_with_clientr�classmethodrrtr0r@r[rrrHr��rrrrJs���<��Y�A�A��y�E�E��y�E�E��I�?�?��i�C�C��i�C�C��Y�A�A����=��=� $�$(�'+�"�"5� :���D�!�D��t�0+�dH�'�R!�F#"�Jf"rr)"r�rirk�logging�urllib.parse�parserJ�oauthlib.commonrrrrr�r	r
�	getLoggerr=rLr�r�r��SIGNATURE_HMACr�r�r��
SIGNATURE_RSArFrrtrzrwr�rr�rr�<module>r�s����(������$��g����!��"��%��%��$����#��#��"�
�!�����������+������B��c"�c"r

Zerion Mini Shell 1.0