o
    >e                     @   sp   d dl Z d dlmZmZ d dlZd dlmZ d dlmZ d dl	m
Z
 G dd dZded	efd
dZdd ZdS )    N)BinaryIOOptional)crypt)
AuthStatus)IncrementalPdfFileWriterc                   @   s4   e Zd ZdedefddZdefddZdd	 Zd
S )OpenForSigninginfile_pathlenientc                 C   s   || _ || _d | _d S N)r   r	   handle)selfr   r	    r   c/var/www/html/humari/django-venv/lib/python3.10/site-packages/pyhanko/cli/commands/signing/utils.py__init__   s   
zOpenForSigning.__init__returnc                 C   s   t | jd | _}t|| j d}|jjrJ|jj}t|t	j
r:tjd| j d}||}|jtjkr8td|S t|t	jrEtdtd|S )Nrb)strictz"Password for encrypted file '%s': )promptz#Invalid password for encrypted filez:Public-key document encryption is not supported in the CLIzRInput file appears to be encrypted, but appropriate credentials are not available.)openr   r   r   r	   prev	encryptedsecurity_handler
isinstancer   StandardSecurityHandlergetpassencryptstatusr   FAILEDclickClickExceptionPubKeySecurityHandler)r   infilewritershpdf_passauthr   r   r   	__enter__   s0   
zOpenForSigning.__enter__c                 C   s   | j r
| j   d S d S r
   )r   close)r   exc_typeexc_valexc_tbr   r   r   __exit__-   s   zOpenForSigning.__exit__N)	__name__
__module____qualname__strboolr   r   r&   r+   r   r   r   r   r      s    r   r   r	   c                 C   s
   t | |S r
   )r   )r   r	   r   r   r   open_for_signing2   s   
r1   c                 C   s    d }| j j}|d urd|i}|S )Nurl)obj	stamp_url)ctxtext_paramsr4   r   r   r   get_text_params6   s
   r7   )r   typingr   r   r   pyhanko.pdf_utilsr   pyhanko.pdf_utils.cryptr   $pyhanko.pdf_utils.incremental_writerr   r   r/   r0   r1   r7   r   r   r   r   <module>   s    '