ó
ùR‹_c           @   s¾   d  Z  d d l Z d d l Z d d l Z d d l Z d Z d Z e j e j ƒ d e	 f d „  ƒ  Yƒ Z
 e j e j ƒ d e	 f d „  ƒ  Yƒ Z e j e j ƒ d	 e	 f d
 „  ƒ  Yƒ Z d S(   s5   Base classes for cryptographic signers and verifiers.iÿÿÿÿNt   private_keyt   private_key_idt   Verifierc           B   s    e  Z d  Z e j d „  ƒ Z RS(   s9   Abstract base class for crytographic signature verifiers.c         C   s   t  d ƒ ‚ d S(   s  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.
        s   Verify must be implementedN(   t   NotImplementedError(   t   selft   messaget	   signature(    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyt   verify    s    (   t   __name__t
   __module__t   __doc__t   abct   abstractmethodR   (    (    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyR      s   t   Signerc           B   s2   e  Z d  Z e j d „  ƒ Z e j d „  ƒ Z RS(   s.   Abstract base class for cryptographic signers.c         C   s   t  d ƒ ‚ d S(   s<   Optional[str]: The key ID used to identify this private key.s   Key id must be implementedN(   R   (   R   (    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyt   key_id5   s    c         C   s   t  d ƒ ‚ d S(   s®   Signs a message.

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

        Returns:
            bytes: The signature of the message.
        s   Sign must be implementedN(   R   (   R   R   (    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyt   sign:   s    (   R   R	   R
   R   t   abstractpropertyR   R   R   (    (    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyR   1   s   t   FromServiceAccountMixinc           B   sA   e  Z d  Z e j d d „ ƒ Z e d „  ƒ Z e d „  ƒ Z	 RS(   s3   Mix-in to enable factory constructors for a Signer.c         C   s   t  d ƒ ‚ d S(   sd  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.
        s   from_string must be implementedN(   R   (   t   clst   keyR   (    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyt   from_stringM   s    c         C   s8   t  | k r t d ƒ ‚ n  |  j | t  | j t ƒ ƒ S(   s‹  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.
        s@   The private_key field was not found in the service account info.(   t   _JSON_FILE_PRIVATE_KEYt
   ValueErrorR   t   gett   _JSON_FILE_PRIVATE_KEY_ID(   R   t   info(    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyt   from_service_account_info]   s
    c         C   s=   t  j | d d d ƒ } t j | ƒ } Wd QX|  j | ƒ S(   s  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.
        t   rt   encodings   utf-8N(   t   iot   opent   jsont   loadR   (   R   t   filenamet	   json_filet   data(    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyt   from_service_account_fileu   s    N(
   R   R	   R
   R   R   t   NoneR   t   classmethodR   R$   (    (    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyR   I   s
   (   R
   R   R   R   t   sixR   R   t   add_metaclasst   ABCMetat   objectR   R   R   (    (    (    sO   /var/www/syncserver/local/lib/python2.7/site-packages/google/auth/crypt/base.pyt   <module>   s   