o
    c                     @   sH  d 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 ddlmZ ddl	Z	ej
r1ddlmZ G d	d
 d
eZG dd deZG dd dejZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"eZG d#d$ d$eZdS )%zACME errors.    N)Any)List)Mapping)Set)errors)messagesc                   @      e Zd ZdZdS )ErrorzGeneric ACME error.N__name__
__module____qualname____doc__ r   r   8/opt/certbot/lib/python3.10/site-packages/acme/errors.pyr	          r	   c                   @   r   )DependencyErrorzDependency errorNr
   r   r   r   r   r      r   r   c                   @   r   )SchemaValidationErrorz)JSON schema ACME object validation error.Nr
   r   r   r   r   r      r   r   c                   @   r   )ClientErrorzNetwork error.Nr
   r   r   r   r   r      r   r   c                   @   r   )UnexpectedUpdatezUnexpected update error.Nr
   r   r   r   r   r   !   r   r   c                   @   r   )
NonceErrorzServer response nonce error.Nr
   r   r   r   r   r   %   r   r   c                       s@   e Zd ZdZdedededdf fddZdefd	d
Z  Z	S )BadNoncezBad nonce error.nonceerrorargsreturnNc                    s   t  j|  || _|| _d S N)super__init__r   r   )selfr   r   r   	__class__r   r   r   +   s   
zBadNonce.__init__c                 C   s   d | j| jS )NzInvalid nonce ({0!r}): {1})formatr   r   r   r   r   r   __str__0   s   zBadNonce.__str__)
r   r   r   r   str	Exceptionr   r   r$   __classcell__r   r   r    r   r   )   s    r   c                       s>   e Zd ZdZdejdeddf fddZdefdd	Z	  Z
S )
MissingNoncezMissing nonce error.

    According to the specification an "ACME server MUST include an
    Replay-Nonce header field in each successful response to a POST it
    provides to a client (...)".

    :ivar requests.Response ~.response: HTTP Response

    responser   r   Nc                    s   t  j|  || _d S r   )r   r   r)   )r   r)   r   r    r   r   r   >   s   
zMissingNonce.__init__c                 C   s   d | jjj| jjS )Nz_Server {0} response did not include a replay nonce, headers: {1} (This may be a service outage))r"   r)   requestmethodheadersr#   r   r   r   r$   B   s
   zMissingNonce.__str__)r   r   r   r   requestsResponser   r   r%   r$   r'   r   r   r    r   r(   4   s    	r(   c                       sV   e Zd ZdZded ded ddf fdd	Zedefd
dZ	de
fddZ  ZS )	PollErrora  Generic error when polling for authorization fails.

    This might be caused by either timeout (`exhausted` will be non-empty)
    or by some authorization being invalid.

    :ivar exhausted: Set of `.AuthorizationResource` that didn't finish
        within max allowed attempts.
    :ivar updated: Mapping from original `.AuthorizationResource`
        to the most recently updated one

    	exhaustedmessages.AuthorizationResourceupdated)r1   r1   r   Nc                    s   || _ || _t   d S r   )r0   r2   r   r   )r   r0   r2   r    r   r   r   T   s   zPollError.__init__c                 C   s
   t | jS )z Was the error caused by timeout?)boolr0   r#   r   r   r   timeout\   s   
zPollError.timeoutc                 C   s   d | jj| j| jS )Nz#{0}(exhausted={1!r}, updated={2!r}))r"   r!   r   r0   r2   r#   r   r   r   __repr__a   s   zPollError.__repr__)r   r   r   r   r   r   r   propertyr3   r4   r%   r5   r'   r   r   r    r   r/   H   s    
r/   c                       s.   e Zd ZdZded ddf fddZ  ZS )ValidationErrorzError for authorization failures. Contains a list of authorization
    resources, each of which is invalid and should have an error field.
    failed_authzrsr1   r   Nc                       || _ t   d S r   )r8   r   r   )r   r8   r    r   r   r   j      zValidationError.__init__)r   r   r   r   r   r   r'   r   r   r    r   r7   f   s    "r7   c                   @   r   )TimeoutErrorz>Error for when polling an authorization or an order times out.Nr
   r   r   r   r   r;   o   r   r;   c                       s"   e Zd ZdZd fddZ  ZS )	IssuanceErrorzDError sent by the server after requesting issuance of a certificate.r   messages.Errorr   Nc                    s   || _ t   dS )z\Initialize.

        :param messages.Error error: The error provided by the server.
        N)r   r   r   )r   r   r    r   r   r   v   s   zIssuanceError.__init__)r   r=   r   N)r   r   r   r   r   r'   r   r   r    r   r<   s   s    r<   c                       s*   e Zd ZdZdeddf fddZ  ZS )ConflictErrora  Error for when the server returns a 409 (Conflict) HTTP status.

    In the version of ACME implemented by Boulder, this is used to find an
    account if you only have the private key, but don't know the account URL.

    Also used in V2 of the ACME client for the same purpose.
    locationr   Nc                    r9   r   )r?   r   r   )r   r?   r    r   r   r      r:   zConflictError.__init__)r   r   r   r   r%   r   r'   r   r   r    r   r>      s    r>   c                   @   r   )WildcardUnsupportedErrorzEError for when a wildcard is requested but is unsupported by ACME CA.Nr
   r   r   r   r   r@      r   r@   )r   typingr   r   r   r   josepyr   jose_errorsr-   TYPE_CHECKINGacmer   r&   r	   r   DeserializationErrorr   r   r   r   r   r(   r/   r7   r;   r<   r>   r@   r   r   r   r   <module>   s0    	