
    oh                     J   d Z ddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z,m-Z- ddl.m/Z/m0Z0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7  G d	 d
      Z8 G d d      Z9 G d de8      Z:y)z
`.AuthHandler`
    N)#cMSG_SERVICE_REQUESTcMSG_DISCONNECT DISCONNECT_SERVICE_NOT_AVAILABLE)DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLEcMSG_USERAUTH_REQUESTcMSG_SERVICE_ACCEPTDEBUGAUTH_SUCCESSFULINFOcMSG_USERAUTH_SUCCESScMSG_USERAUTH_FAILUREAUTH_PARTIALLY_SUCCESSFULcMSG_USERAUTH_INFO_REQUESTWARNINGAUTH_FAILEDcMSG_USERAUTH_PK_OKcMSG_USERAUTH_INFO_RESPONSEMSG_SERVICE_REQUESTMSG_SERVICE_ACCEPTMSG_USERAUTH_REQUESTMSG_USERAUTH_SUCCESSMSG_USERAUTH_FAILUREMSG_USERAUTH_BANNERMSG_USERAUTH_INFO_REQUESTMSG_USERAUTH_INFO_RESPONSEcMSG_USERAUTH_GSSAPI_RESPONSEcMSG_USERAUTH_GSSAPI_TOKENcMSG_USERAUTH_GSSAPI_MICMSG_USERAUTH_GSSAPI_RESPONSEMSG_USERAUTH_GSSAPI_TOKENMSG_USERAUTH_GSSAPI_ERRORMSG_USERAUTH_GSSAPI_ERRTOKMSG_USERAUTH_GSSAPI_MIC	MSG_NAMEScMSG_USERAUTH_BANNER)Message)bu)SSHExceptionAuthenticationExceptionBadAuthenticationTypePartialAuthentication)InteractiveQuery)GSSAuthGSS_EXCEPTIONSc                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d%d	Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"e#d!        Z$e#d"        Z%e#d#        Z&y$)&AuthHandlerzC
    Internal class to handle the mechanics of authentication.
    c                     t        j                  |      | _        d | _        d| _        d | _        d| _        d | _        d | _        d | _	        d | _
        d | _        d | _        d| _        d | _        d| _        y )NF r   T)weakrefproxy	transportusernameauthenticated
auth_eventauth_methodbannerpasswordprivate_keyinteractive_handler
submethodsauth_usernameauth_fail_countgss_hostgss_deleg_creds)selfr6   s     g/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/paramiko/auth_handler.py__init__zAuthHandler.__init__R   st     y1"#' ! #    c                 4     | j                   j                  | S N)r6   _log)rD   argss     rE   rJ   zAuthHandler._logd   s    "t~~""D))rG   c                     | j                   S rI   )r8   rD   s    rE   is_authenticatedzAuthHandler.is_authenticatedg   s    !!!rG   c                 ^    | j                   j                  r| j                  S | j                  S rI   )r6   server_moder@   r7   rM   s    rE   get_usernamezAuthHandler.get_usernamej   s%    >>%%%%%== rG   c                 2   | j                   j                  j                          	 || _        d| _        || _        | j                          | j                   j                  j                          y # | j                   j                  j                          w xY wNnoner6   lockacquirer9   r:   r7   _request_authreleaserD   r7   events      rE   	auth_nonezAuthHandler.auth_nonep   sl    ##%	*#DO%D$DM NN'')DNN'')   %A0 0&Bc                 @   | j                   j                  j                          	 || _        d| _        || _        || _        | j                          | j                   j                  j                          y # | j                   j                  j                          w xY w)N	publickey)	r6   rV   rW   r9   r:   r7   r=   rX   rY   )rD   r7   keyr[   s       rE   auth_publickeyzAuthHandler.auth_publickeyz   st    ##%	*#DO*D$DM"D NN'')DNN'')   ,A7 7&Bc                 @   | j                   j                  j                          	 || _        d| _        || _        || _        | j                          | j                   j                  j                          y # | j                   j                  j                          w xY w)Nr<   )	r6   rV   rW   r9   r:   r7   r<   rX   rY   )rD   r7   r<   r[   s       rE   auth_passwordzAuthHandler.auth_password   ss    ##%	*#DO)D$DM$DM NN'')DNN'')rb   c                 N   | j                   j                  j                          	 || _        d| _        || _        || _        || _        | j                          | j                   j                  j                          y# | j                   j                  j                          w xY w)K
        response_list = handler(title, instructions, prompt_list)
        keyboard-interactiveN)
r6   rV   rW   r9   r:   r7   r>   r?   rX   rY   )rD   r7   handlerr[   r?   s        rE   auth_interactivezAuthHandler.auth_interactive   s}     	##%	*#DO5D$DM'.D$(DO NN'')DNN'')   3A> >&B$c                 N   | j                   j                  j                          	 || _        d| _        || _        || _        || _        | j                          | j                   j                  j                          y # | j                   j                  j                          w xY w)Ngssapi-with-mic)
r6   rV   rW   r9   r:   r7   rB   rC   rX   rY   )rD   r7   rB   rC   r[   s        rE   auth_gssapi_with_micz AuthHandler.auth_gssapi_with_mic   s{    ##%	*#DO0D$DM$DM#2D  NN'')DNN'')rj   c                 2   | j                   j                  j                          	 || _        d| _        || _        | j                          | j                   j                  j                          y # | j                   j                  j                          w xY w)Ngssapi-keyexrU   rZ   s      rE   auth_gssapi_keyexzAuthHandler.auth_gssapi_keyex   sl    ##%	*#DO-D$DM NN'')DNN'')r]   c                 R    | j                   | j                   j                          y y rI   )r9   setrM   s    rE   abortzAuthHandler.abort   s!    ??&OO! 'rG   c                     t               }|j                  t               |j                  d       | j                  j                  |       y Nssh-userauth)r&   add_byter   
add_stringr6   _send_messagerD   ms     rE   rX   zAuthHandler._request_auth   s4    I	

'(	^$$$Q'rG   c                    t               }|j                  t               |j                  t               |j                  d       |j                  d       | j                  j                  |       | j                  j                          y )NzService not availableen)	r&   rw   r   add_intr   rx   r6   ry   closerz   s     rE   !_disconnect_service_not_availablez-AuthHandler._disconnect_service_not_available   s]    I	

?#			23	,-	T$$Q'rG   c                    t               }|j                  t               |j                  t               |j                  d       |j                  d       | j                  j                  |       | j                  j                          y )NzNo more auth methods availabler}   )	r&   rw   r   r~   r   rx   r6   ry   r   rz   s     rE   _disconnect_no_more_authz$AuthHandler._disconnect_no_more_auth   s]    I	

?#			;<	56	T$$Q'rG   c                     |j                   r,|j                   j                  |j                   j                  fS |j                         |fS )z
        Given any key, return its type/algorithm & bits-to-sign.

        Intended for input to or verification of, key signatures.
        )public_blobkey_typekey_blobget_name)rD   r`   s     rE   _get_key_type_and_bitsz"AuthHandler._get_key_type_and_bits   s;     ????++S__-E-EEE<<>3&&rG   c                    t               }|j                  | j                  j                         |j	                  t
               |j                  |       |j                  |       |j                  d       |j                  d       | j                  |      \  }}|j                  |       |j                  |       |j                         S )Nr_   T)	r&   rx   r6   
session_idrw   r   add_booleanr   asbytes)rD   r`   servicer7   	algorithmr{   _bitss           rE   _get_session_blobzAuthHandler._get_session_blob   s    I	T^^../	

()	X	W	[!	d--c24	Y	Tyy{rG   c                    d }| j                   j                  +t        j                         | j                   j                  z   }	 |j                  d       | j                   j	                         sC| j                   j                         }|t        |j                  t              rt        d      }||j                         rn%|"|t        j                         k  rt        d      | j                         sO| j                   j                         }|t        d      }t        |j                  t              r|j                  S |g S )Ng?z5Authentication failed: transport shut down or saw EOFzAuthentication timeout.zAuthentication failed.)r6   auth_timeouttimewait	is_activeget_exception
issubclass	__class__EOFErrorr*   is_setrN   r,   allowed_types)rD   r[   max_tses       rE   wait_for_responsezAuthHandler.wait_for_response   s   >>&&2YY[4>>#>#>>FJJsO>>++-NN002I*Q[[("C/OA ||~!f		&;-.GHH  $$&,,.Ay+,DE !++'<=&G	rG   c                    |j                         }| j                  j                  r|dk(  rt               }|j	                  t
               |j                  |       | j                  j                  |       | j                  j                  j                         \  }}|r\t               }|j	                  t               |j                  |       |j                  |       | j                  j                  |       y | j                          y ru   )get_textr6   rP   r&   rw   r   rx   ry   server_object
get_bannerr%   r   )rD   r{   r   r;   languages        rE   _parse_service_requestz"AuthHandler._parse_service_request
  s    **,>>%%7n+D	AJJ*+LL!NN((+#~~;;FFHFHI

/0V$X&,,Q/..0rG   c                     | j                   j                  }|j                  dd      |vr(d}| j                  t        |j                  |             y  | j                   j                  |   t        |            S )N-cert-v01@openssh.comr3   z<Auth rejected: pubkey algorithm '{}' unsupported or disabled)r6   preferred_pubkeysreplacerJ   r   format	_key_infor&   )rD   r   keybloboptionserrs        rE   _generate_key_from_requestz&AuthHandler._generate_key_from_request  sl    ..224b9HN  IIdCJJy122t~~''	2773CDDrG   c                     |d   }d}| j                  t        |j                  |             | j                  t        d       |S )Nr   zYServer did not send a server-sig-algs list; defaulting to our first preferred algo ({!r})zNOTE: you may use the 'disabled_algorithms' SSHClient/Transport init kwarg to disable that or other algorithms if your server does not support them!)rJ   r	   r   )rD   r   my_algospubkey_algomsgs        rE   !_choose_fallback_pubkey_algorithmz-AuthHandler._choose_fallback_pubkey_algorithm(  sD    qki		%K01		 c	
 rG   c                    d|vr|S | j                  t        dj                  |             |j                  d      rzt	        j
                  d| j                  j                        rPd}|| j                  _        | j                  t        d       | j                  t        dj                  |             |S | j                  j                  D cg c]	  }d|v s| }}| j                  t        dj                  |             |st        d	      t        | j                  j                  j                  d
t        d                  }d }|r|j                  d      }| j                  t        dj                  |             t!        t#        |j$                  |            }|r+|d   }| j                  t        dj                  |             nD| j                  t        d       d}t'        |j                  |            | j)                  ||      }|j                  d      r|dz  }|| j                  _        |S c c}w )Nrsaz0Finalizing pubkey algorithm for key of type {!r}r   z-OpenSSH_(?:[1-6]|7\.[0-7])zssh-rsa-cert-v01@openssh.comz)OpenSSH<7.8 + RSA cert = forcing ssh-rsa!z!Agreed upon {!r} pubkey algorithmzOur pubkey algorithm list: {}zFAn RSA key was specified, but no RSA pubkey algorithms are configured!zserver-sig-algsr3   ,zServer-side algorithm list: {}r   z)No common pubkey algorithms exist! Dying.z=Unable to agree on a pubkey algorithm for signing a {!r} key!)rJ   r	   r   endswithresearchr6   remote_version_agreed_pubkey_algorithmr   r)   r(   server_extensionsgetr'   splitlistfilter__contains__r*   r   )	rD   r   r   xr   server_algo_strserver_algos	agreementr   s	            rE   _finalize_pubkey_algorithmz&AuthHandler._finalize_pubkey_algorithm3  s    O		>EE	
 45"))*DNN,I,I;
 9K6ADNN3IIeHIII:AA+N   $~~??N!5A:ANN		%8??IJX  NN,,001BAbEJ
 *005LII7>>|L VL$=$=xHII'l		7>>{K
 		%!LM V-cjj.BCC @@(K 4522K2=/U Os   	H<H<c                    |j                         }|dk(  r| j                  t        d       t               }|j	                  t
               |j                  | j                         |j                  d       |j                  | j                         | j                  dk(  r9|j                  d       t        | j                        }|j                  |       n| j                  dk(  r|j                  d       | j                  | j                        \  }}| j                  |      }|j                  |       |j                  |       | j                  | j                  d| j                  |      }| j                  j!                  ||      }|j                  |       n| j                  dk(  r.|j                  d	       |j                  | j"                         n| j                  d
k(  rt%        | j                  | j&                        }	|j)                  |	j+                                | j,                  j/                  |       | j,                  j0                  j3                         \  }
}|
t4        k(  r8| j7                  |       | j,                  j0                  j3                         \  }
}|
t8        k(  r|j;                         }t               }|j	                  t<               	 |j                  |	j?                  | j@                  || j                               | j,                  j/                  |       	 | j,                  j0                  j3                         \  }
}|
tF        k(  r|j;                         }	 |	j?                  | j@                  || j                  |      }|nLt               }|j	                  t<               |j                  |       | j,                  jI                  |       t               }|j	                  tP               |j                  |	jS                  | j,                  jT                               nv|
tV        k(  rtK        d      |
tX        k(  r\|j[                         }|j[                         }|j;                         }|j;                          tK        djM                  |||            |
t\        k(  r| j_                  |       y tK        djM                  tN        |
               | j                  dk(  r~| j,                  j`                  rh| j,                  jb                  }|je                  | j                         |jS                  | j,                  jT                        }|j                  |       n4| j                  dk(  rn$tK        djM                  | j                              | j,                  j/                  |       y | j                  t        djM                  |             y # tB        $ r}| jE                  |      cY d }~S d }~ww xY w# tB        $ r}| jE                  |      cY d }~S d }~ww xY w)Nrv   zuserauth is OKssh-connectionr<   Fr_   Trg   r3   rl   zReceived Package: {}zServer returned an error tokenzCGSS-API Error:
Major Status: {}
Minor Status: {}
Error Message: {}
ro   rT   zUnknown auth method "{}"z!Service request "{}" accepted (?))3r   rJ   r	   r&   rw   r   rx   r7   r:   r   r'   r<   r   r=   r   r   sign_ssh_datar?   r.   rC   	add_bytesssh_gss_oidsr6   ry   
packetizerread_messager   _parse_userauth_bannerr   
get_stringr   ssh_init_sec_contextrB   r/   _handle_local_gss_failurer    send_messager)   r   r$   r   ssh_get_micr   r"   r!   get_intr   _parse_userauth_failuregss_kex_usedkexgss_ctxtset_username)rD   r{   r   r<   r   r   r   blobsigsshgssptypemechr   	srv_token
next_token
maj_status
min_statuserr_msgkexgss	mic_tokens                       rE   _parse_service_acceptz!AuthHandler._parse_service_accept{  s
   **,n$IIe-.	AJJ,-LL'LL)*LL))*:-e$T]]+X&!![0d#!%!<!<T=M=M!N$ ;;HE	Y'T"--$$$MM	 &&44T9ES!!!%;;R T__-!!%66 !1!143G3GHF//12,,Q/>>44AACq////2#~~88EEGHE188 <<>D	AJJ9:A"77 $tT]] NN003#'>>#<#<#I#I#Kq $==()II-3-H-H$(MM$($(MM$-	."
  *1 %$+I !

+E F !Z 8 $ ; ;A >- 6  	AJJ78LL!3!3DNN4M4M!NO88
 ''GHH77!"J!"JllnGLLN& F&
G  22003&.55i6FG    N2NN//33##DMM2"..t~~/H/HI	Y'!!V+".55d6F6FG  NN((+II:AA'J[ * A#==a@@A $2 I'+'E'Ea'H HIs<   ,6X ?(X* 	X'X"X'"X'*	Y3Y	Y	Yc                    t               }|t        k(  rB| j                  t        dj	                  |             |j                  t               d| _        n| j                  t        dj	                  |             |j                  t               |j                  | j                  j                  j                  |             |t        k(  r|j                  d       n&|j                  d       | xj                  dz  c_        | j                  j!                  |       | j                  dk\  r| j#                          |t        k(  r| j                  j%                          y y )NzAuth granted ({}).TzAuth rejected ({}).F   
   )r&   r
   rJ   r   r   rw   r   r8   r   rx   r6   r   get_allowed_authsr   r   rA   ry   r   _auth_trigger)rD   r7   methodresultr{   s        rE   _send_auth_resultzAuthHandler._send_auth_result   s   I_$IId077?@JJ,-!%DIId188@AJJ,-LL,,>>xH 22d#e$$$)$$$Q'2%))+_$NN((* %rG   c                    t               }|j                  t               |j                  |j                         |j                  |j
                         |j                  t                      |j                  t        |j                               |j                  D ]*  }|j                  |d          |j                  |d          , | j                  j                  |       y )Nr   r   )r&   rw   r   rx   nameinstructionsbytesr~   lenpromptsr   r6   ry   )rD   qr{   ps       rE   _interactive_queryzAuthHandler._interactive_query  s    I	

-.	QVV	Q^^$	UW			#aii.! 	 ALL1MM!A$	  	$$Q'rG   c           	      |   | j                   j                  s]t               }|j                  t               |j                  d       |j                  d       | j                   j                  |       y | j                  ry |j                         }|j                         }|j                         }| j                  t        dj                  |||             |dk7  r| j                          y | j                  6| j                  |k7  r'| j                  t        d       | j!                          y || _        | j                   j"                  j%                         }|dk(  r'| j                   j"                  j'                  |      }nE|dk(  r|j)                         }|j+                         }	 |j-                  d      }|rA| j                  t        d       |j+                         }		 |	j-                  dd	      }	t0        }n| j                   j"                  j3                  ||      }n|d
k(  rC|j)                         }
|j                         }|j+                         }	 | j5                  ||      }|| j!                          y | j                   j"                  jC                  ||      }|t0        k7  r|
s]t               }|j                  tD               |j                  |       |j                  |       | j                   j                  |       y t        |j+                               }| jG                  ||||      }|jI                  ||      sx| j                  t8        d       t0        }nZ|dk(  rY|jK                         }| j                   j"                  jM                  ||      }tO        |tP              r| jS                  |       y |dk(  r*|r'tU        |      }|jW                         }|dkD  r&| j                  t8        d       | j!                          |jK                         }|jY                  |      }|s&| j                  t8        d       | j!                          |j[                  d      }t               }|j                  t\               |j_                  |       ta        | |      | j                   _1        td        tf        th        f| j                   _5        | j                   j                  |       y |dk(  r|r|jK                         }| j                   jl                  }|t0        }| jo                  |||       	 |jq                  || j                   jr                  | j                         tt        }| j                   j"                  jw                  ||       n%| j                   j"                  j'                  |      }| jo                  |||       y # t.        $ r Y .w xY w# t.        $ r Y w xY w# t6        $ r;}| j                  t8        dj                  t;        |                   d }Y d }~d }~wt<        $ rI}d}| j                  t8        |j                  |j>                  j@                  |             d }Y d }~d }~ww xY w# t<        $ r t0        }| jo                  |||        w xY w)NrT   Fz.Auth request (type={}) service={}, username={}r   zKAuth rejected because the client attempted to change username in mid-flightr<   zUTF-8z+Auth request to change passwords (rejected)r   r_   zAuth rejected: public key: {}z9Auth rejected: unsupported or mangled public key ({}: {})z Auth rejected: invalid signaturerg   rl   r   z8Disconnect: Received more than one GSS-API OID mechanismz5Disconnect: Received an invalid GSS-API OID mechanismserverro   )<r6   rP   r&   rw   r   rx   r   ry   r8   r   rJ   r	   r   r   r@   r   r   r   enable_auth_gssapicheck_auth_noneget_boolean
get_binarydecodeUnicodeErrorr   check_auth_passwordr   r)   r   str	Exceptionr   __name__check_auth_publickeyr   r   verify_ssh_sigr   check_auth_interactive
isinstancer-   r   r.   r   ssh_check_mechr   r   r   GssapiWithMicAuthHandlerauth_handlerr    r   r   _expected_packetr   r   ssh_check_micr   r
   check_auth_gssapi_keyex)rD   r{   r7   r   r   gss_authr   	changereqr<   newpasswordsig_attachedr   r   r`   r   r   r   r   r?   r   mechsdesired_mechmech_oksupported_mechr   s                            rE   _parse_userauth_requestz#AuthHandler._parse_userauth_request%  s   ~~))	AJJ,-LL MM% NN((+::<**,		<CC	
 &&224*(*II] ))+%>>//BBDV^^11AA(KFz!I||~H#??73
  		%!NOlln"-"4"4Wi"HK %55IIh {"==?L 

IllnG55iI {--/^^11FF#F $#  	AJJ23LL+LL)NN003alln---(I ))$4IId$FG(F--J^^11HH*F &"23''/((XV_F IIKE qy		N --/<<>L++L9G		K --/#00:N 	AJJ45KK'*Bf+DNN' *$#/DNN+
 NN((+~%(I^^//F~$&&x@$$t~~88$:L:L %FNN((@@& ^^11AA(KFx8G     $     		$ ? F Fs1v NO Q		$

1;;+?+? CDr  $&&x@sT   -W  'W0  X  	1Z  	W-,W-0	W=<W= 	Z	0X??Z>ZZ$Z;c                     | j                  t        dj                  | j                               d| _        | j
                  j                          | j                  | j                  j                          y y )NzAuthentication ({}) successful!T)	rJ   r   r   r:   r8   r6   r   r9   rr   rz   s     rE   _parse_userauth_successz#AuthHandler._parse_userauth_success  s^    		3::4;K;KL	
 "$$&??&OO! 'rG   c                    |j                         }|j                         }|rS| j                  t        d       | j                  t        dt        |      z          t        |      | j                  _        n| j                  |vrcdj                  | j                        dj                  |      fD ]  }| j                  t        |        t        d|      | j                  _        n/| j                  t        dj                  | j                               d| _        d | _        | j                  | j                  j                          y y )NzAuthentication continues...z	Methods: z'Authentication type ({}) not permitted.zAllowed methods: {}zBad authentication typeAuthentication ({}) failed.F)get_listr   rJ   r   r	   r  r,   r6   saved_exceptionr:   r   r+   r8   r7   r9   rr   )rD   r{   authlistpartialr   s        rE   r   z#AuthHandler._parse_userauth_failure  s   ::< --/IId9:IIe[3x=89-B8-LDNN*X-9@@$$ &,,X6	 & 		%%& .C)8.DNN* II3::4;K;KL #??&OO! 'rG   c                 |    |j                         }|| _        | j                  t        dj	                  |             y )NzAuth banner: {})r   r;   rJ   r   r   )rD   r{   r;   s      rE   r   z"AuthHandler._parse_userauth_banner  s.    		$)0089rG   c                 8   | j                   dk7  rt        d      |j                         }|j                         }|j                          |j	                         }g }t        |      D ]1  }|j                  |j                         |j                         f       3 | j                  |||      }t               }|j                  t               |j                  t        |             |D ]  }|j                  |        | j                  j!                  |       y )Nrg   z Illegal info request from server)r:   r)   r   r   r   rangeappendr   r>   r&   rw   r   r~   r   rx   r6   ry   )	rD   r{   titler   r   prompt_listiresponse_listrs	            rE   _parse_userauth_info_requestz(AuthHandler._parse_userauth_info_request  s    55ABB

zz|	))+w 	@A

ammo>?	@00<
 I	

./			#m$% 	ALLO	$$Q'rG   c                    | j                   j                  st        d      |j                         }g }t	        |      D ]!  }|j                  |j                                # | j                   j                  j                  |      }t        |t              r| j                  |       y | j                  | j                  d|       y )Nz!Illegal info response from serverrg   )r6   rP   r)   r   r!  r"  r   r   check_auth_interactive_responser  r-   r   r   r@   )rD   r{   n	responsesr%  r   s         rE   _parse_userauth_info_responsez)AuthHandler._parse_userauth_info_response  s    ~~))BCCIIK	q 	+AQZZ\*	+--MM
 f./##F+ 6	
rG   c                 6   || j                   _        | j                  t        dj	                  |             | j                  t
        dj	                  | j                               d| _        d | _        | j                  | j                  j                          y )NzGSSAPI failure: {}r  F)r6   r  rJ   r	   r   r   r:   r8   r7   r9   rr   )rD   r   s     rE   r   z%AuthHandler._handle_local_gss_failure*  st    )*&		%-44Q78		$5<<T=M=MNO"??&OO!rG   c                 f    t         | j                  t        | j                  t        | j
                  iS rI   )r   r   r   r  r   r-  rM   s    rE   _server_handler_tablez!AuthHandler._server_handler_table<  s/      !<!< $">">&(J(J
 	
rG   c           
          t         | j                  t        | j                  t        | j
                  t        | j                  t        | j                  iS rI   )
r   r   r   r  r   r   r   r   r   r(  rM   s    rE   _client_handler_tablez!AuthHandler._client_handler_tableH  sE      : : $">"> $">">!<!<%t'H'H
 	
rG   c                 ^    | j                   j                  r| j                  S | j                  S rI   )r6   rP   r0  r2  rM   s    rE   _handler_tablezAuthHandler._handler_tableT  s'    >>%%------rG   Nr3   )'r  
__module____qualname____doc__rF   rJ   rN   rQ   r\   ra   rd   ri   rm   rp   rs   rX   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r   r(  r-  r   propertyr0  r2  r4   rG   rE   r1   r1   M   s    $$*"!*	*	**
**"(
'<1&	E	FPCJ+0(o9b""<:(*
$$ 
 
 
 
 . .rG   r1   c                       e Zd ZdZdZd Zd Zed        Zed        Z	ed        Z
ed        Zd	 Zd
 Zd Zd Zd ZeeeeeeeeiZed        Zy)r	  zA specialized Auth handler for gssapi-with-mic

    During the GSSAPI token exchange we need a modified dispatch table,
    because the packet type numbers are not unique.
    rl   c                      || _         || _        y rI   )	_delegater   )rD   delegater   s      rE   rF   z!GssapiWithMicAuthHandler.__init__e  s    !rG   c                 V    | j                          | j                  j                         S rI   )_restore_delegate_auth_handlerr=  rs   rM   s    rE   rs   zGssapiWithMicAuthHandler.aborti  s!    ++-~~##%%rG   c                 .    | j                   j                  S rI   )r=  r6   rM   s    rE   r6   z"GssapiWithMicAuthHandler.transportm  s    ~~'''rG   c                 .    | j                   j                  S rI   )r=  r   rM   s    rE   r   z*GssapiWithMicAuthHandler._send_auth_resultq  s    ~~///rG   c                 .    | j                   j                  S rI   )r=  r@   rM   s    rE   r@   z&GssapiWithMicAuthHandler.auth_usernameu  s    ~~+++rG   c                 .    | j                   j                  S rI   )r=  rB   rM   s    rE   rB   z!GssapiWithMicAuthHandler.gss_hosty  s    ~~&&&rG   c                 :    | j                   | j                  _        y rI   )r=  r6   r
  rM   s    rE   r@  z7GssapiWithMicAuthHandler._restore_delegate_auth_handler}  s    &*nn#rG   c                 (   |j                         }| j                  }	 |j                  | j                  || j                        }|lt               }|j                  t               |j                  |       t         t"        t$        f| j                  _        | j                  j)                  |       y y # t
        $ rT}|| j                  _        t        }| j                          | j                  | j                  | j                  |        d }~ww xY wrI   )r   r   ssh_accept_sec_contextrB   r@   r  r6   r  r   r@  r   r   r&   rw   r   rx   r    r#   r   r  ry   )rD   r{   client_tokenr   tokenr   r   s          rE   _parse_userauth_gssapi_tokenz5GssapiWithMicAuthHandler._parse_userauth_gssapi_token  s    ||~ 		11|T-?-?E 	AJJ12LL)'$/DNN+
 NN((+   	-.DNN* F//1""4#5#5t{{FK	s   'B4 4	D=ADDc                    |j                         }| j                  }| j                  }| j                          	 |j	                  || j
                  j                  |       t        }| j
                  j                  j                  ||       | j                  || j                  |       y # t        $ r:}|| j
                  _        t        }| j                  || j                  |        d }~ww xY wrI   )r   r   r@   r@  r  r6   r   r  r  r   r   r   r
   r   check_auth_gssapi_with_mic)rD   r{   r   r   r7   r   r   s          rE   _parse_userauth_gssapi_micz3GssapiWithMicAuthHandler._parse_userauth_gssapi_mic  s    LLN	%%++-	  4>>44h !$$??f	
 	xf=  	-.DNN* F""8T[[&A		s   'B+ +	C.45C))C.c                 X    | j                          | j                  j                  |      S rI   )r@  r=  r   rz   s     rE   r   z/GssapiWithMicAuthHandler._parse_service_request  s#    ++-~~44Q77rG   c                 X    | j                          | j                  j                  |      S rI   )r@  r=  r  rz   s     rE   r  z0GssapiWithMicAuthHandler._parse_userauth_request  s#    ++-~~55a88rG   c                     | j                   S rI   )(_GssapiWithMicAuthHandler__handler_tablerM   s    rE   r4  z'GssapiWithMicAuthHandler._handler_table  s     ###rG   N)r  r6  r7  r8  r   rF   rs   r9  r6   r   r@   rB   r@  rJ  rM  r   r  r   r   r    r#   rQ  r4  r:  rG   rE   r	  r	  \  s     F& ( ( 0 0 , , ' '5,4>089
 	35!#?!;	O $ $rG   r	  c                   T     e Zd ZdZe fd       Zd	dZd Zd Zd Z	d
dZ
d Z xZS )AuthOnlyHandlerzU
    AuthHandler, and just auth, no service requests!

    .. versionadded:: 3.2
    c                 F    t         |   j                         }|t        = |S rI   )superr2  copyr   )rD   my_tabler   s     rE   r2  z%AuthOnlyHandler._client_handler_table  s$    70557'(rG   c                    || _         || _        t               }|j                  t               |j                  |       |j                  d       |j                  |        ||       | j                  j                  5  | j                  j                  |       ddd       t        j                         | _        | j                  | j                        S # 1 sw Y   =xY w)a  
        Submit a userauth request message & wait for response.

        Performs the transport message send call, sets self.auth_event, and
        will lock-n-block as necessary to both send, and wait for response to,
        the USERAUTH_REQUEST.

        Most callers will want to supply a callback to ``finish_message``,
        which accepts a Message ``m`` and may call mutator methods on it to add
        more fields.
        r   N)r:   r7   r&   rw   r   rx   r6   rV   ry   	threadingEventr9   r   )rD   r7   r   finish_messager{   s        rE   send_auth_requestz!AuthOnlyHandler.send_auth_request  s     " I	

()	X	%&	Vq ^^   	,NN((+	, $//+%%doo66	, 	,s   ?CC c                 &    | j                  |d      S rS   r\  )rD   r7   s     rE   r\   zAuthOnlyHandler.auth_none  s    %%h77rG   c                     | j                        \  }| j                  |      | j                  d|      fd}| j                  |d|      S )Nr   c                     | j                  d       | j                         | j                         | j                  j                               y )NT)r   rx   r   )r{   r   r   r   r`   s    rE   finishz.AuthOnlyHandler.auth_publickey.<locals>.finish  sB    
 MM$LL#LLLL**4;<rG   r_   )r   r   r   r\  )rD   r7   r`   r   ra  r   r   r   s     `  @@@rE   ra   zAuthOnlyHandler.auth_publickey  s_    44S9$33H=	%%	
	= %%hVDDrG   c                 4    fd}| j                  |d|      S )Nc                 \    | j                  d       | j                  t                     y )NF)r   rx   r'   )r{   r<   s    rE   ra  z-AuthOnlyHandler.auth_password.<locals>.finish  s!     MM% LL8%rG   r<   r^  )rD   r7   r<   ra  s     ` rE   rd   zAuthOnlyHandler.auth_password  s    	& %%h
FCCrG   c                 P    d| _         || _        fd}| j                  |d|      S )rf   keyboard_interactivec                 J    | j                  d       | j                         y )Nr3   )rx   )r{   r?   s    rE   ra  z0AuthOnlyHandler.auth_interactive.<locals>.finish/  s     LLLL$rG   rg   )r:   r>   r\  )rD   r7   rh   r?   ra  s      ` rE   ri   z AuthOnlyHandler.auth_interactive%  s2     2#* 	% %%h0FOOrG   c                     d}| j                  t        |       |j                  dd      }||v s||v r||v r|n|}d|d}|}n|d   }|d|}| j                  t        |       |S )NzdServer did not send a server-sig-algs list; defaulting to something in our preferred algorithms listr   r3   zCurrent key type, z&, is in our preferred list; using thatr   z3 not in our list - trying first list item instead, )rJ   r	   r   )rD   r   r   r   noncert_key_typeactualalgos          rE   r   z1AuthOnlyHandler._choose_fallback_pubkey_algorithm8  s    t		%#++,CRHx#3x#?!)X!5X;KF&vj0VWCDA;DL STXS[\C		%rG   rI   r5  )r  r6  r7  r8  r9  r2  r\  r\   ra   rd   ri   r   __classcell__)r   s   @rE   rS  rS    s>      
'7R8E,DP&rG   rS  );r8  r4   rY  r   r   paramiko.commonr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   paramiko.messager&   paramiko.utilr'   r(   paramiko.ssh_exceptionr)   r*   r+   r,   paramiko.serverr-   paramiko.ssh_gssr.   r/   r1   r	  rS  r:  rG   rE   <module>rr     s   &    	$ $ $ $ $ $ $ $ $ $J %   - 4L. L.^i$ i$X|k |rG   