
    &g                        S r SSKJr  SSKJrJrJrJr  SSKrSSK	J
r
  SSKJrJr  \(       a  SSKJr  SSKJr  SS	KJr  S
rSS jrg)z#MONGODB-AWS Authentication helpers.    )annotations)TYPE_CHECKINGAnyMappingTypeNBinary)ConfigurationErrorOperationFailure)_ReadableBuffer)MongoCredential)
ConnectionTc                    SSK nSSKJnJn  U" S5        UR                  S:  a  [        S5      e " S S	UR                  5      n U" UR                  U R                  U R                  U R                  R                  5      5      nUR                  S5      nS
SUS.n	UR                  SU	5      n
U
n[        S5       H>  nUR                  US   5      nS
U
S   US.nUR                  SU5      nUS   (       d  M>    g   g! [         a  n[        S5      UeSnAff = f! UR                    a)  nU" S5        [#        U SUR$                   S35      SeSnAf[&         a
    U" S5        e f = f)zAuthenticate using MONGODB-AWS.r   NzhMONGODB-AWS authentication requires pymongo-auth-aws: install with: python -m pip install 'pymongo[aws]')set_cached_credentialsset_use_cached_credentialsT	   z@MONGODB-AWS authentication requires MongoDB version 4.4 or laterc                  2    \ rS rSrSS jrSS jrS	S jrSrg)
)_authenticate_aws.<locals>.AwsSaslContext4   c                    [         $ )z#Return the bson.binary.Binary type.r   )selfs    aC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\pymongo/synchronous/auth_aws.pybinary_type5_authenticate_aws.<locals>.AwsSaslContext.binary_type6   s    M    c                .    [         R                  " U5      $ )zEncode a dictionary to BSON.)bsonencode)r   docs     r   bson_encode5_authenticate_aws.<locals>.AwsSaslContext.bson_encode:   s    ;;s##r   c                .    [         R                  " U5      $ )zDecode BSON to a dictionary.)r   decode)r   datas     r   bson_decode5_authenticate_aws.<locals>.AwsSaslContext.bson_decode>   s    ;;t$$r    N)returnzType[Binary])r   Mapping[str, Any]r(   bytes)r$   r   r(   r)   )__name__
__module____qualname____firstlineno__r   r    r%   __static_attributes__r'   r   r   AwsSaslContextr   4   s    		$	%r   r0      zMONGODB-AWS)	saslStart	mechanismpayloadz	$external
   r4   conversationId)saslContinuer6   r4   donez (pymongo-auth-aws version ))pymongo_auth_awsImportErrorr
   pymongo_auth_aws.authr   r   max_wire_versionr0   AwsCredentialusernamepasswordmechanism_propertiesaws_session_tokenstepcommandrangePyMongoAuthAwsErrorr   __version__	Exception)credentialsconnr:   er   r   r0   ctxclient_payloadclient_firstserver_firstres_cmdexcs                  r   _authenticate_awsrT       s   
 t$q  !cdd%)88 %"**$$$$00BB
 $%&]~^||K>rA XXc)n5N !"./?"@)C
 ,,{C0C6{{ W   A
 	l // t$e./?/K/K.LAN
	  t$s<   D B1D <D >D 
DDDE*/$EE*)rI   r   rJ   r   r(   None)__doc__
__future__r   typingr   r   r   r   r   bson.binaryr	   pymongo.errorsr
   r   bson.typingsr   pymongo.auth_sharedr   pymongo.synchronous.poolr   _IS_SYNCrT   r'   r   r   <module>r_      s3    * " 4 4   ?,33Dr   