
     h}'                     l   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j4                        Z G d dej4                        Zy)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                   T     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                 d    t        |t              ryt        j                  j	                  |d      NThash
isinstancer   uhexcExpectedStringErrorclsr   s     W/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/passlib/handlers/misc.pyidentifyzunix_fallback.identify.   '    d23&&,,T6::    c                 Z    t        dt               t        t        |   di | || _        y )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   s1     3  	! 	mT+3d3.r   c                 H    | j                   r| j                   S t        d      S )N!)checksumr   )r!   secrets     r   _calc_checksumzunix_fallback._calc_checksum=   s    == == S6Mr   c                     t        j                  |       t        |t              s t         j                  j                  |d      |ry|S )Nr   F)r   validate_secretr   r   r   r   )r   r'   r   r   s       r   verifyzunix_fallback.verifyE   s>    
6"$ 67&&,,T6::""r   )F)__name__
__module____qualname____doc__namecontext_kwdsclassmethodr   r    r(   r+   __classcell__r#   s   @r   r
   r
      sD    " 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%   c                 ~    t        t        | 
  di |}|&| j                  |      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   sG    }c0848<<' !5!>??$*F!r   c                     t        |t              rt        }n7t        |t              rt        }n t
        j                  j                  |d      | xs |d   |v S )Nr   r   )r   r   _MARKER_CHARSbytes_MARKER_BYTESr   r   r   )r   r   starts      r   r   zunix_disabled.identify   sO      dG$!Ee$!E&&,,T6::x+47e++r   c                     t        j                  |       | j                  |      st         j                  j	                  |       y)NF)r   r*   r   r   InvalidHashError)r   r'   r   s      r   r+   zunix_disabled.verify   s4    
6"||D!&&))#..r   c                     |r7t        j                  | |        | j                  di |j                  |      S t        j                  |       | j
                  }|r| j                  |      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   sk    --c48399$t$))&11
6"###,,v..V844r   1.72.0
deprecatedremovedc                     | j                  |      st        j                  j                  |       |r"t        j                  |       t        |d      S || j                  |      } | j                  |      S )NconfigrG   r6   )r   r   r   rE   r*   r   r;   r   )r   r'   rP   r7   s       r   genhashzunix_disabled.genhash   sh     ||F#&&))#..v& x88!iivi.88F##r   c                     | j                  d      }|6t        |d      }| j                  |      r| j                  |      }|r||z  }|S )N r   rG   )r   r   r   enable)r   r   outs      r   disablezunix_disabled.disable   sL    hhrl V4D||D!zz$'t
r   c                     t        |d      }| j                  D ]2  }|j                  |      s|t        |      d  }|r|c S t	        d       t
        j                  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   sl    T0++ 	EFv&CKL)K$%CDD	E ff%%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   s    , DLLc-01 3
 3  , ,.   5 5 RUE:
$  ;
$ 	 	 	+ 	+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y)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                 d    t        |t              ryt        j                  j	                  |d      r   r   r   s     r   r   zplaintext.identify   r   r   Nc                 b    t        j                  |       |s| j                  }t        ||d      S )Nr'   )r   r*   default_encodingr   )r   r'   rf   s      r   r   zplaintext.hash   s-    
6"++HVXx88r   c                     |s| j                   }t        ||d      }| j                  |      st        j                  j                  |       t        | j                  ||      |      S )Nr   )ri   r   r   r   r   rE   r   r   )r   r'   r   rf   s       r   r+   zplaintext.verify   sW    ++HT8V4||D!&&))#..388FH5t<<r   rJ   rK   rL   c                 $    | j                  d      S )NrS   )r   )r   s    r   	genconfigzplaintext.genconfig   s     xx|r   c                     | j                  |      st        j                  j                  |       | j	                  ||      S )Nre   )r   r   r   rE   r   )r   r'   rP   rf   s       r   rQ   zplaintext.genhash  s8     ||F#&&))#..xxx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 = = RUE:  ; RUE: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|      s     'g''1  5 C C # #4#BFF'')9)9 4#l $|+BFF''):): |+|93!! 93r   