ó
ú—7Tc           @   s”   d  Z  y d d l m Z Wn! e k
 r= d d l m Z n Xd d l m Z d d l m Z d d l m	 Z	 e e
 ƒ Z d e	 f d „  ƒ  YZ d S(	   s   
NTLM authenticating pool, contributed by erikcederstran

Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10
iÿÿÿÿ(   t   HTTPSConnection(   t	   getLogger(   t   ntlm(   t   HTTPSConnectionPoolt   NTLMConnectionPoolc           B   s>   e  Z d  Z d Z d „  Z d „  Z d d d e e d „ Z RS(   sQ   
    Implements an NTLM authentication version of an urllib3 connection pool
    t   httpsc         O   sj   t  t |  ƒ j | | Ž  | |  _ | |  _ | j d d ƒ } | d j ƒ  |  _ | d |  _ | |  _	 d S(   sÅ   
        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.
        s   \i   i    N(
   t   superR   t   __init__t   authurlt   rawusert   splitt   uppert   domaint   usert   pw(   t   selfR   R   R   t   argst   kwargst
   user_parts(    (    se   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/_vendor/requests/packages/urllib3/contrib/ntlmpool.pyR   !   s    		c         C   sÄ  |  j  d 7_  t j d |  j  |  j |  j f ƒ i  } d | d <d } d } t d |  j d |  j ƒ } d	 t j |  j	 ƒ | | <t j d
 | ƒ | j
 d |  j d  | ƒ | j ƒ  } t | j ƒ  ƒ } t j d | j | j f ƒ t j d | ƒ t j d | j d ƒ ƒ d  | _ | | j d ƒ } d  } x+ | D]# }	 |	 d  d k r<|	 d } q<q<W| d  k rŒt d | | | f ƒ ‚ n  t j | ƒ \ }
 } t j |
 |  j |  j |  j | ƒ } d	 | | | <t j d
 | ƒ | j
 d |  j d  | ƒ | j ƒ  } t j d | j | j f ƒ t j d t | j ƒ  ƒ ƒ t j d | j ƒ  d  ƒ | j d k rª| j d k r‹t d ƒ ‚ n  t d | j | j f ƒ ‚ n  d  | _ t j d ƒ | S(   Ni   s3   Starting NTLM HTTPS connection no. %d: https://%s%ss
   Keep-Alivet
   Connectiont   Authorizations   www-authenticatet   hostt   ports   NTLM %ss   Request headers: %st   GETs   Response status: %s %ss   Response headers: %ss   Response data: %s [...]id   s   , i   s   NTLM s!   Unexpected %s response header: %siÈ   i‘  s3   Server rejected request: wrong username or passwords   Wrong server response: %s %ss   Connection established(   t   num_connectionst   logt   debugR   R   R    R   R   t   create_NTLM_NEGOTIATE_MESSAGER	   t   requestt   Nonet   getresponset   dictt
   getheaderst   statust   reasont   readt   fpR
   t	   Exceptiont   parse_NTLM_CHALLENGE_MESSAGEt    create_NTLM_AUTHENTICATE_MESSAGER   R   R   (   R   t   headerst
   req_headert   resp_headert   connt   rest   reshdrt   auth_header_valuest   auth_header_valuet   st   ServerChallenget   NegotiateFlagst   auth_msg(    (    se   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/_vendor/requests/packages/urllib3/contrib/ntlmpool.pyt	   _new_conn/   s\    	
				i   c         C   sG   | d  k r i  } n  d | d <t t |  ƒ j | | | | | | | ƒ S(   Ns
   Keep-AliveR   (   R   R   R   t   urlopen(   R   t   methodt   urlt   bodyR(   t   retriest   redirectt   assert_same_host(    (    se   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/_vendor/requests/packages/urllib3/contrib/ntlmpool.pyR5   p   s    	
N(	   t   __name__t
   __module__t   __doc__t   schemeR   R4   R   t   TrueR5   (    (    (    se   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/_vendor/requests/packages/urllib3/contrib/ntlmpool.pyR      s   		A	N(   R>   t   http.clientR    t   ImportErrort   httplibt   loggingR   R   t   urllib3R   R<   R   R   (    (    (    se   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/_vendor/requests/packages/urllib3/contrib/ntlmpool.pyt   <module>   s   