← Back
Editing: _common.cpython-38.pyc
U ֞\. � @ s� d Z ddlmZmZmZ ddlZddlZddlZddlm Z m Z ddlmZm Z mZmZmZmZ zddlZW n ek r� dZY nX ejdd�G d d � d e��Zdd� Zd d� Zdd� Zdd� Zejddd�G dd� de��Zejdd�G dd� de��Zejddd�G dd� de��Zejddd�G dd� de��Zejddd�G dd� de��Zejdd�G dd � d e��Z ejddd�G d!d"� d"e��Z!ejddd�G d#d$� d$e��Z"d%d&� Z#d'd(� Z$e d)d*�Z%dS )+z Common verification code. � )�absolute_import�division�print_functionN� )� maketrans� text_type)�CertificateError�DNSMismatch�IPAddressMismatch�SRVMismatch�URIMismatch�VerificationErrorT)�slotsc @ s e Zd ZdZe�� Ze�� ZdS )�ServiceMatchz< A match of a service id and a certificate pattern. N)�__name__� __module__�__qualname__�__doc__�attr�ib� service_id�cert_pattern� r r �:/usr/lib/python3/dist-packages/service_identity/_common.pyr s r c C s� g }t | |�t | |� }dd� |D �}|D ]}||kr*|�|j|d�� q*|D ]*}||krNt| |j�rN|�|j|d�� qN|r�t|d��|S )z� Verify whether *cert_patterns* are valid for *obligatory_ids* and *optional_ids*. *obligatory_ids* must be both present and match. *optional_ids* must match if a pattern of the respective type is present. c S s g | ] }|j �qS r )r )�.0�matchr r r � <listcomp>4 s z+verify_service_identity.<locals>.<listcomp>)Z mismatched_id)�errors)� _find_matches�append�error_on_mismatch�_contains_instance_of� pattern_classr )� cert_patternsZobligatory_idsZoptional_idsr �matchesZmatched_ids�ir r r �verify_service_identity'