o
    b	                     @   s4   G d d de ZG dd deZG dd deZdS )c                   @   s8   e Zd ZdZdZdZdZdZdd Zdd Z	d	d
 Z
dS )JWSAlgorithmzInterface for JWS algorithm. JWA specification (RFC7518) SHOULD
    implement the algorithms for JWS with this base implementation.
    NZJWSalgc                 C   s   t  )z0Prepare key for signing and verifying signature.NotImplementedError)selfraw_data r   Z/var/www/secure340b-portal/env/lib/python3.10/site-packages/authlib/jose/rfc7515/models.pyprepare_key
   s   zJWSAlgorithm.prepare_keyc                 C      t )zSign the text msg with a private/sign key.

        :param msg: message bytes to be signed
        :param key: private key to sign the message
        :return: bytes
        r   )r   msgkeyr   r   r   sign   s   zJWSAlgorithm.signc                 C   r
   )zVerify the signature of text msg with a public/verify key.

        :param msg: message bytes to be signed
        :param sig: result signature to be compared
        :param key: public key to verify the signature
        :return: boolean
        r   )r   r   sigr   r   r   r   verify   s   zJWSAlgorithm.verify)__name__
__module____qualname____doc__namedescriptionZalgorithm_typeZalgorithm_locationr	   r   r   r   r   r   r   r      s    	r   c                       s,   e Zd ZdZ fddZedd Z  ZS )	JWSHeadera  Header object for JWS. It combine the protected header and unprotected
    header together. JWSHeader itself is a dict of the combined dict. e.g.

        >>> protected = {'alg': 'HS256'}
        >>> header = {'kid': 'a'}
        >>> jws_header = JWSHeader(protected, header)
        >>> print(jws_header)
        {'alg': 'HS256', 'kid': 'a'}
        >>> jws_header.protected == protected
        >>> jws_header.header == header

    :param protected: dict of protected header
    :param header: dict of unprotected header
    c                    s@   i }|r	| | |r| | tt| | || _|| _d S )N)updatesuperr   __init__	protectedheader)r   r   r   obj	__class__r   r   r   1   s   


zJWSHeader.__init__c                 C   s$   t || r|S | |d|dS )Nr   r   )
isinstanceget)clsr   r   r   r   	from_dict;   s   
zJWSHeader.from_dict)r   r   r   r   r   classmethodr"   __classcell__r   r   r   r   r   "   s
    
r   c                       s.   e Zd ZdZd fdd	Zedd Z  ZS )	JWSObjectz*A dict instance to represent a JWS object.compactc                    s*   t t| j||d || _|| _|| _d S )N)r   payload)r   r%   r   r   r'   type)r   r   r'   r(   r   r   r   r   D   s   

zJWSObject.__init__c                 C   s   | j dkr	| d S dS )z'Alias of ``header`` for JSON typed JWS.jsonr   N)r(   )r   r   r   r   headersM   s   
zJWSObject.headers)r&   )r   r   r   r   r   propertyr*   r$   r   r   r   r   r%   B   s
    	r%   N)objectr   dictr   r%   r   r   r   r   <module>   s    ! 