
    DhW                     j    d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
 erddlmZ d	Z G d
 d	e
      Zy)z%Clear Password Authentication Plugin.    )TYPE_CHECKINGAnyOptional)errors)logger   )MySQLAuthPlugin   )MySQLSocketMySQLClearPasswordAuthPluginc                   z    e Zd ZdZdefdZedefd       Zede	fd       Z
dededee   fdZd	d
dededefdZy)r   zAClass implementing the MySQL Clear Password authentication pluginreturnc                 <    | j                   j                         dz   S )znPrepare and return password as as clear text.

        Returns:
            bytes: Prepared password.
            )	_passwordencodeselfs    C:\Users\Erick Rodrigues\AppData\Local\Programs\Python\Python312\Lib\site-packages\mysql/connector/aio/plugins/mysql_clear_password.py_prepare_passwordz.MySQLClearPasswordAuthPlugin._prepare_password/   s     ~~$$&00    c                      y)zPlugin official name.mysql_clear_password r   s    r   namez!MySQLClearPasswordAuthPlugin.name7   s     &r   c                      y)z'Signals whether or not SSL is required.Fr   r   s    r   requires_sslz)MySQLClearPasswordAuthPlugin.requires_ssl<   s     r   	auth_datakwargsc                     | j                   r.| j                  s"t        j                  | j                   d      | j                         S )zReturn the prepared password to send to MySQL.

        Raises:
            InterfaceError: When SSL is required by not enabled.

        Returns:
            str: The prepared password.
        z requires SSL)r   _ssl_enabledr   InterfaceErrorr   r   )r   r   r   s      r   auth_responsez*MySQLClearPasswordAuthPlugin.auth_responseA   s@     T%6%6''499+](CDD%%''r   sockr   c                 J  K    | j                   |fi |}|t        j                  d      t        j                  d|t        |             |j                  |       d{    t        |j                          d{         }t        j                  d|       |S 7 =7 "w)aS  Handles server's `auth switch request` response.

        Args:
            sock: Pointer to the socket connection.
            auth_data: Plugin provided data (extracted from a packet
                       representing an `auth switch request` response).
            kwargs: Custom configuration to be passed to the auth plugin
                    when invoked. The parameters defined here will override the ones
                    defined in the auth plugin itself.

        Returns:
            packet: Last server's response after back-and-forth
                    communication.
        NzGot a NULL auth responsez# request: %s size: %sz# server response packet: %s)	r#   r   r"   r   debuglenwritebytesread)r   r$   r   r   responsepkts         r   auth_switch_responsez1MySQLClearPasswordAuthPlugin.auth_switch_responseN   s     " &4%%i:6:''(BCC-xXGjj"""$))+%&3S9
 	#%s$   AB#!B"B#>B!?!B#!B#N)__name__
__module____qualname____doc__r)   r   propertystrr   boolr   r   r   r#   r-   r   r   r   r   r   ,   s    K15 1 &c & & d  (u ( ( (!.3?B	r   N)r1   typingr   r   r   mysql.connectorr   mysql.connector.loggerr    r	   networkr   AUTHENTICATION_PLUGIN_CLASSr   r   r   r   <module>r;      s1   : , / / " ) %< =? =r   