3

Z'íc°ã@spdZddlmZddlZddlmZddlmZddlmZddl	m
Z
ejd	eƒee
ƒZGd
d„deƒ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.cs:eZdZdZdZ‡fdd„Zdd„Zd‡fd
d„	Z‡ZS)
Ú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__ÚauthurlÚrawuserÚsplitÚupperÚdomainÚuserÚpw)ÚselfrrrÚargsÚkwargsZ
user_parts)Ú	__class__©ú;/tmp/pip-build-gk9425m9/urllib3/urllib3/contrib/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)Nrz3Starting NTLM HTTPS connection no. %d: https://%s%sÚ
Connectionz
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ÚdebugrrrrrZcreate_NTLM_NEGOTIATE_MESSAGErÚrequestÚgetresponseÚdictÚheadersÚstatusÚreasonÚreadÚfprÚ	ExceptionZparse_NTLM_CHALLENGE_MESSAGEZ create_NTLM_AUTHENTICATE_MESSAGErrr)
rr)Z
req_headerZresp_headerÚconnÚresZreshdrZauth_header_valuesZauth_header_valueÚsZServerChallengeZNegotiateFlagsZauth_msgrrrÚ	_new_conn0s\




zNTLMConnectionPool._new_connNéTcs0|dkri}d|d<tt|ƒj|||||||ƒS)Nz
Keep-Aliver)rrÚurlopen)rÚmethodÚurlÚbodyr)ÚretriesÚredirectÚassert_same_host)rrrr4ss


zNTLMConnectionPool.urlopen)NNr3TT)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úschemer
r2r4Ú
__classcell__rr)rrrsGr)r>Ú
__future__rÚwarningsÚloggingrrÚrZpackages.six.moves.http_clientrÚwarnÚDeprecationWarningr;r$rrrrrÚ<module>s