
    )Jf&                     ~    d Z ddlZddlmZ  ej        e          Z G d de          Z G d de          Z	ee	gZ
dS )	aP  The credentials classes are used to encapsulate all authentication
information for the :class:`~pika.connection.ConnectionParameters` class.

The :class:`~pika.credentials.PlainCredentials` class returns the properly
formatted username and password to the :class:`~pika.connection.Connection`.

To authenticate with Pika, create a :class:`~pika.credentials.PlainCredentials`
object passing in the username and password and pass it as the credentials
argument value to the :class:`~pika.connection.ConnectionParameters` object.

If you are using :class:`~pika.connection.URLParameters` you do not need a
credentials object, one will automatically be created for you.

If you are looking to implement SSL certificate style authentication, you would
extend the :class:`~pika.credentials.ExternalCredentials` class implementing
the required behavior.

    N   )as_bytesc                   6    e Zd ZdZdZd
dZd Zd Zd Zd Z	d	S )PlainCredentialsa*  A credentials object for the default authentication methodology with
    RabbitMQ.

    If you do not pass in credentials to the ConnectionParameters object, it
    will create credentials for 'guest' with the password of 'guest'.

    If you pass True to erase_on_connect the credentials will not be stored
    in memory after the Connection attempt has been made.

    :param str username: The username to authenticate with
    :param str password: The password to authenticate with
    :param bool erase_on_connect: erase credentials on connect.

    PLAINFc                 0    || _         || _        || _        dS )zCreate a new instance of PlainCredentials

        :param str username: The username to authenticate with
        :param str password: The password to authenticate with
        :param bool erase_on_connect: erase credentials on connect.

        N)usernamepassworderase_on_connect)selfr	   r
   r   s       S/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/pika/credentials.py__init__zPlainCredentials.__init__*   s      !  0    c                     t          |t                    r0| j        |j        k    o| j        |j        k    o| j        |j        k    S t
          S N)
isinstancer   r	   r
   r   NotImplementedr   others     r   __eq__zPlainCredentials.__eq__6   sV    e-.. 	EMU^3 DMU^3D)U-CCE r   c                 R    |                      |          }|t          ur| S t          S r   r   r   r   r   results      r   __ne__zPlainCredentials.__ne__=   ,    U##'':r   c                     t          t          j                  t          |j                                                  vrdS t          j        dt          | j                  z   dz   t          | j                  z   fS )zValidate that this type of authentication is supported

        :param spec.Connection.Start start: Connection.Start method
        :rtype: tuple(str|None, str|None)

        NN    )r   r   TYPE
mechanismssplitr	   r
   r   starts     r   response_forzPlainCredentials.response_forC   st     $)**)**00223 3:!HT]+++e3ht}6M6MMO 	Or   c                 h    | j         r*t                              d           d| _        d| _        dS dS )<Called by Connection when it no longer needs the credentialsz Erasing stored credential valuesN)r   LOGGERinfor	   r
   r   s    r   erase_credentialsz"PlainCredentials.erase_credentialsQ   s<      	!KK:;;; DM DMMM	! 	!r   N)F
__name__
__module____qualname____doc__r    r   r   r   r%   r+    r   r   r   r      sx          D
1 
1 
1 
1    O O O! ! ! ! !r   r   c                   4    e Zd ZdZdZd Zd Zd Zd Zd Z	dS )	ExternalCredentialszThe ExternalCredentials class allows the connection to use EXTERNAL
    authentication, generally with a client SSL certificate.

    EXTERNALc                     d| _         dS )z,Create a new instance of ExternalCredentialsFN)r   r*   s    r   r   zExternalCredentials.__init__`   s     %r   c                 Z    t          |t                    r| j        |j        k    S t          S r   )r   r3   r   r   r   s     r   r   zExternalCredentials.__eq__d   s-    e011 	C(E,BBBr   c                 R    |                      |          }|t          ur| S t          S r   r   r   s      r   r   zExternalCredentials.__ne__i   r   r   c                     t          t          j                  t          |j                                                  vrdS t          j        dfS )zValidate that this type of authentication is supported

        :param spec.Connection.Start start: Connection.Start method
        :rtype: tuple(str or None, str or None)

        r   r   )r   r3   r    r!   r"   r#   s     r   r%   z ExternalCredentials.response_foro   sJ     ',--)**00223 3:"',,r   c                 :    t                               d           dS )r'   z&Not supported by this Credentials typeN)r(   debugr*   s    r   r+   z%ExternalCredentials.erase_credentials{   s    =>>>>>r   Nr,   r1   r   r   r3   r3   Y   sp          D& & &  
  
- 
- 
-? ? ? ? ?r   r3   )r0   loggingcompatr   	getLoggerr-   r(   objectr   r3   VALID_TYPESr1   r   r   <module>r@      s    $       		8	$	$=! =! =! =! =!v =! =! =!@$? $? $? $? $?& $? $? $?P  !45r   