a
    lJh                     @   s   d 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rldd	lmZ d
ZG dd deZeddddee
e ee dddZdS )z!Base Authentication Plugin class.    N)ABCabstractmethod)	lru_cache)TYPE_CHECKINGAnyOptionalType   )NotSupportedErrorProgrammingError)logger)MySQLSocketzmysql.connector.pluginsc                   @   s   e Zd ZdZdeeeddddZeeddd	Zee	edd
dZ
ee	edddZe	eeee dddZdeeedddZe	deeedddZdS )MySQLAuthPluginzAuthorization plugin interface.FN)usernamepasswordssl_enabledreturnc                 C   s.   |du rdn|| _ |du rdn|| _|| _dS )zConstructor.N )Z	_usernameZ	_password_ssl_enabled)selfr   r   r    r   R/var/www/shaz/venv/lib/python3.9/site-packages/mysql/connector/plugins/__init__.py__init__1   s    zMySQLAuthPlugin.__init__)r   c                 C   s   | j S )z&Signals whether or not SSL is enabled.)r   r   r   r   r   r   <   s    zMySQLAuthPlugin.ssl_enabledc                 C   s   dS )z'Signals whether or not SSL is required.Nr   r   r   r   r   requires_sslA   s    zMySQLAuthPlugin.requires_sslc                 C   s   dS )zPlugin official name.Nr   r   r   r   r   nameF   s    zMySQLAuthPlugin.name)	auth_datakwargsr   c                 K   s   dS )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   r   r   r   auth_responseK   s    zMySQLAuthPlugin.auth_responser   )sockr   r   r   c                 K   s   t dS )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.
        N)NotImplementedErrorr   r   r   r   r   r   r   auth_more_responseY   s    z"MySQLAuthPlugin.auth_more_responsec                 K   s   dS )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!   r   r   r   auth_switch_responsek   s    z$MySQLAuthPlugin.auth_switch_response)F)__name__
__module____qualname____doc__strboolr   propertyr   r   r   r   bytesr   r   r   r"   r#   r   r   r   r   r   .   s2    r   
   F)maxsizetyped)plugin_nameauth_plugin_classr   c              
   C   s   t }| rzVtd| td|  td|  |}|rBt||sH|j}td| t||W S  ty } zt	d| W Y d}~n<d}~0  t
y } ztd| |W Y d}~n
d}~0 0 td|  d	dS )
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hasattrZAUTHENTICATION_PLUGIN_CLASSgetattrModuleNotFoundErrorwarning
ValueErrorr   r
   )r/   r0   packageZplugin_moduleerrr   r   r   get_auth_plugin~   s     &r=   )N)r'   r4   abcr   r   	functoolsr   typingr   r   r   r   errorsr
   r   r   networkr   r2   r   r(   r=   r   r   r   r   <module>   s"   P
 