
     h8                        d Z  G d de      Z G d de      Z G d de      Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z	 G d de      Z
 G d de
      Z G d de
      Z G d de
      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Zd# Zd$ Zd% Zd& Zd1d(Zd1d)Zd1d*Zd2d+Zd1d,Zd3d.Zd-Zd4d/Z 	 d5d0Z!y')6z6passlib.exc -- exceptions & warnings raised by passlibc                       e Zd ZdZd Zy)UnknownBackendErrorz
    Error raised if multi-backend handler doesn't recognize backend name.
    Inherits from :exc:`ValueError`.

    .. versionadded:: 1.7
    c                 n    || _         || _        |j                  d|}t        j	                  | |       y )Nz: unknown backend: )hasherbackendname
ValueError__init__)selfr   r   messages       M/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/passlib/exc.pyr	   zUnknownBackendError.__init__   s.    /5{{GDD'*    N__name__
__module____qualname____doc__r	    r   r   r   r      s    +r   r   c                       e Zd ZdZy)MissingBackendErrora  Error raised if multi-backend handler has no available backends;
    or if specifically requested backend is not available.

    :exc:`!MissingBackendError` derives
    from :exc:`RuntimeError`, since it usually indicates
    lack of an external library or OS feature.
    This is primarily raised by handlers which depend on
    external libraries (which is currently just
    :class:`~passlib.hash.bcrypt`).
    Nr   r   r   r   r   r   r   r   r      s    	r   r   c                       e Zd ZdZy)InternalBackendErrorz
    Error raised if something unrecoverable goes wrong with backend call;
    such as if ``crypt.crypt()`` returning a malformed hash.

    .. versionadded:: 1.7.3
    Nr   r   r   r   r   r   #       r   r   c                       e Zd ZdZy)PasswordValueErrora  
    Error raised if a password can't be hashed / verified for various reasons.
    This exception derives from the builtin :exc:`!ValueError`.

    May be thrown directly when password violates internal invariants of hasher
    (e.g. some don't support NULL characters).  Hashers may also throw more specific subclasses,
    such as :exc:`!PasswordSizeError`.

    .. versionadded:: 1.7.3
    Nr   r   r   r   r   r   ,   s    	 	r   r   c                       e Zd ZdZdZddZy)PasswordSizeErrora  
    Error raised if a password exceeds the maximum size allowed
    by Passlib (by default, 4096 characters); or if password exceeds
    a hash-specific size limitation.

    This exception derives from :exc:`PasswordValueError` (above).

    Many password hash algorithms take proportionately larger amounts of time and/or
    memory depending on the size of the password provided. This could present
    a potential denial of service (DOS) situation if a maliciously large
    password is provided to an application. Because of this, Passlib enforces
    a maximum size limit, but one which should be *much* larger
    than any legitimate password. :exc:`PasswordSizeError` derives
    from :exc:`!ValueError`.

    .. note::
        Applications wishing to use a different limit should set the
        ``PASSLIB_MAX_PASSWORD_SIZE`` environmental variable before
        Passlib is loaded. The value can be any large positive integer.

    .. attribute:: max_size

        indicates the maximum allowed size.

    .. versionadded:: 1.6
    Nc                 F    || _         |d}t        j                  | |       y )Nz%password exceeds maximum allowed size)max_sizer   r	   )r
   r   msgs      r   r	   zPasswordSizeError.__init__X   s#     ;9C##D#.r   N)r   r   r   r   r   r	   r   r   r   r   r   :   s    6 H/r   r   c                       e Zd ZdZddZy)PasswordTruncateErrora]  
    Error raised if password would be truncated by hash.
    This derives from :exc:`PasswordSizeError` (above).

    Hashers such as :class:`~passlib.hash.bcrypt` can be configured to raises
    this error by setting ``truncate_error=True``.

    .. attribute:: max_size

        indicates the maximum allowed size.

    .. versionadded:: 1.7
    Nc                     |d|j                   |j                  fz  }t        j                  | |j                  |       y )Nz1Password too long (%s truncates to %d characters))r   truncate_sizer   r	   )r
   clsr    s      r   r	   zPasswordTruncateError.__init__p   s;    ;FHHc//01C""4):):C@r   r!   r   r   r   r   r#   r#   a   s    Ar   r#   c                       e Zd ZdZy)PasslibSecurityErrorz
    Error raised if critical security issue is detected
    (e.g. an attempt is made to use a vulnerable version of a bcrypt backend).

    .. versionadded:: 1.6.3
    Nr   r   r   r   r(   r(   w   r   r   r(   c                       e Zd ZdZdZddZy)
TokenErrora  
    Base error raised by v:mod:`passlib.totp` when
    a token can't be parsed / isn't valid / etc.
    Derives from :exc:`!ValueError`.

    Usually one of the more specific subclasses below will be raised:

    * :class:`MalformedTokenError` -- invalid chars, too few digits
    * :class:`InvalidTokenError` -- no match found
    * :class:`UsedTokenError` -- match found, but token already used

    .. versionadded:: 1.7
    zToken not acceptableNc                 T    || j                   }t        j                  | |g|i | y r!   )_default_messager   r	   )r
   r    argskwdss       r   r	   zTokenError.__init__   s,    ;''CD#555r   r!   )r   r   r   r   r,   r	   r   r   r   r*   r*      s     .6r   r*   c                       e Zd ZdZdZy)MalformedTokenErrorz
    Error raised by :mod:`passlib.totp` when a token isn't formatted correctly
    (contains invalid characters, wrong number of digits, etc)
    zUnrecognized tokenNr   r   r   r   r,   r   r   r   r0   r0      s     ,r   r0   c                       e Zd ZdZdZy)InvalidTokenErrorz
    Error raised by :mod:`passlib.totp` when a token is formatted correctly,
    but doesn't match any tokens within valid range.
    zToken did not matchNr1   r   r   r   r3   r3      s     -r   r3   c                       e Zd ZdZdZdZd Zy)UsedTokenErrorz
    Error raised by :mod:`passlib.totp` if a token is reused.
    Derives from :exc:`TokenError`.

    .. autoattribute:: expire_time

    .. versionadded:: 1.7
    z5Token has already been used, please wait for another.Nc                 d    |j                  dd       | _        t        j                  | g|i | y )Nexpire_time)popr7   r*   r	   )r
   r-   r.   s      r   r	   zUsedTokenError.__init__   s-    88M48D04040r   )r   r   r   r   r,   r7   r	   r   r   r   r5   r5      s     O K1r   r5   c                       e Zd ZdZddZd Zy)UnknownHashErrorar  
    Error raised by :class:`~passlib.crypto.lookup_hash` if hash name is not recognized.
    This exception derives from :exc:`!ValueError`.

    As of version 1.7.3, this may also be raised if hash algorithm is known,
    but has been disabled due to FIPS mode (message will include phrase "disabled for fips").

    As of version 1.7.4, this may be raised if a :class:`~passlib.context.CryptContext`
    is unable to identify the algorithm used by a password hash.

    .. versionadded:: 1.7

    .. versionchanged: 1.7.3
        added 'message' argument.

    .. versionchanged:: 1.7.4
        altered call signature.
    Nc                 \    || _         |d|z  }|| _        t        j                  | ||       y )Nzunknown hash algorithm: %r)valuer   r   r	   )r
   r   r<   s      r   r	   zUnknownHashError.__init__   s1    
?2U:GD'51r   c                     | j                   S r!   )r   )r
   s    r   __str__zUnknownHashError.__str__   s    ||r   NN)r   r   r   r   r	   r>   r   r   r   r:   r:      s    $2r   r:   c                       e Zd ZdZy)PasslibWarningzxbase class for Passlib's user warnings,
    derives from the builtin :exc:`UserWarning`.

    .. versionadded:: 1.6
    Nr   r   r   r   rA   rA          r   rA   c                       e Zd ZdZy)PasslibConfigWarningaH  Warning issued when non-fatal issue is found related to the configuration
    of a :class:`~passlib.context.CryptContext` instance.

    This occurs primarily in one of two cases:

    * The CryptContext contains rounds limits which exceed the hard limits
      imposed by the underlying algorithm.
    * An explicit rounds value was provided which exceeds the limits
      imposed by the CryptContext.

    In both of these cases, the code will perform correctly & securely;
    but the warning is issued as a sign the configuration may need updating.

    .. versionadded:: 1.6
    Nr   r   r   r   rD   rD      s    r   rD   c                       e Zd ZdZy)PasslibHashWarninga  Warning issued when non-fatal issue is found with parameters
    or hash string passed to a passlib hash class.

    This occurs primarily in one of two cases:

    * A rounds value or other setting was explicitly provided which
      exceeded the handler's limits (and has been clamped
      by the :ref:`relaxed<relaxed-keyword>` flag).

    * A malformed hash string was encountered which (while parsable)
      should be re-encoded.

    .. versionadded:: 1.6
    Nr   r   r   r   rF   rF      s    r   rF   c                       e Zd ZdZy)PasslibRuntimeWarninga8  Warning issued when something unexpected happens during runtime.

    The fact that it's a warning instead of an error means Passlib
    was able to correct for the issue, but that it's anomalous enough
    that the developers would love to hear under what conditions it occurred.

    .. versionadded:: 1.6
    Nr   r   r   r   rH   rH     s    r   rH   c                       e Zd ZdZy)PasslibSecurityWarningzxSpecial warning issued when Passlib encounters something
    that might affect security.

    .. versionadded:: 1.6
    Nr   r   r   r   rJ   rJ     rB   r   rJ   c                 "    | r| j                   S dS )Nz	<unnamed>)r   handlers    r   	_get_namerN   "  s    "7<<33r   c                     | j                   }|j                  r)|j                  dvr|j                  d|j                  S | y|j                  S )z<return pretty-printed string containing name of value's type)__builtin__builtins.None)	__class__r   r   )r<   r&   s     r   	type_namerU   (  sC    
//C
~~#..0KK..#,,77	||r   c                 >    t        |       }t        |d|d|      S )zGerror message when param was supposed to be one type, but found anotherz	 must be z, not )rU   	TypeError)r<   expectedparamr   s       r   ExpectedTypeErrorrZ   2  s      UDxFGGr   c                     t        | d|      S )z<error message when param was supposed to be unicode or byteszunicode or bytes)rZ   r<   rY   s     r   ExpectedStringErrorr]   8  s    U$6>>r   Nc                 <    t        |       }t        d|d|d      S )zEraised when verify() method gets passed config string instead of hashz	expected z hash, got z config string insteadrN   r   rM   r   s     r   MissingDigestErrorra   ?  s#    WDD" # #r   c                 4    t        |       }t        d|z        S )zFraised by OS crypt() supporting hashes, which forbid NULLs in passwordz(%s does not allow NULL bytes in password)rN   r   r`   s     r   NullPasswordErrorrc   E  s    WDH4OPPr   c                 0    t        dt        |       z        S )z5error raised if unrecognized hash provided to handlerznot a valid %s hash)r   rN   rL   s    r   InvalidHashErrorre   M  s    +i.@@AAr   c                 H    dt        |       z  }|r|d|d}t        |      S )zAerror raised if recognized-but-malformed hash provided to handlerzmalformed %s hashz ()r_   )rM   reasontexts      r   MalformedHashErrorrj   Q  s)    7!33D &)dr   c                     t        | d      S )zJerror raised if hash was recognized but contained zero-padded rounds fieldzzero-padded rounds)rj   rL   s    r   ZeroPaddedRoundsErrorrl   X  s    g';<<r   Fc                 L    | j                   }|rdnd}d||fz  }t        | |      S )z@error raised if hash was recognized, but checksum was wrong sizebytescharszchecksum must be exactly %d %s)checksum_sizerj   )rM   rawrp   unitrh   s        r   ChecksumSizeErrorrs   _  s4     ))M7wD-0EEFgv..r   c                 l    t         s| t        | t              rt        |       S d|dt	        |       dS )a  
    helper used to display sensitive data (hashes etc) within error messages.
    currently returns placeholder test UNLESS unittests are running,
    in which case the real value is displayed.

    mainly useful to prevent hashes / secrets from being exposed in production tracebacks;
    while still being visible from test failures.

    NOTE: api subject to change, may formalize this more in the future.
    < z value omitted>)ENABLE_DEBUG_ONLY_REPR
isinstanceboolreprtyper\   s     r   debug_only_reprr|   p  s3     *UD2IE{ 3J&+T%[99r   c           	      l    t        |       }|d|dt        |      dt        |      }t        |      )z
    helper to generate standard message when ``crypt.crypt()`` returns invalid result.
    takes care of automatically masking contents of config & hash outside of UTs.
    z returned invalid z hash: config=z hash=)rN   r|   r   )rM   confighashsourcer   r    s         r   CryptBackendErrorr     s4     WD40/$2GIC
s
##r   r!   r?   )F)r   )zcrypt.crypt())"r   r   r   RuntimeErrorr   r   r   r   r#   r(   r*   r0   r3   r5   r:   UserWarningrA   rD   rF   rH   rJ   rN   rU   rZ   r]   ra   rc   re   rj   rl   rs   rw   r|   r   r   r   r   <module>r      s&   <+* +"
, 
< 	 	"/* "/NA- A,< 6 60,* ,-
 -1Z 1(z B[ > "  N ^ "4H?#QB=/  :" -	$r   