%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/requests/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/requests/__pycache__/auth.cpython-35.pyc



~�V~�@sdZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZmZddlmZd	Zd
Zdd�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z]
requests.auth
~~~~~~~~~~~~~

This module contains the authentication handlers for Requests.
�N)�	b64encode�)�urlparse�str)�extract_cookies_to_jar)�parse_dict_header�to_native_string)�codesz!application/x-www-form-urlencodedzmultipart/form-datacCs3dttd||fjd��j��}|S)zReturns a Basic Auth string.zBasic z%s:%s�latin1)rr�encode�strip)�username�passwordZauthstr�r�//usr/lib/python3/dist-packages/requests/auth.py�_basic_auth_strs)rc@s"eZdZdZdd�ZdS)�AuthBasez4Base class that all auth implementations derive fromcCstd��dS)NzAuth hooks must be callable.)�NotImplementedError)�self�rrrr�__call__(szAuthBase.__call__N)�__name__�
__module__�__qualname__�__doc__rrrrrr%src@s.eZdZdZdd�Zdd�ZdS)�
HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS)N)r
r)rr
rrrr�__init__.s	zHTTPBasicAuth.__init__cCs t|j|j�|jd<|S)N�
Authorization)rr
r�headers)rrrrrr2szHTTPBasicAuth.__call__N)rrrrrrrrrrr,src@s"eZdZdZdd�ZdS)�
HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCs t|j|j�|jd<|S)NzProxy-Authorization)rr
rr)rrrrrr9szHTTPProxyAuth.__call__N)rrrrrrrrrr7src@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cCs%||_||_tj�|_dS)N)r
r�	threadingZlocal�
_thread_local)rr
rrrrr@s		zHTTPDigestAuth.__init__cCs^t|jd�sZd|j_d|j_d|j_i|j_d|j_d|j_dS)N�initT�r)�hasattrr"r#�
last_nonce�nonce_count�chal�pos�
num_401_calls)rrrr�init_per_thread_stateFsz$HTTPDigestAuth.init_per_thread_statecsB|jjd}|jjd}|jjjd�}|jjjd�}|jjjd�}|dkrtd}n|j�}|dks�|dkr�dd	�}	|	�n|d
kr�dd�}
|
��fd
d�}�dkr�dSd}t|�}
|
jpd}|
jr(|d|
j7}d|j||jf}d||f}�|�}�|�}||jj	kr�|jj
d7_
nd|j_
d|jj
}t|jj
�jd�}||jd�7}|t
j�jd�7}|tjd�7}tj|�j�dd�}|dkrJ�d|||f�}|sl||d||f�}nP|dks�d|jd�kr�d|||d|f}|||�}ndS||j_	d|j||||f}|r�|d|7}|r|d|7}|r |d|7}|r:|d||f7}d |S)!N�realm�nonce�qop�	algorithm�opaqueZMD5zMD5-SESScSs1t|t�r|jd�}tj|�j�S)Nzutf-8)�
isinstancerr�hashlibZmd5�	hexdigest)�xrrr�md5_utf8^sz4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8ZSHAcSs1t|t�r|jd�}tj|�j�S)Nzutf-8)r1rrr2�sha1r3)r4rrr�sha_utf8dsz4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8cs�d||f�S)Nz%s:%sr)�s�d)�	hash_utf8rr�<lambda>jsz4HTTPDigestAuth.build_digest_header.<locals>.<lambda>�/�?z%s:%s:%sz%s:%srz%08xzutf-8��Zauth�,z%s:%s:%s:%s:%sz>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z, algorithm="%s"z
, digest="%s"z , qop="auth", nc=%s, cnonce="%s"z	Digest %s)r"r(�get�upperr�pathZqueryr
rr&r'rr�timeZctime�os�urandomr2r6r3�split)r�method�urlr,r-r.r/r0Z
_algorithmr5r7ZKDZentdigZp_parsedrCZA1ZA2ZHA1ZHA2Zncvaluer8ZcnonceZrespdigZnoncebit�baser)r:r�build_digest_headerPsp			!z"HTTPDigestAuth.build_digest_headercKs|jrd|j_dS)z)Reset num_401_calls counter on redirects.rN)Zis_redirectr"r*)rr�kwargsrrr�handle_redirect�s	zHTTPDigestAuth.handle_redirectcKs\|jjdk	r+|jjj|jj�|jjdd�}d|j�krL|jjdkrL|jjd7_t	j
ddt	j�}t|j
d|d	d��|j_|j|j�|jj�}t|j|j|j�|j|j�|j|j|j�|jd
<|jj||�}|jj|�||_|Sd|j_|S)z:Takes the given response and tries digest-auth, if needed.Nzwww-authenticater$Zdigest�rzdigest �flags�countr)r"r)Zrequest�body�seekrrA�lowerr*�re�compile�
IGNORECASEr�subr(Zcontent�close�copyrZ_cookies�rawZprepare_cookiesrKrHrIZ
connection�send�history�append)rrrLZs_authZpatZprepZ_rrrr�
handle_401�s($$
	zHTTPDigestAuth.handle_401cCs�|j�|jjr5|j|j|j�|jd<y|jj�|j_	Wnt
k
rnd|j_	YnX|jd|j�|jd|j
�d|j_|S)NrZresponser)r+r"r&rKrHrIrrQ�tellr)�AttributeErrorZ
register_hookr^rMr*)rrrrrr�s

zHTTPDigestAuth.__call__N)
rrrrrr+rKrMr^rrrrrr >s
V"r )rrErTrDr2r!�base64r�compatrrZcookiesrZutilsrrZstatus_codesr	ZCONTENT_TYPE_FORM_URLENCODEDZCONTENT_TYPE_MULTI_PARTr�objectrrrr rrrr�<module>s"


Zerion Mini Shell 1.0