o
    “nd2  ã                   @   sœ   d Z zddlZddlmZmZmZ dZW n ey'   G dd„ deƒZdZY nw ddlZddl	m
Z
 dd	lmZ dd
lmZmZ G dd„ deƒZdd„ ZdS )z#MONGODB-AWS Authentication helpers.é    N)ÚAwsCredentialÚAwsSaslContextÚPyMongoAuthAwsErrorTc                   @   s   e Zd Zdd„ ZdS )r   c                 C   s   d S )N© )ÚselfÚcredentialsr   r   úc/var/www/html/apis.geethamveg.com/public_html/venv/lib/python3.10/site-packages/pymongo/auth_aws.pyÚ__init__   s   zAwsSaslContext.__init__N)Ú__name__Ú
__module__Ú__qualname__r	   r   r   r   r   r      s    r   F©ÚBinary)ÚSON)ÚConfigurationErrorÚOperationFailurec                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )Ú_AwsSaslContextc                 C   s   t S )z#Return the bson.binary.Binary type.r   )r   r   r   r   Úbinary_type%   s   z_AwsSaslContext.binary_typec                 C   ó
   t  |¡S )zEncode a dictionary to BSON.)ÚbsonÚencode)r   Údocr   r   r   Úbson_encode)   ó   
z_AwsSaslContext.bson_encodec                 C   r   )zDecode BSON to a dictionary.)r   Údecode)r   Údatar   r   r   Úbson_decode-   r   z_AwsSaslContext.bson_decodeN)r
   r   r   r   r   r   r   r   r   r   r   #   s    r   c           
   
   C   sæ   t stdƒ‚|jdk rtdƒ‚zNtt| j| j| jjƒƒ}| 	d¡}t
ddd|fgƒ}| d|¡}|}td	ƒD ]$}| 	|d ¡}t
d
d|d fd|fgƒ}| d|¡}|d rZ W dS q6W dS  tyr }	 z	td|	tjf ƒ‚d}	~	ww )z$Authenticate using MONGODB-AWS.
    zhMONGODB-AWS authentication requires pymongo-auth-aws: install with: python -m pip install 'pymongo[aws]'é	   z@MONGODB-AWS authentication requires MongoDB version 4.4 or laterN)Ú	saslStarté   )Ú	mechanismzMONGODB-AWSÚpayloadz	$externalé
   )ÚsaslContinuer   ÚconversationIdÚdonez %s (pymongo-auth-aws version %s))Ú_HAVE_MONGODB_AWSr   Úmax_wire_versionr   r   ÚusernameÚpasswordÚmechanism_propertiesÚaws_session_tokenÚstepr   ÚcommandÚranger   r   Úpymongo_auth_awsÚ__version__)
r   Ú	sock_infoÚctxÚclient_payloadÚclient_firstÚserver_firstÚresÚ_ÚcmdÚexcr   r   r   Ú_authenticate_aws2   sJ   ÿ
ÿþ
þ
þþú	ÿ€þr:   )Ú__doc__r/   r   r   r   r&   ÚImportErrorÚobjectr   Úbson.binaryr   Úbson.sonr   Úpymongo.errorsr   r   r   r:   r   r   r   r   Ú<module>   s   ü