← Back
Editing: jws.cpython-38.pyc
U ��]�7 � @ s� d Z ddlZddlZddlZddlZddlZddlmZmZm Z m Z mZmZ G dd� de �ZG dd� de j�ZG dd � d e j�ZG d d� de j�ZG dd � d e �Zedkr�ee�� � dS )zJSON Web Signature.� N)�b64�errors� json_util�jwa�jwk�utilc @ s, e Zd ZdZdZedd� �Zedd� �ZdS )� MediaTypez MediaType field encoder/decoder.zapplication/c C s( d|kr$d|krt �d��| j| S |S )zDecoder.�/�;zUnexpected semi-colon)r �DeserializationError�PREFIX��cls�value� r �,/usr/lib/python3/dist-packages/josepy/jws.py�decode s zMediaType.decodec C s. d|kr*|� | j�st�|t| j�d� S |S )zEncoder.r N)� startswithr �AssertionError�lenr r r r �encode s zMediaType.encodeN)�__name__� __module__�__qualname__�__doc__r �classmethodr r r r r r r s r c @ s e Zd ZdZejdejjdd�Z ejddd�Z ejdejjdd�Zejddd�Z ejd dd�Zejd ddd�Zejd ejdd�Zejdejdd�Zejdejejdd�Zejdejejdd�Zejdddd�Zdd� Zdd� Zdd� Zejdd� �Zejdd� �Zejdd� �ZdS )�Headera6 JOSE Header. .. warning:: This class supports **only** Registered Header Parameter Names (as defined in section 4.1 of the protocol). If you need Public Header Parameter Names (4.2) or Private Header Parameter Names (4.3), you must subclass and override :meth:`from_json` and :meth:`to_partial_json` appropriately. .. warning:: This class does not support any extensions through the "crit" (Critical) Header Parameter (4.1.11) and as a conforming implementation, :meth:`from_json` treats its occurrence as an error. Please subclass if you seek for a different behaviour. :ivar x5tS256: "x5t#S256" :ivar str typ: MIME Media Type, inc. :const:`MediaType.PREFIX`. :ivar str cty: Content-Type, inc. :const:`MediaType.PREFIX`. �algT)�decoder� omitempty�jku)r r �kid�x5u�x5cr �r �default�x5tzx5t#S256�typ)�encoderr r �cty�critc s t � fdd�t�� j�D ��S )z4Fields that would not be omitted in the JSON object.c 3 s0 | ](\}}|� t� |��s|t� |�fV qd S �N)Zomit�getattr)�.0�nameZfield��selfr r � <genexpr>N s �z%Header.not_omitted.<locals>.<genexpr>)�dict�sixZ iteritems�_fieldsr/ r r/ r �not_omittedL s �zHeader.not_omittedc C s^ t |t| ��s td�t|����| �� }|�� }t|��|�rFtd��|�|� t| �f |�S )NzHeader cannot be added to: {0}z+Addition of overlapping headers not defined)� isinstance�type� TypeError�formatr5 �set�intersection�update)r0 �otherZnot_omitted_selfZnot_omitted_otherr r r �__add__R s � zHeader.__add__c C s | j dkrt�d��| j S )z�Find key based on header. .. todo:: Supports only "jwk" header parameter lookup. :returns: (Public) key found in the header. :rtype: .JWK :raises josepy.errors.Error: if key could not be found NzNo key found)r r �Errorr/ r r r �find_key` s zHeader.find_keyc C s t �d��d S )Nz("crit" is not supported, please subclass)r r )Zunused_valuer r r r* o s �zHeader.critc C s dd� | D �S )Nc S s&