
     f%'                        d dl mZ d dlZd dlZd dlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ej        rd dlZ G d	 d
          Z G d d          ZdS )    )annotationsN   )dump_header)parse_dict_header)quote_header_value   )CallbackDictc                  z    e Zd ZdZ	 	 dddZddZddZd d!dZd"dZd#dZ	e
d$d            Zd%dZd%dZd%dZdS )&Authorizationa  Represents the parts of an ``Authorization`` request header.

    :attr:`.Request.authorization` returns an instance if the header is set.

    An instance can be used with the test :class:`.Client` request methods' ``auth``
    parameter to send the header in test requests.

    Depending on the auth scheme, either :attr:`parameters` or :attr:`token` will be
    set. The ``Basic`` scheme's token is decoded into the ``username`` and ``password``
    parameters.

    For convenience, ``auth["key"]`` and ``auth.key`` both access the key in the
    :attr:`parameters` dict, along with ``auth.get("key")`` and ``"key" in auth``.

    .. versionchanged:: 2.3
        The ``token`` parameter and attribute was added to support auth schemes that use
        a token instead of parameters, such as ``Bearer``.

    .. versionchanged:: 2.3
        The object is no longer a ``dict``.

    .. versionchanged:: 0.5
        The object is an immutable dict.
    N	auth_typestrdatadict[str, str | None] | Nonetoken
str | NonereturnNonec                <    || _         	 |i }|| _        	 || _        d S N)type
parametersr   )selfr   r   r   s       _/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/werkzeug/datastructures/auth.py__init__zAuthorization.__init__*   s7     	R<D	 
	 	    namec                6    | j                             |          S r   r   getr   r   s     r   __getattr__zAuthorization.__getattr__B       ""4(((r   c                6    | j                             |          S r   r   r    s     r   __getitem__zAuthorization.__getitem__E   r"   r   keydefaultc                8    | j                             ||          S r   r   r   r%   r&   s      r   r   zAuthorization.getH       ""3000r   boolc                    || j         v S r   r   r   r%   s     r   __contains__zAuthorization.__contains__K       do%%r   otherobjectc                    t          |t                    st          S |j        | j        k    o|j        | j        k    o|j        | j        k    S r   )
isinstancer   NotImplementedr   r   r   r   r0   s     r   __eq__zAuthorization.__eq__N   sP    %// 	"!! J$)# 4tz)4 DO3	
r   valuete.Self | Nonec                   |sdS |                     d          \  }}}|                                }|                                }|dk    rk	 t          j        |                                                               d          \  }}}n# t          j        t          f$ r Y dS w xY w | |||d          S d|	                    d          v r | |t          |          d          S  | |d|          S )zParse an ``Authorization`` header value and return an instance, or ``None``
        if the value is empty.

        :param value: The header value to parse.

        .. versionadded:: 2.3
        N basic:)usernamepassword=)	partitionlowerstripbase64	b64decodedecodebinasciiErrorUnicodeErrorrstripr   )clsr7   scheme_restr=   r>   s          r   from_headerzAuthorization.from_headerX   s     	4//#..4zz||W(.(8(>(>(E(E(G(G(Q(QRU(V(V%!XXNL1   tt 3vH(KKLLL$++c""""3v066=== s64&&&s   =B B%$B%c                f   | j         dk    rMt          j        | j         d| j                                                                       d          }d| S | j        #| j                                          d| j         S | j                                          dt          | j
                   S )ziProduce an ``Authorization`` header value representing this data.

        .. versionadded:: 2.0
        r;   r<   asciizBasic Nr:   )r   rC   	b64encoder=   r>   encoderE   r   titler   r   r   r7   s     r   	to_headerzAuthorization.to_headerw   s    
 9$=224=2299;; fWoo  $E###:!ioo''66$*666)//##DDk$/&B&BDDDr   c                *    |                                  S r   rU   r   s    r   __str__zAuthorization.__str__       ~~r   c                \    dt          |           j         d|                                  dS N<r:   >r   __name__rU   rX   s    r   __repr__zAuthorization.__repr__   .    <4::&<<)9)9<<<<r   NN)r   r   r   r   r   r   r   r   r   r   r   r   r   r%   r   r&   r   r   r   r%   r   r   r*   r0   r1   r   r*   r7   r   r   r8   r   r   )r`   
__module____qualname____doc__r   r!   r$   r   r.   r6   classmethodrN   rU   rY   ra    r   r   r   r      s        8 .2 	    0) ) ) )) ) ) )1 1 1 1 1& & & &
 
 
 
 ' ' ' ['<E E E E        = = = = = =r   r   c                  Z    e Zd ZdZ	 	 d*d+d	Zd,dZed-d            Zej        d.d            Zed/d            Z	e	j        d0d            Z	ed1d            Z
e
j        d2d            Z
d3dZd4dZd5dZd6dZd7 fdZd8dZd9dZd:d"Zd;d<d$Zed=d&            Zd-d'Zd-d(Zd-d)Z xZS )>WWWAuthenticatea  Represents the parts of a ``WWW-Authenticate`` response header.

    Set :attr:`.Response.www_authenticate` to an instance of list of instances to set
    values for this header in the response. Modifying this instance will modify the
    header value.

    Depending on the auth scheme, either :attr:`parameters` or :attr:`token` should be
    set. The ``Basic`` scheme will encode ``username`` and ``password`` parameters to a
    token.

    For convenience, ``auth["key"]`` and ``auth.key`` both act on the :attr:`parameters`
    dict, and can be used to get, set, or delete parameters. ``auth.get("key")`` and
    ``"key" in auth`` are also provided.

    .. versionchanged:: 2.3
        The ``token`` parameter and attribute was added to support auth schemes that use
        a token instead of parameters, such as ``Bearer``.

    .. versionchanged:: 2.3
        The object is no longer a ``dict``.

    .. versionchanged:: 2.3
        The ``on_update`` parameter was removed.
    Nr   r   valuesr   r   r   c                     |                                  _        t          | fd           _        | _        d  _        d S )Nc                ,                                     S r   _trigger_on_updaterL   r   s    r   <lambda>z*WWWAuthenticate.__init__.<locals>.<lambda>   s    d5577 r   )rA   _typer	   _parameters_token
_on_update)r   r   rq   r   s   `   r   r   zWWWAuthenticate.__init__   sK     __&&
2>77773
 3
 FJr   r   r   c                B    | j         |                      |            d S d S r   )r{   rX   s    r   ru   z"WWWAuthenticate._trigger_on_update   s*    ?&OOD!!!!! '&r   c                    | j         S )zDThe authorization scheme, like ``basic``, ``digest``, or ``bearer``.)rx   rX   s    r   r   zWWWAuthenticate.type   s     zr   r7   c                <    || _         |                                  d S r   )rx   ru   rT   s     r   r   zWWWAuthenticate.type   s!    
!!!!!r   dict[str, str | None]c                    | j         S zA dict of parameters for the header. Only one of this or :attr:`token` should
        have a value for a given scheme.
        )ry   rX   s    r   r   zWWWAuthenticate.parameters   s    
 r   dict[str, str]c                `     t          | fd           _                                          d S )Nc                ,                                     S r   rt   rv   s    r   rw   z,WWWAuthenticate.parameters.<locals>.<lambda>   s    9P9P9R9R r   )r	   ry   ru   rT   s   ` r   r   zWWWAuthenticate.parameters   s7    '/R/R/R/RSS!!!!!r   c                    | j         S r   )rz   rX   s    r   r   zWWWAuthenticate.token   s    
 {r   c                <    || _         |                                  dS )zA token for the header. Only one of this or :attr:`parameters` should have a
        value for a given scheme.

        .. versionadded:: 2.3
        N)rz   ru   rT   s     r   r   zWWWAuthenticate.token   s#     !!!!!r   r%   c                6    | j                             |          S r   r   r-   s     r   r$   zWWWAuthenticate.__getitem__   s    ""3'''r   c                j    ||| j         v r| j         |= n
|| j         |<   |                                  d S r   r   ru   )r   r%   r7   s      r   __setitem__zWWWAuthenticate.__setitem__   sC    =do%%OC(#(DOC !!!!!r   c                T    || j         v r| j         |= |                                  d S d S r   r   r-   s     r   __delitem__zWWWAuthenticate.__delitem__   s9    $/!!$##%%%%% "!r   r   c                    | |         S r   rn   r    s     r   r!   zWWWAuthenticate.__getattr__   s    Dzr   c                b    |dv r$t                                          ||           d S || |<   d S )N>   rx   rz   r{   ry   )super__setattr__)r   r   r7   	__class__s      r   r   zWWWAuthenticate.__setattr__   s<    CCCGGe,,,,,DJJJr   c                    | |= d S r   rn   r    s     r   __delattr__zWWWAuthenticate.__delattr__   s    JJJr   r*   c                    || j         v S r   r,   r-   s     r   r.   zWWWAuthenticate.__contains__   r/   r   r0   r1   c                    t          |t                    st          S |j        | j        k    o|j        | j        k    o|j        | j        k    S r   )r3   rp   r4   r   r   r   r5   s     r   r6   zWWWAuthenticate.__eq__   sP    %11 	"!! J$)# 4tz)4 DO3	
r   r&   c                8    | j                             ||          S r   r   r(   s      r   r   zWWWAuthenticate.get
  r)   r   r8   c                   |sdS |                     d          \  }}}|                                }|                                }d|                    d          v r | |t	          |          d          S  | |d|          S )zParse a ``WWW-Authenticate`` header value and return an instance, or ``None``
        if the value is empty.

        :param value: The header value to parse.

        .. versionadded:: 2.3
        Nr:   r?   )r@   rA   rB   rI   r   )rJ   r7   rK   rL   rM   s        r   rN   zWWWAuthenticate.from_header  s      	4//#..4zz||$++c""""3v066=== s64&&&r   c                   | j         #| j                                         d| j          S | j        dk    rxg }| j                                        D ]D\  }}|dv rt          |d          }nt          |          }|                    | d|            Edd	                    |           S | j                                         dt          | j                   S )
zCProduce a ``WWW-Authenticate`` header value representing this data.Nr:   digest>   qopnoncerealmdomainopaqueF)allow_tokenr?   zDigest z, )	r   r   rS   r   itemsr   appendjoinr   )r   r   r%   r7   s       r   rU   zWWWAuthenticate.to_header$  s    :!ioo''66$*6669  E"o3355 / /
UGGG.u%HHHEE.u55E--e--..../TYYu--///)//##DDk$/&B&BDDDr   c                *    |                                  S r   rW   rX   s    r   rY   zWWWAuthenticate.__str__8  rZ   r   c                \    dt          |           j         d|                                  dS r\   r_   rX   s    r   ra   zWWWAuthenticate.__repr__;  rb   r   rc   )r   r   rq   r   r   r   )r   r   ri   )r7   r   r   r   )r   r   )r7   r   r   r   )r   r   )r7   r   r   r   )r%   r   r   r   )r%   r   r7   r   r   r   )r%   r   r   r   rd   )r   r   r7   r   r   r   )r   r   r   r   rf   rg   r   re   rh   )r`   rj   rk   rl   r   ru   propertyr   setterr   r   r$   r   r   r!   r   r   r.   r6   r   rm   rN   rU   rY   ra   __classcell__)r   s   @r   rp   rp      sN        8 04 	K K K K K" " " "    X 
[" " " ["       X  " " " "    X \" " " \"( ( ( (" " " "& & & &
           & & & &
 
 
 
1 1 1 1 1 ' ' ' [',E E E E(       = = = = = = = =r   rp   )
__future__r   rC   rF   typingthttpr   r   r   
structuresr	   TYPE_CHECKINGtyping_extensionster   rp   rn   r   r   <module>r      s    " " " " " "             $ $ $ $ $ $ % % % % % % $ $ $ $ $ $? #""""{= {= {= {= {= {= {= {=|n= n= n= n= n= n= n= n= n= n=r   