o
    <^öh^  ã                   @   sp   d Z ddlZddlZddlZddlmZ dZdZG dd„ dejdZ	G d	d
„ d
ejdZ
G dd„ dejdZdS )z5Base classes for cryptographic signers and verifiers.é    N)Ú
exceptionsÚprivate_keyÚprivate_key_idc                   @   s   e Zd ZdZejdd„ ƒZdS )ÚVerifierz9Abstract base class for crytographic signature verifiers.c                 C   ó   t dƒ‚)a  Verifies a message against a cryptographic signature.

        Args:
            message (Union[str, bytes]): The message to verify.
            signature (Union[str, bytes]): The cryptography signature to check.

        Returns:
            bool: True if message was signed by the private key associated
            with the public key that this object was constructed with.
        zVerify must be implemented©ÚNotImplementedError)ÚselfÚmessageÚ	signature© r   úV/home/air/websocket/korean/venv/lib/python3.10/site-packages/google/auth/crypt/base.pyÚverify   ó   zVerifier.verifyN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚabcÚabstractmethodr   r   r   r   r   r      s    r   )Ú	metaclassc                   @   s,   e Zd ZdZejdd„ ƒZejdd„ ƒZdS )ÚSignerz.Abstract base class for cryptographic signers.c                 C   r   )z<Optional[str]: The key ID used to identify this private key.zKey id must be implementedr   )r	   r   r   r   Úkey_id2   s   zSigner.key_idc                 C   r   )z®Signs a message.

        Args:
            message (Union[str, bytes]): The message to be signed.

        Returns:
            bytes: The signature of the message.
        zSign must be implementedr   )r	   r
   r   r   r   Úsign7   s   zSigner.signN)	r   r   r   r   r   Úabstractpropertyr   r   r   r   r   r   r   r   /   s    
r   c                   @   s8   e Zd ZdZejd	dd„ƒZedd„ ƒZedd„ ƒZ	dS )
ÚFromServiceAccountMixinz3Mix-in to enable factory constructors for a Signer.Nc                 C   r   )ad  Construct an Signer instance from a private key string.

        Args:
            key (str): Private key as a string.
            key_id (str): An optional key id used to identify the private key.

        Returns:
            google.auth.crypt.Signer: The constructed signer.

        Raises:
            ValueError: If the key cannot be parsed.
        zfrom_string must be implementedr   )ÚclsÚkeyr   r   r   r   Úfrom_stringI   r   z#FromServiceAccountMixin.from_stringc                 C   s(   t |vr	t d¡‚|  |t  | t¡¡S )a‹  Creates a Signer instance instance from a dictionary containing
        service account info in Google format.

        Args:
            info (Mapping[str, str]): The service account info in Google
                format.

        Returns:
            google.auth.crypt.Signer: The constructed signer.

        Raises:
            ValueError: If the info is not in the expected format.
        z@The private_key field was not found in the service account info.)Ú_JSON_FILE_PRIVATE_KEYr   ÚMalformedErrorr   ÚgetÚ_JSON_FILE_PRIVATE_KEY_ID)r   Úinfor   r   r   Úfrom_service_account_infoY   s   ÿÿz1FromServiceAccountMixin.from_service_account_infoc                 C   sD   t j|ddd}t |¡}W d  ƒ n1 sw   Y  |  |¡S )a  Creates a Signer instance from a service account .json file
        in Google format.

        Args:
            filename (str): The path to the service account .json file.

        Returns:
            google.auth.crypt.Signer: The constructed signer.
        Úrzutf-8)ÚencodingN)ÚioÚopenÚjsonÚloadr$   )r   ÚfilenameÚ	json_fileÚdatar   r   r   Úfrom_service_account_fileq   s   ÿ
z1FromServiceAccountMixin.from_service_account_file)N)
r   r   r   r   r   r   r   Úclassmethodr$   r.   r   r   r   r   r   F   s    
r   )r   r   r'   r)   Úgoogle.authr   r   r"   ÚABCMetar   r   r   r   r   r   r   Ú<module>   s   