3 nf·\kã@s\dZddlmZddlmZddlmZddlmZddlm Z ee ƒZ Gdd „d eƒZ d S) z NTLM authenticating pool, contributed by erikcederstran Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10 é)Úabsolute_import)Ú getLogger)Úntlmé)ÚHTTPSConnectionPool)ÚHTTPSConnectioncs:eZdZdZdZ‡fdd„Zdd„Zd ‡fd d „ Z‡ZS) ÚNTLMConnectionPoolzQ Implements an NTLM authentication version of an urllib3 connection pool ZhttpscsLtt|ƒj||Ž||_||_|jddƒ}|djƒ|_|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__©ú/usr/lib/python3.6/ntlmpool.pyr s  zNTLMConnectionPool.__init__c Csø|jd7_tjd|j|j|jƒddi}d}d}t|j|jd�}dtj|j ƒ||<tjd |ƒ|j d |jd|ƒ|j ƒ}t |j ƒƒ}tjd |j|jƒtjd |ƒtjd |jdƒƒd|_||jdƒ}d}x(|D] } | dd…dkrØ| dd…}qØW|dk�rtd|||fƒ‚tj|ƒ\} } tj| |j|j|j| ƒ} d| ||<tjd |ƒ|j d |jd|ƒ|j ƒ}tjd |j|jƒtjd t |j ƒƒƒtjd |jƒdd…ƒ|jdk�rä|jdk�rÐtdƒ‚td|j|jfƒ‚d|_tjdƒ|S)Nr z3Starting NTLM HTTPS connection no. %d: https://%s%sÚ Connectionz Keep-AliveZ Authorizationzwww-authenticate)ÚhostÚportzNTLM %szRequest headers: %sZGETzResponse 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)Znum_connectionsÚlogÚdebugrr rrrZcreate_NTLM_NEGOTIATE_MESSAGErZrequestZ getresponseÚdictZ getheadersZstatusÚreasonÚreadÚfprÚ ExceptionZparse_NTLM_CHALLENGE_MESSAGEZ create_NTLM_AUTHENTICATE_MESSAGErrr) rÚheadersZ req_headerZ resp_headerZconnÚresZreshdrZauth_header_valuesZauth_header_valueÚsZServerChallengeZNegotiateFlagsZauth_msgrrrÚ _new_conn'sZ          zNTLMConnectionPool._new_connNéTcs0|dkr i}d|d<tt|ƒj|||||||ƒS)Nz Keep-Aliver)r rÚurlopen)rÚmethodZurlZbodyr'ZretriesZredirectZassert_same_host)rrrr,gszNTLMConnectionPool.urlopen)NNr+TT) Ú__name__Ú __module__Ú __qualname__Ú__doc__Úschemer r*r,Ú __classcell__rr)rrrs  @rN) r1Z __future__rZloggingrrÚrZpackages.six.moves.http_clientrr.r rrrrrÚs