ó †2{Yc@sídZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z dZd Zd „Zd efd „ƒYZd efd„ƒYZdefd„ƒYZdefd„ƒYZdS(s] requests.auth ~~~~~~~~~~~~~ This module contains the authentication handlers for Requests. iÿÿÿÿN(t b64encodei(turlparsetstr(textract_cookies_to_jar(tparse_dict_headers!application/x-www-form-urlencodedsmultipart/form-datacCs0dtd||fjdƒƒjƒjdƒS(sReturns a Basic Auth string.sBasic s%s:%stlatin1(Rtencodetstriptdecode(tusernametpassword((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyt_basic_auth_strstAuthBasecBseZdZd„ZRS(s4Base class that all auth implementations derive fromcCstdƒ‚dS(NsAuth hooks must be callable.(tNotImplementedError(tselftr((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyt__call__"s(t__name__t __module__t__doc__R(((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyR st HTTPBasicAuthcBs eZdZd„Zd„ZRS(s?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS(N(R R (RR R ((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyt__init__(s cCs t|j|jƒ|jd<|S(Nt Authorization(R R R theaders(RR((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyR,s(RRRRR(((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyR&s t HTTPProxyAuthcBseZdZd„ZRS(s=Attaches HTTP Proxy Authentication to a given Request object.cCs t|j|jƒ|jd<|S(NsProxy-Authorization(R R R R(RR((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyR3s(RRRR(((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyR1stHTTPDigestAuthcBs2eZdZd„Zd„Zd„Zd„ZRS(s@Attaches HTTP Digest Authentication to the given Request object.cCs:||_||_d|_d|_i|_d|_dS(Nti(R R t last_noncet nonce_counttchaltNonetpos(RR R ((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyR:s      cs'|jd}|jd}|jjdƒ}|jjdƒ}|jjdƒ}|dkred}n |jƒ}|dks‰|dkr›d„} | ‰n|d kr¹d „} | ‰n‡fd †} ˆdkrØdSd} t|ƒ} | j}| jr|d | j7}nd |j||jf}d||f}ˆ|ƒ}ˆ|ƒ}||j krr|j d7_ n d|_ d|j }t |j ƒj dƒ}||j dƒ7}|t jƒj dƒ7}|tjdƒ7}tj|ƒjƒd }d|||||f}|dkr9ˆd |||fƒ}n|dkra| |d||fƒ}n7|dks‚d|jdƒkr”| ||ƒ}ndS||_ d|j||||f}|rÔ|d|7}n|rë|d|7}n| r|d| 7}n|r|d||f7}nd|S(Ntrealmtnoncetqopt algorithmtopaquetMD5sMD5-SESScSs4t|tƒr!|jdƒ}ntj|ƒjƒS(Nsutf-8(t isinstanceRRthashlibtmd5t hexdigest(tx((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pytmd5_utf8PstSHAcSs4t|tƒr!|jdƒ}ntj|ƒjƒS(Nsutf-8(R&RRR'tsha1R)(R*((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pytsha_utf8Vscsˆd||fƒS(Ns%s:%s((tstd(t hash_utf8(sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyt\st?s%s:%s:%ss%s:%sis%08xsutf-8iis%s:%s:%s:%s:%stautht,s>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"s , opaque="%s"s, algorithm="%s"s , digest="%s"s , qop="auth", nc=%s, cnonce="%s"s Digest %s(RtgetRtupperRtpathtqueryR R RRRRttimetctimetosturandomR'R-R)tsplit(RtmethodturlR R!R"R#R$t _algorithmR+R.tKDtentdigtp_parsedR8tA1tA2tHA1tHA2tncvalueR/tcnoncetnoncebittrespdigtbase((R1sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pytbuild_digest_headerBsn                    ! cKsk|jd k r(|jjj|jƒnt|ddƒ}|jjddƒ}d|jƒkrW|dkrWt |d|dƒt j ddt j ƒ}t |jd|d dƒƒ|_|j|jjƒ|jjƒ}t|j|j|jƒ|j|jƒ|j|j|jƒ|jd <|jj||}|jj|ƒ||_|St |ddƒ|S( s:Takes the given response and tries digest-auth, if needed.t num_401_callsiswww-authenticateRtdigestisdigest tflagstcountRN(RRtrequesttbodytseektgetattrRR6tlowertsetattrtretcompilet IGNORECASERtsubRtcontenttrawt release_conntcopyRt_cookiestprepare_cookiesRNR?R@t connectiontsendthistorytappend(RRtkwargsROts_authtpattprept_r((sJ/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/requests/auth.pyt handle_401•s*!  cCsl|jr+|j|j|jƒ|jds