
                         P   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	J
r
  Sr\R                  " \ R                  5       " S S\5      5       r " S S\5      r " S S	\5      r " S
 S\5      r\" 5       \" 5       \" 5       4 V s0 s H  n U R&                  U _M     sn rgs  sn f )    N)_helperserrorszhttps://accounts.google.comc                       \ rS rSrSr\\R                  S 5       5       r\\R                  S 5       5       r	\R                  S 5       r
Srg)ReauthChallenge   z!Base class for reauth challenges.c                     g)z"Returns the name of the challenge.N selfs    3platform/bq/third_party/google_reauth/challenges.pynameReauthChallenge.name#        	    c                     g)zAReturns true if a challenge is supported locally on this machine.Nr	   r
   s    r   is_locally_eligible#ReauthChallenge.is_locally_eligible)   r   r   c                     g)a  Performs logic required to obtain credentials and returns it.

Args:
    metadata: challenge metadata returned in the 'challenges' field in
        the initial reauth request. Includes the 'challengeType' field
        and other challenge-specific fields.

Returns:
    response that will be send to the reauth service as the content of
    the 'proposalResponse' field in the request body. Usually a dict
    with the keys specific to the challenge. For example,
    {'credential': password} for password challenge.
Nr	   r   metadatas     r   obtain_challenge_input&ReauthChallenge.obtain_challenge_input/   s     	r   r	   N)__name__
__module____qualname____firstlineno____doc__propertyabcabstractmethodr   r   r   __static_attributes__r	   r   r   r   r      sa    +      	 r   r   c                   >    \ rS rSrSr\S 5       r\S 5       rS rSr	g)PasswordChallengeA   z(Challenge that asks for user's password.c                     g)NPASSWORDr	   r
   s    r   r   PasswordChallenge.nameD   s    r   c                     gNTr	   r
   s    r   r   %PasswordChallenge.is_locally_eligibleH       r   c                 H    [         R                  " S5      nU(       d  SnSU0$ )NzPlease enter your password: 
credential)r   get_user_password)r   unused_metadatapasswds      r   r   (PasswordChallenge.obtain_challenge_inputL   s&    ++,IJFf%%r   r	   N
r   r   r   r   r   r   r   r   r   r!   r	   r   r   r#   r#   A   s0    2   &r   r#   c                   >    \ rS rSrSr\S 5       r\S 5       rS rSr	g)SecurityKeyChallengeS   z2Challenge that asks for user's security key touch.c                     g)NSECURITY_KEYr	   r
   s    r   r   SecurityKeyChallenge.nameV   s    r   c                     gr)   r	   r
   s    r   r   (SecurityKeyChallenge.is_locally_eligibleZ   r+   r   c                 (   US   nUS   nUS   n/ nU H  nUS   R                  S5      n[        R                  R                  [	        [
        R                  " U5      5      5      nUS   R                  S5      n	[
        R                  " U	5      n	UR                  XS.5        M      [        R                  R                  R                  [        5      n
U
R                  XE[        R                  R                  S9nSU0$ ! [        R                   R"                   a  nUR$                  [        R                   R"                  R&                  :X  a$  [        R                  R                  S	5         S nAg UR$                  [        R                   R"                  R(                  :X  a$  [        R                  R                  S
5         S nAg UeS nAf[        R                   R*                   a"    [        R                  R                  S5         g f = f)NsecurityKey
challengesapplicationId	keyHandleascii	challenge)keyrB   )print_callbackzIneligible security key.
z0Timed out while waiting for security key touch.
zNo security key found.
)encodepyu2fmodelRegisteredKey	bytearraybase64urlsafe_b64decodeappendconvenienceauthenticatorCreateCompositeAuthenticatorREAUTH_ORIGINAuthenticatesysstderrwriter   U2FErrorcodeDEVICE_INELIGIBLETIMEOUTNoDeviceFoundError)r   r   skr>   app_idchallenge_datackhrC   rB   apiresponsees                r   r   +SecurityKeyChallenge.obtain_challenge_input^   s   m$%
O$A;&&w/B++++&222679C+--g6I00;I!!#"FG 	9##11NNC''7:zz7G7G ( IH!8,,||$$ 	vv..@@@

  !=>>  5<<00888

  GI I  ||.. 	9JJ78	9s.   )AD H AG6AGGA HHr	   Nr3   r	   r   r   r5   r5   S   s0    <   r   r5   c                   >    \ rS rSrSr\S 5       r\S 5       rS rSr	g)SamlChallenge   z>Challenge that asks the users to browse to their ID Providers.c                     g)NSAMLr	   r
   s    r   r   SamlChallenge.name   s    r   c                     gr)   r	   r
   s    r   r   !SamlChallenge.is_locally_eligible   r+   r   c                 ,    [         R                  " 5       e)N)r   ReauthSamlLoginRequiredErrorr   s     r   r   $SamlChallenge.obtain_challenge_input   s     1133r   r	   Nr3   r	   r   r   rd   rd      s0    H   4r   rd   )r   rJ   rR   pyu2f.convenience.authenticatorrF   pyu2f.errorspyu2f.modelsixgoogle_reauthr   r   rP   add_metaclassABCMetaobjectr   r#   r5   rd   r   AVAILABLE_CHALLENGES)rB   s   0r   <module>rw      s       
 &   
 * . 3;;f   B& &$)? )X4O 4* 		 NNI  s   B#