
    oh,                        d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d d      Z	 G d	 d
e	      Z
 G d de	      Z G d de	      Z G d de      Z G d de      Z edddg      Z G d de      Z G d de      Z G d d      Zy)z
Modern, adaptable authentication machinery.

Replaces certain parts of `.SSHClient`. For a concrete implementation, see the
``OpenSSHAuthStrategy`` class in `Fabric <https://fabfile.org>`_.
    )
namedtuple   )AgentKey)
get_logger)AuthenticationExceptionc                   (    e Zd ZdZd Zd Zd Zd Zy)
AuthSourcez
    Some SSH authentication source, such as a password, private key, or agent.

    See subclasses in this module for concrete implementations.

    All implementations must accept at least a ``username`` (``str``) kwarg.
    c                     || _         y Nusername)selfr   s     h/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/paramiko/auth_strategy.py__init__zAuthSource.__init__   s	         c                     |j                         D cg c]  \  }}| d| }}}dj                  |      }| j                  j                   d| dS c c}}w )N=z, ())itemsjoin	__class____name__)r   kwargskvpairsjoineds         r   _reprzAuthSource._repr   s\     +1,,.9$!QA3au995!..))*!F8155 :s   Ac                 "    | j                         S r   )r   r   s    r   __repr__zAuthSource.__repr__"   s    zz|r   c                     t         )z)
        Perform authentication.
        NotImplementedErrorr   	transports     r   authenticatezAuthSource.authenticate%   s
     "!r   N)r   
__module____qualname____doc__r   r   r"   r(    r   r   r	   r	      s    !6"r   r	   c                       e Zd ZdZd Zy)NoneAuthzS
    Auth type "none", ie https://www.rfc-editor.org/rfc/rfc4252#section-5.2 .
    c                 8    |j                  | j                        S r   )	auth_noner   r&   s     r   r(   zNoneAuth.authenticate1   s    ""4==11r   Nr   r)   r*   r+   r(   r,   r   r   r.   r.   ,   s    2r   r.   c                   2     e Zd ZdZ fdZ fdZd Z xZS )Passworda  
    Password authentication.

    :param callable password_getter:
        A lazy callable that should return a `str` password value at
        authentication time, such as a `functools.partial` wrapping
        `getpass.getpass`, an API call to a secrets store, or similar.

        If you already know the password at instantiation time, you should
        simply use something like ``lambda: "my literal"`` (for a literal, but
        also, shame on you!) or ``lambda: variable_name`` (for something stored
        in a variable).
    c                 4    t         |   |       || _        y Nr   )superr   password_getter)r   r   r7   r   s      r   r   zPassword.__init__D   s    (+.r   c                 8    t         |   | j                        S )N)user)r6   r   r   )r   r   s    r   r"   zPassword.__repr__H   s     w}$--}00r   c                 Z    | j                         }|j                  | j                  |      S r   )r7   auth_passwordr   )r   r'   passwords      r   r(   zPassword.authenticateM   s)     '')&&t}}h??r   )r   r)   r*   r+   r   r"   r(   __classcell__r   s   @r   r3   r3   5   s    /1
@r   r3   c                       e Zd ZdZd Zy)
PrivateKeya  
    Essentially a mixin for private keys.

    Knows how to auth, but leaves key material discovery/loading/decryption to
    subclasses.

    Subclasses **must** ensure that they've set ``self.pkey`` to a decrypted
    `.PKey` instance before calling ``super().authenticate``; typically
    either in their ``__init__``, or in an overridden ``authenticate`` prior to
    its `super` call.
    c                 N    |j                  | j                  | j                        S r   )auth_publickeyr   pkeyr&   s     r   r(   zPrivateKey.authenticatee   s    ''tyyAAr   Nr1   r,   r   r   r@   r@   X   s    
Br   r@   c                   ,     e Zd ZdZ fdZ fdZ xZS )InMemoryPrivateKeyz1
    An in-memory, decrypted `.PKey` object.
    c                 4    t         |   |       || _        y r5   )r6   r   rC   )r   r   rC   r   s      r   r   zInMemoryPrivateKey.__init__n   s    (+	r   c                 z    t         |   | j                        }t        | j                  t              r|dz  }|S )N)rC   z [agent])r6   r   rC   
isinstancer   )r   repr   s     r   r"   zInMemoryPrivateKey.__repr__s   s6     gmm+dii*:C
r   r   r)   r*   r+   r   r"   r=   r>   s   @r   rE   rE   i   s    
 r   rE   c                   (     e Zd ZdZ fdZd Z xZS )OnDiskPrivateKeya  
    Some on-disk private key that needs opening and possibly decrypting.

    :param str source:
        String tracking where this key's path was specified; should be one of
        ``"ssh-config"``, ``"python-config"``, or ``"implicit-home"``.
    :param Path path:
        The filesystem path this key was loaded from.
    :param PKey pkey:
        The `PKey` object this auth source uses/represents.
    c                 x    t         |   |       || _        d}||vrt        d|      || _        || _        y )Nr   )z
ssh-configzpython-configzimplicit-homez source argument must be one of: )r6   r   source
ValueErrorpathrC   )r   r   rN   rP   rC   allowedr   s         r   r   zOnDiskPrivateKey.__init__   sH    (+B ?{KLL		r   c                 x    | j                  | j                  | j                  t        | j                              S )N)keyrN   rP   )r   rC   rN   strrP   r!   s    r   r"   zOnDiskPrivateKey.__repr__   s/    zz		$++C		N  
 	
r   rJ   r>   s   @r   rL   rL   |   s    

r   rL   SourceResultrN   resultc                   (     e Zd ZdZ fdZd Z xZS )
AuthResulta  
    Represents a partial or complete SSH authentication attempt.

    This class conceptually extends `AuthStrategy` by pairing the former's
    authentication **sources** with the **results** of trying to authenticate
    with them.

    `AuthResult` is a (subclass of) `list` of `namedtuple`, which are of the
    form ``namedtuple('SourceResult', 'source', 'result')`` (where the
    ``source`` member is an `AuthSource` and the ``result`` member is either a
    return value from the relevant `.Transport` method, or an exception
    object).

    .. note::
        Transport auth method results are always themselves a ``list`` of "next
        allowable authentication methods".

        In the simple case of "you just authenticated successfully", it's an
        empty list; if your auth was rejected but you're allowed to try again,
        it will be a list of string method names like ``pubkey`` or
        ``password``.

        The ``__str__`` of this class represents the empty-list scenario as the
        word ``success``, which should make reading the result of an
        authentication session more obvious to humans.

    Instances also have a `strategy` attribute referencing the `AuthStrategy`
    which was attempted.
    c                 2    || _         t        |   |i | y r   )strategyr6   r   )r   rZ   argsr   r   s       r   r   zAuthResult.__init__   s     $)&)r   c                 2    dj                  d | D              S )N
c              3   Z   K   | ]#  }|j                    d |j                  xs d  % yw)z -> successN)rN   rV   ).0xs     r   	<genexpr>z%AuthResult.__str__.<locals>.<genexpr>   s.      
9:qxxjQXX234
s   )+)r   r!   s    r   __str__zAuthResult.__str__   s"    
 yy 
>B
 
 	
r   )r   r)   r*   r+   r   rc   r=   r>   s   @r   rX   rX      s    <*
r   rX   c                       e Zd ZdZd Zd Zy)AuthFailurea  
    Basic exception wrapping an `AuthResult` indicating overall auth failure.

    Note that `AuthFailure` descends from `AuthenticationException` but is
    generally "higher level"; the latter is now only raised by individual
    `AuthSource` attempts and should typically only be seen by users when
    encapsulated in this class. It subclasses `AuthenticationException`
    primarily for backwards compatibility reasons.
    c                     || _         y r   rV   )r   rV   s     r   r   zAuthFailure.__init__   s	    r   c                 2    dt        | j                        z   S )Nr]   )rT   rV   r!   s    r   rc   zAuthFailure.__str__   s    c$++&&&r   N)r   r)   r*   r+   r   rc   r,   r   r   re   re      s    'r   re   c                   "    e Zd ZdZd Zd Zd Zy)AuthStrategya   
    This class represents one or more attempts to auth with an SSH server.

    By default, subclasses must at least accept an ``ssh_config``
    (`.SSHConfig`) keyword argument, but may opt to accept more as needed for
    their particular strategy.
    c                 :    || _         t        t              | _        y r   )
ssh_configr   r   log)r   rl   s     r   r   zAuthStrategy.__init__   s     %h'r   c                     t         )a[  
        Generator yielding `AuthSource` instances, in the order to try.

        This is the primary override point for subclasses: you figure out what
        sources you need, and ``yield`` them.

        Subclasses _of_ subclasses may find themselves wanting to do things
        like filtering or discarding around a call to `super`.
        r$   r!   s    r   get_sourceszAuthStrategy.get_sources   s
     "!r   c                    d}t        |       }| j                         D ]S  }| j                  j                  d|        	 |j	                  |      }d}|j                  t        ||             |sS n |st        |      |S # t
        $ rC}|}|j                  j                  }| j                  j                  d| d|        Y d}~xd}~ww xY w)	z
        Handles attempting `AuthSource` instances yielded from `get_sources`.

        You *normally* won't need to override this, but it's an option for
        advanced users.
        F)rZ   zTrying TzAuthentication via z failed with Nrg   )rX   ro   rm   debugr(   	Exceptionr   r   infoappendrU   re   )r   r'   	succeededoverall_resultrN   rV   esource_classs           r   r(   zAuthStrategy.authenticate  s     	#T2 &&( 	FHHNNWVH-.,,Y7 	" !!,vv">?/	4 ^44)    !{{33)&|nM s   B	C9CCN)r   r)   r*   r+   r   ro   r(   r,   r   r   rj   rj      s    (
"+r   rj   N)r+   collectionsr   agentr   utilr   ssh_exceptionr   r	   r.   r3   r@   rE   rL   rU   listrX   re   rj   r,   r   r   <module>r~      s    #   2" ":2z 2@z @FB B" &
z 
B .8X*>?*
 *
\') '$G Gr   