
    (phk@                     6   S r SSKJr  SSKrSSKrSSKr SSKr SSKrSSK	rSSK
Jr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  \R(                  " \R*                  5      \R(                  " S5      :  a  \R,                  R.                  rO\R0                  R.                  r\R2                  " \5      r " S S\R8                  5      r " S S\R<                  5      rS rS r  " S S\5      r!g! \ a    Sr Nf = f! \ a  r\" S\ S35      \eSrCff = f)zTransport adapter for urllib3.    )absolute_importN)versionzError: aS  . The 'google-auth' library requires the extras installed for urllib3 network transport.
Please install the necessary dependencies using pip:
  pip install google-auth[urllib3]

(Note: Using '[urllib3]' ensures the specific dependencies needed for this feature are installed. We recommend running this command in your virtual environment.))_helpers)environment_vars)
exceptions)	transport)service_accountz2.0.0c                   N    \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	Sr
g)		_ResponseC   zsurllib3 transport response adapter.

Args:
    response (urllib3.response.HTTPResponse): The raw urllib3 response.
c                     Xl         g N	_response)selfresponses     P/var/www/html/venv/lib/python3.13/site-packages/google/auth/transport/urllib3.py__init___Response.__init__J   s    !    c                 .    U R                   R                  $ r   )r   statusr   s    r   r   _Response.statusM   s    ~~$$$r   c                 .    U R                   R                  $ r   )r   headersr   s    r   r   _Response.headersQ   s    ~~%%%r   c                 .    U R                   R                  $ r   )r   datar   s    r   r   _Response.dataU   s    ~~"""r   r   N)__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r   __static_attributes__ r   r   r   r   C   sH    " % % & & # #r   r   c                   *    \ rS rSrSrS r SS jrSrg)RequestZ   a  urllib3 request adapter.

This class is used internally for making requests using various transports
in a consistent way. If you use :class:`AuthorizedHttp` you do not need
to construct or use this class directly.

This class can be useful if you want to manually refresh a
:class:`~google.auth.credentials.Credentials` instance::

    import google.auth.transport.urllib3
    import urllib3

    http = urllib3.PoolManager()
    request = google.auth.transport.urllib3.Request(http)

    credentials.refresh(request)

Args:
    http (urllib3.request.RequestMethods): An instance of any urllib3
        class that implements :class:`~urllib3.request.RequestMethods`,
        usually :class:`urllib3.PoolManager`.

.. automethod:: __call__
c                     Xl         g r   http)r   r.   s     r   r   Request.__init__t   s    	r   Nc                 P   Ub  XVS'    [         R                  " [        X!X45        U R                  R                  " X!4X4S.UD6n[         R
                  " [        U5        [        U5      $ ! [        R                  R                   a  n[        R                  " U5      n	XeSnAff = f)a  Make an HTTP request using urllib3.

Args:
    url (str): The URI to be requested.
    method (str): The HTTP method to use for the request. Defaults
        to 'GET'.
    body (bytes): The payload / body in HTTP request.
    headers (Mapping[str, str]): Request headers.
    timeout (Optional[int]): The number of seconds to wait for a
        response from the server. If not specified or if None, the
        urllib3 default timeout will be used.
    kwargs: Additional arguments passed throught to the underlying
        urllib3 :meth:`urlopen` method.

Returns:
    google.auth.transport.Response: The HTTP response.

Raises:
    google.auth.exceptions.TransportError: If any exception occurred.
Ntimeoutbodyr   )r   request_log_LOGGERr.   requestresponse_logr   urllib3r   	HTTPErrorTransportError)
r   urlmethodr3   r   r1   kwargsr   
caught_excnew_excs
             r   __call__Request.__call__w   s    2  '9		*  &tEyy(("&;AH !!'84X&&!!++ 	* //
;G)	*s   A A* *B%B  B%r-   )GETNNN)r!   r"   r#   r$   r%   r   r@   r'   r(   r   r   r*   r*   Z   s    2 CG%*r   r*   c                      [         b(  [        R                  " S[         R                  " 5       S9$ [        R                  " 5       $ )NCERT_REQUIRED)	cert_reqsca_certs)certifir8   PoolManagerwherer(   r   r   _make_default_httprJ      s0    ""_w}}WW""$$r   c                    SSK nSSKJn  SSKnUR                  R
                  R                  5         UR                  R                  R                  5       nUR                  UR                  " 5       S9  UR                  UR                  U5      nUR                  UR                  U 5      nUR                  R!                  U5        UR                  R#                  U5        UR$                  " US9nU$ )a  Create a mutual TLS HTTP connection with the given client cert and key.
See https://github.com/urllib3/urllib3/issues/474#issuecomment-253168415

Args:
    cert (bytes): client certificate in PEM format
    key (bytes): client private key in PEM format

Returns:
    urllib3.PoolManager: Mutual TLS HTTP connection.

Raises:
    ImportError: If certifi or pyOpenSSL is not installed.
    OpenSSL.crypto.Error: If the cert or key is invalid.
r   N)crypto)cafile)ssl_context)rG   OpenSSLrL   urllib3.contrib.pyopensslcontrib	pyopensslinject_into_urllib3utilssl_create_urllib3_contextload_verify_locationsrI   load_privatekeyFILETYPE_PEMload_certificate_ctxuse_certificateuse_privatekeyrH   )	certkeyrG   rL   r8   ctxpkeyx509r.   s	            r   _make_mutual_tls_httprc      s     $OO113
,,


2
2
4CW]]_5!!&"5"5s;D""6#6#6=DHHT"HHD!3/DKr   c                      ^  \ rS rSrSrS\R                  \R                  S4U 4S jjrSS jr	SS jr
S rS rS	 r\S
 5       r\R                   S 5       rSrU =r$ )AuthorizedHttp   a  A urllib3 HTTP class with credentials.

This class is used to perform requests to API endpoints that require
authorization::

    from google.auth.transport.urllib3 import AuthorizedHttp

    authed_http = AuthorizedHttp(credentials)

    response = authed_http.request(
        'GET', 'https://www.googleapis.com/storage/v1/b')

This class implements :class:`urllib3.request.RequestMethods` and can be
used just like any other :class:`urllib3.PoolManager`.

The underlying :meth:`urlopen` implementation handles adding the
credentials' headers to the request and refreshing credentials as needed.

This class also supports mutual TLS via :meth:`configure_mtls_channel`
method. In order to use this method, the `GOOGLE_API_USE_CLIENT_CERTIFICATE`
environment variable must be explicitly set to `true`, otherwise it does
nothing. Assume the environment is set to `true`, the method behaves in the
following manner:
If client_cert_callback is provided, client certificate and private
key are loaded using the callback; if client_cert_callback is None,
application default SSL credentials will be used. Exceptions are raised if
there are problems with the certificate, private key, or the loading process,
so it should be called within a try/except block.

First we set the environment variable to `true`, then create an :class:`AuthorizedHttp`
instance and specify the endpoints::

    regular_endpoint = 'https://pubsub.googleapis.com/v1/projects/{my_project_id}/topics'
    mtls_endpoint = 'https://pubsub.mtls.googleapis.com/v1/projects/{my_project_id}/topics'

    authed_http = AuthorizedHttp(credentials)

Now we can pass a callback to :meth:`configure_mtls_channel`::

    def my_cert_callback():
        # some code to load client cert bytes and private key bytes, both in
        # PEM format.
        some_code_to_load_client_cert_and_key()
        if loaded:
            return cert, key
        raise MyClientCertFailureException()

    # Always call configure_mtls_channel within a try/except block.
    try:
        is_mtls = authed_http.configure_mtls_channel(my_cert_callback)
    except:
        # handle exceptions.

    if is_mtls:
        response = authed_http.request('GET', mtls_endpoint)
    else:
        response = authed_http.request('GET', regular_endpoint)

You can alternatively use application default SSL credentials like this::

    try:
        is_mtls = authed_http.configure_mtls_channel()
    except:
        # handle exceptions.

Args:
    credentials (google.auth.credentials.Credentials): The credentials to
        add to the request.
    http (urllib3.PoolManager): The underlying HTTP object to
        use to make requests. If not specified, a
        :class:`urllib3.PoolManager` instance will be constructed with
        sane defaults.
    refresh_status_codes (Sequence[int]): Which HTTP status codes indicate
        that credentials should be refreshed and the request should be
        retried.
    max_refresh_attempts (int): The maximum number of times to attempt to
        refresh the credentials and retry the request.
    default_host (Optional[str]): A host like "pubsub.googleapis.com".
        This is used when a self-signed JWT is created from service
        account credentials.
Nc                   > Uc  [        5       U l        SU l        OX l        SU l        Xl        X0l        X@l        XPl        [        U R                  5      U l        [        U R                  [        R                  5      (       aG  U R                  R                  U R                  (       a  SR                  U R                  5      OS 5        [        [        U ]C  5         g )NFTzhttps://{}/)rJ   r.   _has_user_provided_httpcredentials_refresh_status_codes_max_refresh_attempts_default_hostr*   _request
isinstancer	   Credentials_create_self_signed_jwtformatsuperre   r   )r   ri   r.   refresh_status_codesmax_refresh_attemptsdefault_host	__class__s         r   r   AuthorizedHttp.__init__  s     <*,DI+0D(I+/D(&%9"%9")  		* d&&(C(CDD44<@<N<N$$T%7%78TX 	nd,.r   c                 V   [         R                  " [        R                  S5      nUS:w  a  g SSKn [        R                  R                  U5      u  pgnU(       a  [        Xx5      U l        O[        5       U l         U R"                  (       a"  SU l        [$        R&                  " S[(        5        U$ ! [
         a  n[        R                  " U5      nXTeSnAff = f! [        R                  [
        UR                  R                   4 a  n[        R                  " U5      nXTeSnAff = f)a  Configures mutual TLS channel using the given client_cert_callback or
application default SSL credentials. The behavior is controlled by
`GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable.
(1) If the environment variable value is `true`, the function returns True
if the channel is mutual TLS and False otherwise. The `http` provided
in the constructor will be overwritten.
(2) If the environment variable is not set or `false`, the function does
nothing and it always return False.

Args:
    client_cert_callback (Optional[Callable[[], (bytes, bytes)]]):
        The optional callback returns the client certificate and private
        key bytes both in PEM format.
        If the callback is None, application default SSL credentials
        will be used.

Returns:
    True if the channel is mutual TLS and False otherwise.

Raises:
    google.auth.exceptions.MutualTLSChannelError: If mutual TLS channel
        creation failed for any reason.
falsetrueFr   Nz1`http` provided in the constructor is overwritten)osgetenvr   !GOOGLE_API_USE_CLIENT_CERTIFICATErO   ImportErrorr   MutualTLSChannelErrorr   _mtls_helperget_client_cert_and_keyrc   r.   rJ   ClientCertErrorrL   Errorrh   warningswarnUserWarning)	r   client_cert_callbackuse_client_certrO   r>   r?   found_cert_keyr^   r_   s	            r   configure_mtls_channel%AuthorizedHttp.configure_mtls_channel:  s   0 ))>>
 f$	*
	*(1(>(>(V(V$)%N# 1$<	.0	 ''+0D(MMC[ 7  	* 66zBG)	* &&NN  
 	*
 !66zBG)	*s4   B2 9C -C 2
C<CC/D(D##D(c                 $   UR                  SS5      nUc  U R                  nUR                  5       nU R                  R	                  U R
                  XU5        U R                  R                  " X4X7S.UD6nUR                  U R                  ;   a~  X`R                  :  ao  [        R                  SUR                  US-   U R                  5        U R                  R                  U R
                  5        U R                  " UU4UUUS-   S.UD6$ U$ )z$Implementation of urllib3's urlopen._credential_refresh_attemptr   r2   z;Refreshing credentials due to a %s response. Attempt %s/%s.   )r3   r   r   )popr   copyri   before_requestrm   r.   urlopenr   rj   rk   r5   inforefresh)	r   r<   r;   r3   r   r=   r   request_headersr   s	            r   r   AuthorizedHttp.urlopenw  s    '-jj1NPQ&R#?llG ",,.''vOT99$$
"
?E
 OOt999+.H.HH LLM+a/**	 $$T]]3 << ,G!,K   r   c                 6    U R                   R                  5       $ Proxy to ``self.http``.)r.   	__enter__r   s    r   r   AuthorizedHttp.__enter__  s    yy""$$r   c                 :    U R                   R                  XU5      $ r   )r.   __exit__)r   exc_typeexc_valexc_tbs       r   r   AuthorizedHttp.__exit__  s    yy!!(V<<r   c                 x    [        U S5      (       a)  U R                  b  U R                  R                  5         g g g )Nr.   )hasattrr.   clearr   s    r   __del__AuthorizedHttp.__del__  s.    4  TYY%:IIOO &; r   c                 .    U R                   R                  $ r   r.   r   r   s    r   r   AuthorizedHttp.headers  s     yy   r   c                 $    XR                   l        g)r   Nr   )r   values     r   r   r     s     "		r   )rl   rh   rk   rj   rm   ri   r.   r   )NN)r!   r"   r#   r$   r%   r   DEFAULT_REFRESH_STATUS_CODESDEFAULT_MAX_REFRESH_ATTEMPTSr   r   r   r   r   r   r&   r   setterr'   __classcell__)rv   s   @r   re   re      sq    Pj &CC&CC/@;z7v%= ! ! ^^" "r   re   )"r%   
__future__r   loggingr{   r   rG   r~   r8   urllib3.exceptions	packagingr   r>   google.authr   r   r   r   google.oauth2r	   parse__version___request_methodsRequestMethodsr6   	getLoggerr!   r5   Responser   r*   rJ   rc   re   r(   r   r   <module>r      s   % &  	 !  ! ( " ! )
==$$%w)??--<<N__33N


H
%#	"" #.B*i B*J%B"^ "Q  G  
	 J		J s(   C2 D  2C=<C= DDD