o âÄd°ã@spdZddlmZddlZddlmZddlmZddlmZddl m Z e  d e ¡ee ƒZGd d „d eƒZdS) z NTLM authenticating pool, contributed by erikcederstran Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10 é)Úabsolute_importN)Ú getLogger)Úntlmé)ÚHTTPSConnectionPool)ÚHTTPSConnectiona#The 'urllib3.contrib.ntlmpool' module is deprecated and will be removed in urllib3 v2.0 release, urllib3 is not able to support it properly due to reasons listed in issue: https://github.com/urllib3/urllib3/issues/2282. If you are a user of this module please comment in the mentioned issue.csDeZdZdZdZ‡fdd„Zdd„Z    d ‡fd d „ Z‡ZS) ÚNTLMConnectionPoolzQ Implements an NTLM authentication version of an urllib3 connection pool ÚhttpscsPtt|ƒj|i|¤Ž||_||_| dd¡}|d ¡|_|d|_||_ dS)zÅ authurl is a random URL on the server that is protected by NTLM. user is the Windows user, probably in the DOMAIN\username format. pw is the password for the user. ú\érN) ÚsuperrÚ__init__ÚauthurlÚrawuserÚsplitÚupperÚdomainÚuserÚpw)ÚselfrrrÚargsÚkwargsZ user_parts©Ú __class__©ús/private/var/folders/v1/_jykv66s6qd26_69j1njbrl80000gr/T/pip-target-p1gutpg6/lib/python/urllib3/contrib/ntlmpool.pyr "s   zNTLMConnectionPool.__init__c Csê|jd7_t d|j|j|j¡ddi}d}d}t|j|jd}dt |j ¡||<t d |¡|  d |jd|¡|  ¡}t |j ƒ}t d |j|j¡t d |¡t d | d¡¡d|_|| d¡}d}|D]} | dd…dkrz| dd…}qj|dur‰td|||fƒ‚t |¡\} } t | |j|j|j| ¡} d| ||<t d |¡|  d |jd|¡|  ¡}t d |j|j¡t d t |j ƒ¡t d | ¡dd…¡|jdkrë|jdkrátdƒ‚td|j|jfƒ‚d|_t d¡|S)Nr z3Starting NTLM HTTPS connection no. %d: https://%s%sÚ Connectionú Keep-AliveÚ Authorizationzwww-authenticate)ÚhostÚportzNTLM %szRequest headers: %sÚGETzResponse status: %s %szResponse headers: %szResponse data: %s [...]édz, ézNTLM z!Unexpected %s response header: %séÈi‘z3Server rejected request: wrong username or passwordzWrong server response: %s %szConnection established)Únum_connectionsÚlogÚdebugrrrr rZcreate_NTLM_NEGOTIATE_MESSAGErÚrequestÚ getresponseÚdictÚheadersÚstatusÚreasonÚreadÚfprÚ ExceptionZparse_NTLM_CHALLENGE_MESSAGEZ create_NTLM_AUTHENTICATE_MESSAGErrr) rr+Z req_headerZ resp_headerÚconnÚresZreshdrZauth_header_valuesZauth_header_valueÚsZServerChallengeZNegotiateFlagsZauth_msgrrrÚ _new_conn0shü ÿ    €ÿÿÿ     zNTLMConnectionPool._new_connNéTc s0|duri}d|d<tt|ƒ |||||||¡S)Nrr)r rÚurlopen)rÚmethodÚurlÚbodyr+ÚretriesÚredirectÚassert_same_hostrrrr6ss   ÿzNTLMConnectionPool.urlopen)NNr5TT) Ú__name__Ú __module__Ú __qualname__Ú__doc__Úschemer r4r6Ú __classcell__rrrrrs Gør)r@Ú __future__rÚwarningsÚloggingrrÚrZpackages.six.moves.http_clientrÚwarnÚDeprecationWarningr=r&rrrrrÚs     û