
    g                     6   S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSKJ	r	   " S S	\R                  5      r
S
rSr " S S\
5      r " S S\
5      r " S S\5      r " S S\5      r " S S\5      r " S S\
5      r " S S\5      r " S S\
5      rg)zExceptions for authentications.    )absolute_import)division)unicode_literalsN)
exceptions)logc                       \ rS rSrSrSrg)Error   zRoot error of this module. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       1lib/googlecloudsdk/core/credentials/exceptions.pyr	   r	      s    "r   r	   zgcloud auth loginz%gcloud auth application-default loginc                       \ rS rSrSrSrg)InvalidCredentialsException$   z;Exceptions to indicate that invalid credentials were found.r   Nr   r   r   r   r   r   $   s    Cr   r   c                   6   ^  \ rS rSrSr   SU 4S jjrSrU =r$ )AuthenticationException(   z+Exceptions that tell the users to re-login.c                   > U(       a  U(       a)  [         R                  " SR                  U[        S95      nOSU(       a$  [         R                  " SR                  US95      nO([         R                  " SR                  U[        S95      nU(       d(  [         R                  " S5      nSR                  X/5      n[        [        U ]#  U5        g )Nzf        {message}
        Please run:

          $ {login_command}

        to obtain new credentials.messagelogin_commandz        {message}
        Please run:

          $ gcloud auth activate-service-account --key-file=SERVICE_ACCOUNT_FILE_PATH

        Or:

          $ gcloud auth login --cred-file=SERVICE_ACCOUNT_FILE_PATH

        to obtain new credentials.)r   zn          {message}
          Please run:

            $ {login_command}

          to obtain new credentials.z      If you have already logged in with a different account, run:

        $ gcloud config set account ACCOUNT

      to select an already authenticated account to use.z

)	textwrapdedentformatADC_LOGIN_COMMANDAUTH_LOGIN_COMMANDjoinsuperr   __init__)selfr   for_adcshould_reloginis_service_accountswitch_account_msg	__class__s         r   r&    AuthenticationException.__init__+   s     	//& '-f/@ '- '

 // 
#& '-fWf&=
? //( )//A )/ )

 #?? ,< = W9:g	
!41':r   r   )FTFr   r   r   r   r   r&   r   __classcell__r,   s   @r   r   r   (   s    3
 4; 4;r   r   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )NoActiveAccountExceptionb   z9Exception for when there are no valid active credentials.c                    > U(       a;  [         R                  R                  U5      (       d  [        R                  " SU5        [
        [        U ]  S5        g )Nz,Could not open the configuration file: [%s].z5You do not currently have an active account selected.)ospathexistsr   warningr%   r2   r&   )r'   active_config_pathr,   s     r   r&   !NoActiveAccountException.__init__e   s@    WW^^.//B&	(	 NOr   r   )Nr.   r0   s   @r   r2   r2   b   s    AP Pr   r2   c                   8   ^  \ rS rSrSr    SU 4S jjrSrU =r$ )TokenRefreshErroro   z9An exception raised when the auth tokens fail to refresh.c                    > U(       a  SR                  XA5      nOSR                  U5      n[        [        U ]  UUUUS9  g )Nz?There was a problem refreshing auth tokens for account {0}: {1}z<There was a problem refreshing your current auth tokens: {0})r(   r)   r*   )r!   r%   r<   r&   )r'   errorr(   r)   accountr*   r   r,   s          r   r&   TokenRefreshError.__init__r   sV     
K6'!  I
O
O 
 

T+%-	 , r   r   )FTNFr.   r0   s   @r   r<   r<   o   s    A
  r   r<   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )TokenRefreshDeniedByCAAError   zERaises when token refresh is denied by context aware access policies.c                    > SSK Jn  SR                  XR                  R	                  5       5      n[
        [        U ]  XBSS9  g )Nr   )context_awarez{}

{}F)r(   r)   )googlecloudsdk.corerF   r!   ContextAwareAccessErrorGetr%   rC   r&   )r'   r?   r(   rF   compiled_msgr,   s        r   r&   %TokenRefreshDeniedByCAAError.__init__   sD    1$$4488:<L 

&6e 7 =r   r   Fr.   r0   s   @r   rC   rC      s    M= =r   rC   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )ReauthenticationException   zFExceptions that tells the user to retry his command or run auth login.c           	         > U(       a  [         O[        n[        [        U ]  [
        R                  " SR                  XS95      5        g )Nz|        {message}
        Please retry your command or run:

          $ {login_command}

        to obtain new credentials.r   )r"   r#   r%   rN   r&   r   r    r!   )r'   r   r(   r   r,   s       r   r&   "ReauthenticationException.__init__   sC    )0%6HM	
#T3 & '-f '- ':	;<r   r   rL   r.   r0   s   @r   rN   rN      s    N
< 
<r   rN   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )TokenRefreshReauthError   zGAn exception raised when the auth tokens fail to refresh due to reauth.c                 J   > SR                  U5      n[        [        U ]  X2S9  g )NzSThere was a problem reauthenticating while refreshing your current auth tokens: {0})r(   )r!   r%   rS   r&   )r'   r?   r(   r   r,   s       r   r&    TokenRefreshReauthError.__init__   s)    *+16%= 	
!41'1Kr   r   rL   r.   r0   s   @r   rS   rS      s    OL Lr   rS   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )WebLoginRequiredReauthError   a  An exception raised when login through browser is required for reauth.

This applies to SAML users who set password as their reauth method today.
Since SAML uers do not have knowledge of their Google password, we require
web login and allow users to be authenticated by their IDP.
c                    > U(       a  [         O[        n[        [        U ]  [
        R                  " SR                  US95      5        g )NzW        Please run:

          $ {login_command}

        to complete reauthentication.)r   )r"   r#   r%   rX   r&   r   r    r!   )r'   r(   r   r,   s      r   r&   $WebLoginRequiredReauthError.__init__   s?    )0%6HM	
%t5 )
 *0m)L	NOr   r   rL   r.   r0   s   @r   rX   rX      s    O Or   rX   )r   
__future__r   r   r   r5   r   rG   r   r   r	   r#   r"   r   r   r2   r<   rC   rN   rS   rX   r   r   r   <module>r]      s    & &  ' 	  * ##J # ) ; D% D7;e 7;t
P6 
P/ <=#4 =< < L7 LO% Or   