3 $c@spdZddlmZddlZddlmZddlmZddlmZddl m Z ej d e ee ZGd d d eZdS) 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.cs:eZdZdZdZfddZddZd fd d ZZS) NTLMConnectionPoolzQ Implements an NTLM authentication version of an urllib3 connection pool httpscsLtt|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__authurlrawusersplitupperdomainuserpw)selfrrrargskwargsZ user_parts) __class__?/tmp/pip-target-ezim9f7s/lib/python/urllib3/contrib/ntlmpool.pyr "s  zNTLMConnectionPool.__init__c Cs|jd7_tjd|j|j|jddi}d}d}t|j|jd}dtj|j ||<tjd ||j d |jd||j }t |j }tjd |j|jtjd |tjd |jdd|_||jd}d}x(|D] } | dddkr| dd}qW|dkrtd|||ftj|\} } tj| |j|j|j| } d| ||<tjd ||j d |jd||j }tjd |j|jtjd t |j tjd |jdd|jdkr|jdkrtdtd|j|jfd|_tjd|S)Nr z3Starting NTLM HTTPS connection no. %d: https://%s%s Connectionz Keep-Alive Authorizationzwww-authenticate)hostportzNTLM %szRequest headers: %sGETzResponse status: %s %szResponse headers: %szResponse data: %s [...]dz, zNTLM z!Unexpected %s response header: %siz3Server rejected request: wrong username or passwordzWrong server response: %s %szConnection established)num_connectionslogdebugrrrrrZcreate_NTLM_NEGOTIATE_MESSAGErrequest getresponsedictheadersstatusreasonreadfpr ExceptionZparse_NTLM_CHALLENGE_MESSAGEZ create_NTLM_AUTHENTICATE_MESSAGErrr) rr)Z req_headerZ resp_headerconnresZreshdrZauth_header_valuesZauth_header_valuesZServerChallengeZNegotiateFlagsZauth_msgrrr _new_conn0s\           zNTLMConnectionPool._new_connNTcs0|dkr i}d|d<tt|j|||||||S)Nz Keep-Aliver)r rurlopen)rmethodurlbodyr)retriesredirectassert_same_host)rrrr4ss  zNTLMConnectionPool.urlopen)NNr3TT) __name__ __module__ __qualname____doc__schemer r2r4 __classcell__rr)rrrs Gr)r> __future__rwarningsloggingrrrZpackages.six.moves.http_clientrwarnDeprecationWarningr;r$rrrrrs