o
    >e                     @   sJ  d dl Z d dlmZ d dlmZ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mZmZ d d	lmZ d
dgZeejddde jde dde jdddedde jddedddde jdd Zeejddde jde dde jdddde jdddedde jd d!dedddd"e jd#d
 ZdS )$    N)ValidationContext)build_vc_kwargstrust_options)signing)pyhanko_exception_manager)IncrementalPdfFileWriter)PdfFileReader)signers
validation)HTTPTimeStamperltv_fix
lta_update	ltaupdatezupdate LTA timestamp)namehelpinfilezr+b)typez--timestamp-urlzURL for timestamp serverT)r   requiredr   defaultz--retroactive-revinfozOTreat revocation info as retroactively valid (i.e. ignore thisUpdate timestamp)F)r   r   is_flagr   show_defaultc                 C   sn   t  * t| jj|||||}t|}	t|}
t|	|
t	di | W d    d S 1 s0w   Y  d S )N )
r   r   objconfigr   r   r	   PdfTimeStamperupdate_archival_timestamp_chainr   )ctxr   validation_contexttrusttrust_replaceother_certstimestamp_urlretroactive_revinfo	vc_kwargstimestamperrr   r   d/var/www/html/humari/django-venv/lib/python3.10/site-packages/pyhanko/cli/commands/validation/ltv.pyr      s   
"ltvfixz5add revocation information for a signature to the DSSz--fieldzname of the signature field)r   r   z--apply-lta-timestampz8Apply a document timestamp after adding revocation info.)r   r   r   r   r   r   c	              	      s   |r	|s	t dt| jj||||ddd}	d|	d< t|}
zt fdd|
jD }W n ty<   t d	  d
w t	j
|tdi |	dd}|rft|}t|jt|tjtdi |	dd d S d S )Nz8Please specify a timestamp server using --timestamp-url.FT)r"   allow_fetchingz	hard-failrevocation_modec                 3   s    | ]
}|j  kr|V  qd S )N)
field_name).0sfieldr   r&   	<genexpr>u   s    zltv_fix.<locals>.<genexpr>z(Could not find a PDF signature labelled .)in_placer   )clickClickExceptionr   r   r   r   nextembedded_regular_signaturesStopIterationr
   add_validation_infor   r   r	   r   timestamp_pdfr   
DEFAULT_MD)r   r   r.   r!   apply_lta_timestampr   r   r   r    r#   r%   emb_sigoutputr$   r   r-   r&   r   A   sH   "	


)r2   pyhanko_certvalidatorr   pyhanko.cli._trustr   r   pyhanko.cli.commands.signingr   pyhanko.cli.runtimer   $pyhanko.pdf_utils.incremental_writerr   pyhanko.pdf_utils.readerr   pyhanko.signr	   r
   pyhanko.sign.timestampsr   __all__commandargumentFileoptionstrboolpass_contextr   r   r   r   r   r&   <module>   sl    		