
    3i              	           d Z ddgZddlZddlmZmZ ddlmZ ddlm	Z	m
Z
mZmZ ddlmZmZ dd	lmZ e	rd
dlmZ dZ G d de      Z edd      	 ddedee   dee   fd       Zy)z!Base Authentication Plugin class.MySQLAuthPluginget_auth_plugin    N)ABCabstractmethod)	lru_cache)TYPE_CHECKINGAnyOptionalType)NotSupportedErrorProgrammingError)logger   )MySQLSocketzmysql.connector.aio.pluginsc            	           e Zd ZdZ	 ddedededdfdZedefd       Zee	defd	              Z
ee	defd
              Ze	dededee   fd       ZdddededefdZe	dddededefd       Zy)r   zAuthorization plugin interface.usernamepasswordssl_enabledreturnNc                 >    |dn|| _         |dn|| _        || _        y)zConstructor.N )	_username	_password_ssl_enabled)selfr   r   r   s       ID:\jyotish\venv\Lib\site-packages\mysql/connector/aio/plugins/__init__.py__init__zMySQLAuthPlugin.__init__3   s(     %-$4b($,$4b("-    c                     | j                   S )z&Signals whether or not SSL is enabled.)r   r   s    r   r   zMySQLAuthPlugin.ssl_enabled>   s        r   c                      y)z'Signals whether or not SSL is required.N r    s    r   requires_sslzMySQLAuthPlugin.requires_sslC       r   c                      y)zPlugin official name.Nr"   r    s    r   namezMySQLAuthPlugin.nameH   r$   r   	auth_datakwargsc                      y)a  Make the client's authorization response.

        Args:
            auth_data: Authorization data.
            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: Client's authorization response.
        Nr"   )r   r'   r(   s      r   auth_responsezMySQLAuthPlugin.auth_responseM   r$   r   sockr   c                    K   t         w)a1  Handles server's `auth more data` response.

        Args:
            sock: Pointer to the socket connection.
            auth_data: Authentication method data (from a packet representing
                       an `auth more data` 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.
        )NotImplementedErrorr   r+   r'   r(   s       r   auth_more_responsez"MySQLAuthPlugin.auth_more_response[   s       "!s   	c                    K   yw)a?  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.
        Nr"   r.   s       r   auth_switch_responsez$MySQLAuthPlugin.auth_switch_responsem   s     s   )F)__name__
__module____qualname____doc__strboolr   propertyr   r   r#   r&   bytesr	   r
   r*   r/   r1   r"   r   r   r   r   0   s   ) "		.	. 	. 		.
 
	. !T ! ! 6d 6  6 $c $  $ u    "!".3"?B"	"$ !.3?B	 r   
   F)maxsizetypedplugin_nameauth_plugin_classr   c                    t         }| r	 t        j                  d|       t        j                  d|        t        j                  d|  |      }|rt        ||      s|j                  }t        j                  d|       t        ||      S t        d|  d	      # t        $ r }t        j                  d|       Y d}~3d}~wt        $ r}t        d|       |d}~ww xY w)
a  Return authentication class based on plugin name

    This function returns the class for the authentication plugin plugin_name.
    The returned class is a subclass of BaseAuthPlugin.

    Args:
        plugin_name (str): Authentication plugin name.
        auth_plugin_class (str): Authentication plugin class name.

    Raises:
        NotSupportedError: When plugin_name is not supported.

    Returns:
        Subclass of `MySQLAuthPlugin`.
    zpackage: %szplugin_name: %s.zAUTHENTICATION_PLUGIN_CLASS: %sz"Requested Module was not found: %sNzInvalid module name: zAuthentication plugin 'z' is not supported)DEFAULT_PLUGINS_PKGr   info	importlibimport_modulehasattrAUTHENTICATION_PLUGIN_CLASSgetattrModuleNotFoundErrorwarning
ValueErrorr   r   )r=   r>   packageplugin_moduleerrs        r   r   r      s    ( "G	KKKw/KK);7%33a}4EwOM$GMCT,U$1$M$M!KK9;LM=*;<<
 5k]BTU
VV	 # 	FNN?EE 	K"%:3%#@AsJ	Ks$   B B 	C#B>>C
CC)N)r5   __all__rC   abcr   r   	functoolsr   typingr   r	   r
   r   mysql.connector.errorsr   r   mysql.connector.loggerr   networkr   rA   r   r6   r   r"   r   r   <module>rU      s   : (/
0  #  5 5 F )%3 Mc M` 2U# (,!W!W}!W 
/!W $!Wr   