
    )h                         d Z ddlmZ ddlZddlmZ ddlmZ ddlmZ ddl	m
Z
  ej                  d	e        ee      Z G d
 de      Zy)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.c                   B     e Zd ZdZdZ fdZd Z	 	 	 	 	 d fd	Z xZS )NTLMConnectionPoolzQ
    Implements an NTLM authentication version of an urllib3 connection pool
    httpsc                     t        t        | 
  |i | || _        || _        |j                  dd      }|d   j                         | _        |d   | _        || _	        y)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.
        \   r   N)
superr
   __init__authurlrawusersplitupperdomainuserpw)selfr   r   r   argskwargs
user_parts	__class__s          W/var/www/html/venv/lib/python3.12/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.pyr   zNTLMConnectionPool.__init__"   s^     	 $0$A&AZZa(
 m))+qM	    c                 F   | xj                   dz  c_         t        j                  d| j                   | j                  | j                         ddi}d}d}t        | j                  | j                        }dt        j                  | j                        z  ||<   t        j                  d	|       |j                  d
| j                  d |       |j                         }t        |j                        }t        j                  d|j                  |j                         t        j                  d|       t        j                  d|j!                  d             d |_        ||   j%                  d      }d }|D ]  }	|	d d dk(  s|	dd  } |t'        d|d||         t        j(                  |      \  }
}t        j*                  |
| j,                  | j.                  | j0                  |      }d|z  ||<   t        j                  d	|       |j                  d
| j                  d |       |j                         }t        j                  d|j                  |j                         t        j                  dt        |j                               t        j                  d|j!                         d d        |j                  dk7  r?|j                  dk(  rt'        d      t'        d|j                  d|j                        d |_        t        j                  d       |S )Nr   z3Starting NTLM HTTPS connection no. %d: https://%s%s
Connection
Keep-AliveAuthorizationzwww-authenticate)hostportzNTLM %szRequest headers: %sGETzResponse status: %s %szResponse headers: %szResponse data: %s [...]d   z,    zNTLM zUnexpected z response header:    i  z3Server rejected request: wrong username or passwordzWrong server response:  zConnection established)num_connectionslogdebugr#   r   r   r$   r   create_NTLM_NEGOTIATE_MESSAGEr   requestgetresponsedictheadersstatusreasonreadfpr   	Exceptionparse_NTLM_CHALLENGE_MESSAGE create_NTLM_AUTHENTICATE_MESSAGEr   r   r   )r   r1   
req_headerresp_headerconnresreshdrauth_header_valuesauth_header_valuesServerChallengeNegotiateFlagsauth_msgs                r   	_new_connzNTLMConnectionPool._new_conn0   s    	!		A  IILL		
  .$
(DIIDII> ($*L*LLL+
 

 			'1UDLL$8 ckk"		*CJJ

C		(&1		+SXXc];  $K066t< # 	*A!u$%abE!	* $7BF;DWX 
 +/*K*K+
' 88TYYTWWn
 ((2
		'1UDLL$8 		*CJJ

C		($s{{*;<		+SXXZ-=>::zzS  UVVcjj#**UVV		*+r   c           	      H    |i }d|d<   t         t        |   |||||||      S )Nr!   r    )r   r
   urlopen)	r   methodurlbodyr1   retriesredirectassert_same_hostr   s	           r   rF   zNTLMConnectionPool.urlopens   s>     ?G ,'6Cw;K
 	
r   )NN   TT)	__name__
__module____qualname____doc__schemer   rD   rF   __classcell__)r   s   @r   r
   r
      s6     FAN 
 
r   r
   )rQ   
__future__r   warningsloggingr   r    r   packages.six.moves.http_clientr   warnDeprecationWarningrN   r+   r
    r   r   <module>r\      sR   
 '    " < N  g
, g
r   