§
    HŠtj}'  ã                   ó<  — d Z ddlZddlZ ej        e¦  «        ZddlmZ ddlm	Z	m
Z
 ddlmZmZmZ ddlmc mZ g d¢Z G d„ dej        j        ej        ¦  «        Z ed	¦  «        Zd
Z G d„ dej        j        ej        ¦  «        Z G d„ dej        ¦  «        ZdS )z.passlib.handlers.misc - misc generic handlers
é    N)Úwarn)Úto_native_strÚstr_consteq)ÚunicodeÚuÚunicode_or_bytes_types)Úunix_disabledÚunix_fallbackÚ	plaintextc                   ó`   ‡ — e Zd ZdZd ZdZed„ ¦   «         Zdˆ fd„	Zd„ Z	edd„¦   «         Z
ˆ xZS )	r
   a…  This class provides the fallback behavior for unix shadow files, and follows the :ref:`password-hash-api`.

    This class does not implement a hash, but instead provides fallback
    behavior as found in /etc/shadow on most unix variants.
    If used, should be the last scheme in the context.

    * this class will positively identify all hash strings.
    * for security, passwords will always hash to ``!``.
    * it rejects all passwords if the hash is NOT an empty string (``!`` or ``*`` are frequently used).
    * by default it rejects all passwords if the hash is an empty string,
      but if ``enable_wildcard=True`` is passed to verify(),
      all passwords will be allowed through if the hash is an empty string.

    .. deprecated:: 1.6
        This has been deprecated due to its "wildcard" feature,
        and will be removed in Passlib 1.8. Use :class:`unix_disabled` instead.
    )Úenable_wildcardc                 óp   — t          |t          ¦  «        rdS t          j                             |d¦  «        ‚©NTÚhash©Ú
isinstancer   ÚuhÚexcÚExpectedStringError©Úclsr   s     úS/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/passlib/handlers/misc.pyÚidentifyzunix_fallback.identify.   ó2   € å�dÕ2Ñ3Ô3ð 	;Ø�4å”&×,Ò,¨T°6Ñ:Ô:Ð:ó    Fc                 ó€   •— t          dt          ¦  «          t          t          | ¦  «        j        di |¤Ž || _        d S )Nzf'unix_fallback' is deprecated, and will be removed in Passlib 1.8; please use 'unix_disabled' instead.© )r   ÚDeprecationWarningÚsuperr
   Ú__init__r   )Úselfr   ÚkwdsÚ	__class__s      €r   r    zunix_fallback.__init__5   sR   ø€ Ýð 3õ  ñ	!ô 	!ð 	!ð 	,��m˜TÑ"Ô"Ô+Ð3Ð3¨dÐ3Ð3Ð3Ø.ˆÔÐÐr   c                 ó<   — | j         r| j         S t          d¦  «        S )Nú!)Úchecksumr   )r!   Úsecrets     r   Ú_calc_checksumzunix_fallback._calc_checksum=   s!   € ØŒ=ð 	ð ”=Ð å�S‘6”6ˆMr   c                 ó    — t          j        |¦  «         t          |t          ¦  «        s t           j                             |d¦  «        ‚|rdS |S )Nr   F)r   Úvalidate_secretr   r   r   r   )r   r'   r   r   s       r   Úverifyzunix_fallback.verifyE   sQ   € å
Ô˜6Ñ"Ô"Ð"Ý˜$Õ 6Ñ7Ô7ð 	#Ý”&×,Ò,¨T°6Ñ:Ô:Ð:Øð 	#Ø�5à"Ð"r   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚcontext_kwdsÚclassmethodr   r    r(   r+   Ú__classcell__©r#   s   @r   r
   r
      s›   ø€ € € € € ðð ð" €DØ'€Làð;ð ;ñ „[ð;ð/ð /ð /ð /ð /ð /ðð ð ð ð#ð #ð #ñ „[ð#ð #ð #ð #ð #r   r
   z*!s   *!c                   ó`  ‡ — e Zd ZdZd ZdZdZ e ee	¦  «        ¦  «        Z
dej        v r ed¦  «        Zn ed¦  «        Zedˆ fd„	¦   «         Zed	„ ¦   «         Zed
„ ¦   «         Zed„ ¦   «         Z ej        dd¬¦  «        edd„¦   «         ¦   «         Zedd„¦   «         Zed„ ¦   «         Zˆ xZS )r	   a  This class provides disabled password behavior for unix shadow files,
    and follows the :ref:`password-hash-api`.

    This class does not implement a hash, but instead matches the "disabled account"
    strings found in ``/etc/shadow`` on most Unix variants. "encrypting" a password
    will simply return the disabled account marker. It will reject all passwords,
    no matter the hash string. The :meth:`~passlib.ifc.PasswordHash.hash`
    method supports one optional keyword:

    :type marker: str
    :param marker:
        Optional marker string which overrides the platform default
        used to indicate a disabled account.

        If not specified, this will default to ``"*"`` on BSD systems,
        and use the Linux default ``"!"`` for all other platforms.
        (:attr:`!unix_disabled.default_marker` will contain the default value)

    .. versionadded:: 1.6
        This class was added as a replacement for the now-deprecated
        :class:`unix_fallback` class, which had some undesirable features.
    ©Úmarkerr   ÚbsdÚ*r%   Nc                 ó¨   •—  t          t          | ¦  «        j        di |¤Ž}|�.|                      |¦  «        st	          d|z  ¦  «        ‚||_        |S )Nzinvalid marker: %rr   )r   r	   Úusingr   Ú
ValueErrorÚdefault_marker)r   r7   r"   Úsubclsr#   s       €r   r;   zunix_disabled.usingx   sa   ø€ à0••} cÑ*Ô*Ô0Ð8Ð8°4Ð8Ð8ˆØÐØ—<’< Ñ'Ô'ð @Ý Ð!5¸Ñ!>Ñ?Ô?Ð?Ø$*ˆFÔ!Øˆr   c                 óÐ   — t          |t          ¦  «        rt          }n=t          |t          ¦  «        rt          }n t
          j                             |d¦  «        ‚| p	|d         |v S )Nr   r   )r   r   Ú_MARKER_CHARSÚbytesÚ_MARKER_BYTESr   r   r   )r   r   Ústarts      r   r   zunix_disabled.identify�   sd   € õ  �d�GÑ$Ô$ð 	;Ý!ˆEˆEÝ˜�eÑ$Ô$ð 	;Ý!ˆEˆEå”&×,Ò,¨T°6Ñ:Ô:Ð:ØˆxÐ+˜4 œ7 eÐ+Ð+r   c                 ó–   — t          j        |¦  «         |                      |¦  «        st           j                             | ¦  «        ‚dS )NF)r   r*   r   r   ÚInvalidHashError)r   r'   r   s      r   r+   zunix_disabled.verify™   sB   € å
Ô˜6Ñ"Ô"Ð"Ø�|Š|˜DÑ!Ô!ð 	/Ý”&×)Ò)¨#Ñ.Ô.Ð.Øˆur   c                 óú   — |r5t          j        | |¦  «          | j        di |¤Ž                     |¦  «        S t          j        |¦  «         | j        }|r|                      |¦  «        sJ ‚t          |d¬¦  «        S )Nr7   ©Úparamr   )r   Úwarn_hash_settings_deprecationr;   r   r*   r=   r   r   )r   r'   r"   r7   s       r   r   zunix_disabled.hash    sŒ   € àð 	2ÝÔ-¨c°4Ñ8Ô8Ð8Ø�3”9Ð$Ð$˜tÐ$Ð$×)Ò)¨&Ñ1Ô1Ð1Ý
Ô˜6Ñ"Ô"Ð"ØÔ#ˆØÐ.˜#Ÿ,š, vÑ.Ô.Ð.Ð.Ð.Ý˜V¨8Ð4Ñ4Ô4Ð4r   ú1.7ú2.0©Ú
deprecatedÚremovedc                 ó  — |                       |¦  «        st          j                             | ¦  «        ‚|r%t          j        |¦  «         t          |d¬¦  «        S |�|                      |¬¦  «        } |                      |¦  «        S )NÚconfigrG   r6   )r   r   r   rE   r*   r   r;   r   )r   r'   rP   r7   s       r   Úgenhashzunix_disabled.genhashª   s…   € ð �|Š|˜FÑ#Ô#ð 		$Ý”&×)Ò)¨#Ñ.Ô.Ð.Øð 	$åÔ˜vÑ&Ô&Ð&Ý  ¨xÐ8Ñ8Ô8Ð8àÐ!Ø—i’i v�iÑ.Ô.�Ø—8’8˜FÑ#Ô#Ð#r   c                 ó¸   — |                       d¦  «        }|�Bt          |d¬¦  «        }|                      |¦  «        r|                      |¦  «        }|r||z  }|S )NÚ r   rG   )r   r   r   Úenable)r   r   Úouts      r   Údisablezunix_disabled.disable¸   sd   € à�hŠh�r‰lŒlˆØÐÝ  ¨VÐ4Ñ4Ô4ˆDØ�|Š|˜DÑ!Ô!ð (à—z’z $Ñ'Ô'�Øð Ø�t‘�Øˆ
r   c                 óø   — t          |d¬¦  «        }| j        D ]C}|                     |¦  «        r,|t          |¦  «        d …         }|r|c S t	          d¦  «        ‚ŒDt
          j                             | ¦  «        ‚)Nr   rG   zcannot restore original hash)r   Ú_disable_prefixesÚ
startswithÚlenr<   r   r   rE   )r   r   ÚprefixÚorigs       r   rT   zunix_disabled.enableÄ   s�   € å˜T¨Ð0Ñ0Ô0ˆØÔ+ð 	Eð 	EˆFØ�Š˜vÑ&Ô&ð EØ�C ™KœK˜L˜LÔ)�Øð EØ�K�K�Kå$Ð%CÑDÔDÐDðEõ Œf×%Ò% cÑ*Ô*Ð*r   ©N)r,   r-   r.   r/   r0   Úsetting_kwdsr1   ÚtupleÚstrr@   rX   ÚsysÚplatformr   r=   r2   r;   r   r+   r   r   Údeprecated_methodrQ   rV   rT   r3   r4   s   @r   r	   r	   R   sr  ø€ € € € € ðð ð, €DØ€LØ€Là˜˜c˜c -Ñ0Ô0Ñ1Ô1Ðð �”ÐÐØ˜˜3™œˆˆð
 ˜˜3™œˆàðð ð ð ð ñ „[ðð ð,ð ,ñ „[ð,ð. ðð ñ „[ðð ð5ð 5ñ „[ð5ð €RÔ U°EÐ:Ñ:Ô:Øð
$ð 
$ð 
$ñ „[ñ ;Ô:ð
$ð ð	ð 	ð 	ñ „[ð	ð ð	+ð 	+ñ „[ð	+ð 	+ð 	+ð 	+ð 	+r   r	   c                   óö   — e Zd ZdZd ZdZdZdZed„ ¦   «         Z	edd„¦   «         Z
edd„¦   «         Z ej        d	d
¬¦  «        ed„ ¦   «         ¦   «         Z ej        d	d
¬¦  «        edd„¦   «         ¦   «         ZdS )r   a~  This class stores passwords in plaintext, and follows the :ref:`password-hash-api`.

    The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods all require the
    following additional contextual keyword:

    :type encoding: str
    :param encoding:
        This controls the character encoding to use (defaults to ``utf-8``).

        This encoding will be used to encode :class:`!unicode` passwords
        under Python 2, and decode :class:`!bytes` hashes under Python 3.

    .. versionchanged:: 1.6
        The ``encoding`` keyword was added.
    r   ©Úencodingzutf-8c                 óp   — t          |t          ¦  «        rdS t          j                             |d¦  «        ‚r   r   r   s     r   r   zplaintext.identifyç   r   r   Nc                 ó^   — t          j        |¦  «         |s| j        }t          ||d¦  «        S )Nr'   )r   r*   Údefault_encodingr   )r   r'   rf   s      r   r   zplaintext.hashî   s5   € å
Ô˜6Ñ"Ô"Ð"Øð 	,ØÔ+ˆHÝ˜V X¨xÑ8Ô8Ð8r   c                 óæ   — |s| j         }t          ||d¦  «        }|                      |¦  «        st          j                             | ¦  «        ‚t          |                      ||¦  «        |¦  «        S )Nr   )ri   r   r   r   r   rE   r   r   )r   r'   r   rf   s       r   r+   zplaintext.verifyõ   sk   € àð 	,ØÔ+ˆHÝ˜T 8¨VÑ4Ô4ˆØ�|Š|˜DÑ!Ô!ð 	/Ý”&×)Ò)¨#Ñ.Ô.Ð.Ý˜3Ÿ8š8 F¨HÑ5Ô5°tÑ<Ô<Ð<r   rJ   rK   rL   c                 ó,   — |                       d¦  «        S )NrS   )r   )r   s    r   Ú	genconfigzplaintext.genconfigþ   s   € ð �xŠx˜‰|Œ|Ðr   c                 ó˜   — |                       |¦  «        st          j                             | ¦  «        ‚|                      ||¬¦  «        S )Nre   )r   r   r   rE   r   )r   r'   rP   rf   s       r   rQ   zplaintext.genhash  sD   € ð �|Š|˜FÑ#Ô#ð 	/Ý”&×)Ò)¨#Ñ.Ô.Ð.Ø�xŠx˜¨ˆxÑ2Ô2Ð2r   r]   )r,   r-   r.   r/   r0   r^   r1   ri   r2   r   r   r+   r   rc   rl   rQ   r   r   r   r   r   Ð   s  € € € € € ðð ð" €DØ€LØ €LØÐàð;ð ;ñ „[ð;ð ð9ð 9ð 9ñ „[ð9ð ð=ð =ð =ñ „[ð=ð €RÔ U°EÐ:Ñ:Ô:Øðð ñ „[ñ ;Ô:ðð €RÔ U°EÐ:Ñ:Ô:Øð3ð 3ð 3ñ „[ñ ;Ô:ð3ð 3ð 3r   r   )r/   ra   ÚloggingÚ	getLoggerr,   ÚlogÚwarningsr   Úpasslib.utilsr   r   Úpasslib.utils.compatr   r   r   Úpasslib.utils.handlersÚutilsÚhandlersr   Ú__all__ÚifcÚDisabledHashÚStaticHandlerr
   r@   rB   ÚMinimalHandlerr	   r   r   r   r   ú<module>r|      sh  ððð ð €
€
€
Ø €€€Ð'�gÔ'¨Ñ1Ô1�Ø Ð Ð Ð Ð Ð ð 5Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #ðð ð €ð4#ð 4#ð 4#ð 4#ð 4#�B”FÔ'¨Ô)9ñ 4#ô 4#ð 4#ðl ��$‘”€Ø€ð|+ð |+ð |+ð |+ð |+�B”FÔ'¨Ô):ñ |+ô |+ð |+ð|93ð 93ð 93ð 93ð 93�Ô!ñ 93ô 93ð 93ð 93ð 93r   