
    7g                     ^   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:dS )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&d%S )'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| _        d S )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     O/var/www/html/syslog/venv/lib/python3.11/site-packages/paramiko/auth_handler.py__init__zAuthHandler.__init__R   s{     y11"#' ! #    c                       | 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                 6    | j         j        r| j        S | j        S rI   )r6   server_moder@   r7   rM   s    rE   get_usernamezAuthHandler.get_usernamej   s     >% 	!%%= rG   c                    | j         j                                         	 || _        d| _        || _        |                                  | j         j                                         d S # | 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   s    ##%%%	*#DO%D$DM   N'')))))DN''))))   )A) ) B	c                 &   | j         j                                         	 || _        d| _        || _        || _        |                                  | j         j                                         d S # | 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   s    ##%%%	*#DO*D$DM"D   N'')))))DN''))))   0A0 0 Bc                 &   | j         j                                         	 || _        d| _        || _        || _        |                                  | j         j                                         d S # | 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   s    ##%%%	*#DO)D$DM$DM   N'')))))DN''))))rb   r3   c                 4   | j         j                                         	 || _        d| _        || _        || _        || _        |                                  | j         j        	                                 dS # | 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   N'')))))DN''))))   7A7 7 Bc                 4   | j         j                                         	 || _        d| _        || _        || _        || _        |                                  | j         j        	                                 d S # | 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    N'')))))DN''))))rj   c                    | j         j                                         	 || _        d| _        || _        |                                  | j         j                                         d S # | j         j                                         w xY w)Ngssapi-keyexrU   rZ   s      rE   auth_gssapi_keyexzAuthHandler.auth_gssapi_keyex   s    ##%%%	*#DO-D$DM   N'')))))DN''))))r]   c                 J    | j         | j                                          d S d S rI   )r9   setrM   s    rE   abortzAuthHandler.abort   s,    ?&O!!!!! '&rG   c                     t                      }|                    t                     |                    d           | j                            |           d S Nssh-userauth)r&   add_byter   
add_stringr6   _send_messagerD   ms     rE   rX   zAuthHandler._request_auth   sL    II	

'(((	^$$$$$Q'''''rG   c                 D   t                      }|                    t                     |                    t                     |                    d           |                    d           | j                            |           | j                                         d S )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    II	

?###			2333	,---	T$$Q'''rG   c                 D   t                      }|                    t                     |                    t                     |                    d           |                    d           | j                            |           | j                                         d S )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    II	

?###			;<<<	5666	T$$Q'''rG   c                 l    |j         r|j         j        |j         j        fS |                                |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   s6     ? 	'?+S_-EEE<<>>3&&rG   c                    t                      }|                    | j        j                   |                    t
                     |                    |           |                    |           |                    d           |                    d           |                     |          \  }}|                    |           |                    |           |                                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    II	T^.///	

()))	X	W	[!!!	d--c224	Y	Tyy{{rG   c                    d }| j         j         t          j                    | j         j        z   }	 |                    d           | j                                         sF| j                                         }|t          |j        t                    rt          d          }||
                                rn)|&|t          j                    k    rt          d          |                                 sM| j                                         }|t          d          }t          |j        t                    r|j        S |g S )NTg?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   s6   >&2Y[[4>#>>F	IJJsOOO>++-- N0022I*Q[("C"CI/O A ||~~ !f	&;&;-.GHHH	I $$&& 		,,..Ay+,DEE !+'<== '&G	rG   c                 J   |                                 }| j        j        r|dk    rt                      }|                    t
                     |                    |           | j                            |           | j        j        	                                \  }}|rlt                      }|                    t                     |                    |           |                    |           | j                            |           d S |                                  d S 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+D		AJJ*+++LL!!!N((+++#~;FFHHFH 0II

/000V$$$X&&&,,Q///F..00000rG   c                     | j         j        }|                    dd          |vr2d}|                     t          |                    |                     d S  | 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  sy    .24b99HHN  IIdCJJy1122242t~'	2773C3CDDDrG   c                     |d         }d}|                      t          |                    |                     |                      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(  sW    qki		%K00111		 c	
 	
 	
 rG   c                    d|vr|S |                      t          d                    |                     |                    d          rxt	          j        d| j        j                  rYd}|| j        _        |                      t          d           |                      t          d                    |                     |S d | j        j	        D             }|                      t          d	                    |                     |st          d
          t          | j        j                            dt          d                              }d }|r|                    d          }|                      t          d                    |                     t!          t#          |j        |                    }|r7|d         }|                      t          d                    |                     nU|                      t          d           d}t'          |                    |                    |                     ||          }|                    d          r|dz  }|| j        _        |S )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 algorithmc                     g | ]}d |v |	S )r    ).0xs     rE   
<listcomp>z:AuthHandler._finalize_pubkey_algorithm.<locals>.<listcomp>O  s    NNN!5A::A:::rG   z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   r   server_algo_strserver_algos	agreementr   s           rE   _finalize_pubkey_algorithmz&AuthHandler._finalize_pubkey_algorithm3  s     O		>EE 	
 	
 	
 455 		")*DN,I;
 ;
 		 9K6ADN3IIeHIIIII:AA+NN    ONt~?NNN		%8??IIJJJ 	X   N,001BAbEEJJ
 
  	*0055LII7>>|LL   VL$=xHHIII D'l		7>>{KK   
 		%!LMMM V-cjj.B.BCCC @@( K 455 	322K2=/rG   c                 Z   |                                 }|dk    ra|                     t          d           t                      }|                    t
                     |                    | j                   |                    d           |                    | j                   | j        dk    r@|	                    d           t          | j                  }|                    |           nn| j        dk    r|	                    d           |                     | j                  \  }}|                     |          }|                    |           |                    |           |                     | j        d| j        |          }| j                            ||          }|                    |           n| j        dk    r1|                    d	           |                    | j                   nb| j        d
k    rt%          | j        | j                  }	|                    |	                                           | j                            |           | j        j                                        \  }
}|
t4          k    r6|                     |           | j        j                                        \  }
}|
t8          k    r |                                }t                      }|                    t<                     	 |                    |	                    | j         || j                             n,# tB          $ r}| "                    |          cY d }~S d }~ww xY w| j                            |           	 | j        j                                        \  }
}|
tF          k    r|                                }	 |	                    | j         || j        |          }n,# tB          $ r}| "                    |          cY d }~S d }~ww xY w|nXt                      }|                    t<                     |                    |           | j        $                    |           t                      }|                    tP                     |                    |	)                    | j        j*                             n|
tV          k    rtK          d          |
tX          k    rt|-                                }|-                                }|                                }|                                 tK          d&                    |||                    |
t\          k    r| /                    |           d S tK          d&                    tN          |
                             | j        dk    rg| j        j0        r[| j        j1        }|2                    | j                   |)                    | j        j*                  }|                    |           n3| j        dk    rn'tK          d&                    | j                            | j                            |           d S |                     t          d&                    |                     d S )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0d###!%!<!<T=M!N!N$ ;;HEE	Y'''T"""--$$M	  &44T9EES!!!!!%;;;R   T_----!%666 !143GHHF//11222,,Q///>4AACCq/////222#~8EEGGHE1888 <<>>D		AJJ9:::A"77 $tT]    
 * A A A#==a@@@@@@@@AN00333#'>#<#I#I#K#Kq $===()II-3-H-H$(M$($(M$-	." ."

 $2 I I I'+'E'Ea'H'H H H H H H HI
  *1 %$+II !

+E F F F !Z 8 8 8 $ ; ;A > > >-6  		AJJ7888LL!3!3DN4M!N!NOOOO888
 ''GHHH777!"J!"JllnnGLLNNN& F&
G    22200333F&.55i6FGG    N22N/ 3 3##DM222"..t~/HII	Y''''!V++".55d6FGG   N((+++++II:AA'JJ    s<   4M 
M/M*$M/*M/"O1 1
P;PPPc                    t                      }|t          k    rP|                     t          d                    |                     |                    t                     d| _        n|                     t          d                    |                     |                    t                     |	                    | j
        j                            |                     |t          k    r|                    d           n%|                    d           | xj        dz  c_        | j
                            |           | j        dk    r|                                  |t          k    r| j
                                         d S d S )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   se   II_$$IId077??@@@JJ,---!%DIId188@@AAAJJ,---LL,>>xHH   222d####e$$$$$)$$$$Q'''2%%))+++_$$N((***** %$rG   c                    t                      }|                    t                     |                    |j                   |                    |j                   |                    t                                 |                    t          |j	                             |j	        D ]8}|                    |d                    |
                    |d                    9| j                            |           d S )Nr   r   )r&   rw   r   rx   nameinstructionsbytesr~   lenpromptsr   r6   ry   )rD   qr{   ps       rE   _interactive_queryzAuthHandler._interactive_query  s    II	

-...	QV	Q^$$$	UWW			#ai..!!! 	  	 ALL1MM!A$$$Q'''''rG   c           	         | j         j        snt                      }|                    t                     |                    d           |                    d           | j                             |           d S | j        rd S |	                                }|	                                }|	                                }| 
                    t          d                    |||                     |dk    r|                                  d S | j        <| j        |k    r1| 
                    t          d           |                                  d S || _        | j         j                                        }|dk    r!| j         j                            |          }n|dk    r|                                }|                                }	 |                    d          }n# t.          $ r Y nw xY w|r`| 
                    t          d           |                                }		 |	                    dd	          }	n# t.          $ r Y nw xY wt0          }n| j         j                            ||          }n|d
k    r|                                }
|	                                }|                                }	 |                     ||          }n# t6          $ rG}| 
                    t8          d                    t;          |                               d }Y d }~nWd }~wt<          $ rG}d}| 
                    t8          |                    |j        j         |                     d }Y d }~nd }~ww xY w||                                  d S | j         j        !                    ||          }|t0          k    r|
snt                      }|                    tD                     |                    |           |                    |           | j                             |           d S t          |                                          }| #                    ||||          }|$                    ||          s"| 
                    t8          d           t0          }n|dk    rb|%                                }| j         j        &                    ||          }tO          |tP                    r| )                    |           d S nF|dk    r[|rXtU          |          }|+                                }|dk    r/| 
                    t8          d           |                                  |%                                }|,                    |          }|s/| 
                    t8          d           |                                  |-                    d          }t                      }|                    t\                     |/                    |           ta          | |          | j         _1        td          tf          th          f| j         _5        | j                             |           d S |dk    r|r|%                                }| j         j6        }|t0          }| 7                    |||           	 |8                    || j         j9        | j                   n-# t<          $ r  t0          }| 7                    |||            w xY wtt          }| j         j        ;                    ||           n| j         j                            |          }| 7                    |||           d S )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%  sb   ~) 			AJJ,---LL   MM%   N((+++F 	F::<<**,,		<CC 	
 	
 	
 &&&22444F*(**II]   ))+++F%>/BBDDV^1AA(KKFFz!!I||~~H#??733       		%!NOOOllnn"-"4"4Wi"H"HKK#   D$5IIh  {""==??L 

IllnnG55iII   		$ ? F Fs1vv N NOOO   Q		$

1;+? C CDDD {--///^1FF# F $$#   		AJJ2333LL+++LL)))N00333Fallnn----(I  ))$44 )IId$FGGG(F---J^1HH* F &"233 ''/// (((X(V__F IIKKE qyy		N   --///<<>>L++L99G 0		K   --///#00::N 		AJJ4555KK'''*Bf+ +DN' *$#/DN+
 N((+++F~%%(%I^/F~$&&x@@@$$t~8$:L       $&&x@@@ %FN(@@&    ^1AA(KKFx88888sT   
G   
G-,G-"H9 9
II8K 
M/=LM/(=M**M/+&[ *[<c                     |                      t          d                    | j                             d| _        | j                                         | j        | j                                         d S d S )NzAuthentication ({}) successful!T)	rJ   r   r   r:   r8   r6   r   r9   rr   rz   s     rE   _parse_userauth_successz#AuthHandler._parse_userauth_success  sw    		3::4;KLL	
 	
 	
 "$$&&&?&O!!!!! '&rG   c                    |                                 }|                                }|r`|                     t          d           |                     t          dt          |          z              t          |          | j        _        n| j	        |vrhd
                    | j	                  d
                    |          fD ]}|                     t          |           t          d|          | j        _        n3|                     t          d
                    | j	                             d| _        d | _        | j        | j                                         d S d S )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  sY   ::<< --// 	IId9:::IIe[3x==8999-B8-L-LDN**X--9@@$  &,,X66	 & & 		%%%%%-B)8. .DN** II3::4;KLL   #?&O!!!!! '&rG   c                     |                                 }|| _        |                     t          d                    |                     d S )NzAuth banner: {})r   r;   rJ   r   r   )rD   r{   r;   s      rE   r   z"AuthHandler._parse_userauth_banner  s?    		$)008899999rG   c                    | j         dk    rt          d          |                                }|                                }|                                 |                                }g }t          |          D ]=}|                    |                                |                                f           >|                     |||          }t                      }|
                    t                     |                    t          |                     |D ]}|                    |           | j                            |           d S )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5ABBB

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

ammoo>????00<
 
 II	

.///			#m$$%%% 	 	ALLOOOO$$Q'''''rG   c                    | j         j        st          d          |                                }g }t	          |          D ])}|                    |                                           *| j         j                            |          }t          |t                    r|                     |           d S |                     | j        d|           d S )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    ~) 	DBCCCIIKK	q 	+ 	+AQZZ\\****-MM
 
 f.// 	##F+++F 6	
 	
 	
 	
 	
rG   c                 <   || j         _        |                     t          d                    |                     |                     t
          d                    | j                             d| _        d | _        | j	        | j	        
                                 d S )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*  s    )*&		%-44Q77888		$5<<T=MNNOOO"?&O!!!rG   c                 N    t           | j        t          | j        t          | j        iS rI   )r   r   r   r  r   r1  rM   s    rE   _server_handler_tablez!AuthHandler._server_handler_table<  s&      !< $">&(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  s6      : $"> $">!<%t'H
 	
rG   c                 6    | j         j        r| j        S | j        S rI   )r6   rP   r4  r6  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,  r1  r   propertyr4  r6  r8  r   rG   rE   r1   r1   M   sT        $ $ $$* * *" " "! ! !* * *	* 	* 	*	* 	* 	** * * *
* 
* 
** * *" " "( ( (    
' 
' 
'    <1 1 1&	E 	E 	E	 	 	F F FPC C CJ+ + +0( ( (o9 o9 o9b" " "" " "<: : :( ( (*
 
 
$  $ 
 
 X
 
 
 X
 . . X. . .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dS )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                 "    || _         || _        d S rI   )	_delegater   )rD   delegater   s      rE   rF   z!GssapiWithMicAuthHandler.__init__e  s    !rG   c                 \    |                                   | 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        _        d S rI   )r@  r6   r  rM   s    rE   rC  z7GssapiWithMicAuthHandler._restore_delegate_auth_handler}  s    &*n###rG   c                 *   |                                 }| j        }	 |                    | j        || j                  }n[# t
          $ rN}|| j        _        t          }| 	                                 | 
                    | j        | j        |            d }~ww xY w|wt                      }|                    t                     |                    |           t           t"          t$          f| j        _        | j                            |           d S d S rI   )r   r   ssh_accept_sec_contextrB   r@   r  r6   r   r   rC  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-? EE  	 	 	-.DN* F//111""4#5t{FKKK	 		AJJ1222LL)'$/DN+
 N((+++++ s   !? 
B	A	BBc                    |                                 }| j        }| j        }|                                  	 |                    || j        j        |           nB# t          $ r5}|| j        _        t          }| 
                    || j        |            d }~ww xY wt          }| j        j                            ||           | 
                    || j        |           d S rI   )r   r   r@   rC  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    LLNN	%++---	  4>4h     	 	 	-.DN* F""8T[&AAA		 !$??f	
 	
 	
 	xf=====s   !A 
B$0BBc                 ^    |                                   | j                            |          S rI   )rC  r@  r   rz   s     rE   r   z/GssapiWithMicAuthHandler._parse_service_request  s*    ++---~44Q777rG   c                 ^    |                                   | j                            |          S rI   )rC  r@  r  rz   s     rE   r  z0GssapiWithMicAuthHandler._parse_userauth_request  s*    ++---~55a888rG   c                     | j         S rI   )(_GssapiWithMicAuthHandler__handler_tablerM   s    rE   r8  z'GssapiWithMicAuthHandler._handler_table  s     ##rG   N)r  r:  r;  r<  r   rF   rs   r=  r6   r   r@   rB   rC  rM  rP  r   r  r   r   r    r#   rT  r8  r   rG   rE   r  r  \  s6         F  & & & ( ( X( 0 0 X0 , , X, ' ' X'5 5 5, , ,4> > >08 8 89 9 9
 	35!#?!;	O $ $ X$ $ $rG   r  c                   Z     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                 b    t                      j                                        }|t          = |S rI   )superr6  copyr   )rD   my_tabler   s     rE   r6  z%AuthOnlyHandler._client_handler_table  s)    7705577'(rG   Nc                    || _         || _        t                      }|                    t                     |                    |           |                    d           |                    |            ||           | j        j        5  | j                            |           ddd           n# 1 swxY w Y   t          j
                    | _        |                     | j                  S )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    " II	

()))	X	%&&&	Vq ^  	, 	,N((+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, $/++%%do666s   B44B8;B8c                 .    |                      |d          S rS   r_  )rD   r7   s     rE   r\   zAuthOnlyHandler.auth_none  s    %%h777rG   c                     |                                \  }|                     |          |                     d|          fd}|                     |d|          S )Nr   c                     |                      d           |                                |                                |                                                              d S )NT)r   rx   r   )r{   r   r   r   r`   s    rE   finishz.AuthOnlyHandler.auth_publickey.<locals>.finish  sc    
 MM$LL###LLLL**4;;<<<<<rG   r_   )r   r   r   r_  )rD   r7   r`   r   rd  r   r   r   s     `  @@@rE   ra   zAuthOnlyHandler.auth_publickey  s    44S99$33H==	%%	
 
	= 	= 	= 	= 	= 	= 	= 	= %%hVDDDrG   c                 <    fd}|                      |d|          S )Nc                 v    |                      d           |                     t                               d S )NF)r   rx   r'   )r{   r<   s    rE   rd  z-AuthOnlyHandler.auth_password.<locals>.finish  s5     MM%   LL8%%%%%rG   r<   ra  )rD   r7   r<   rd  s     ` rE   rd   zAuthOnlyHandler.auth_password  s6    	& 	& 	& 	& 	& %%h
FCCCrG   r3   c                 X    d| _         || _        fd}|                     |d|          S )rf   keyboard_interactivec                 \    |                      d           |                                 d S )Nr3   )rx   )r{   r?   s    rE   rd  z0AuthOnlyHandler.auth_interactive.<locals>.finish/  s/     LLLL$$$$$rG   rg   )r:   r>   r_  )rD   r7   rh   r?   rd  s      ` rE   ri   z AuthOnlyHandler.auth_interactive%  sI     2#* 	% 	% 	% 	% 	% %%h0FOOOrG   c                     d}|                      t          |           |                    dd          }||v s||v r||v r|n|}d|d}|}n|d         }|d|}|                      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Hx#3x#?#?!)X!5!5XX;KFWvWWWCDDA;D\\TX\\C		%rG   rI   r9  )r  r:  r;  r<  r=  r6  r_  r\   ra   rd   ri   r   __classcell__)r   s   @rE   rV  rV    s              X
'7 '7 '7 '7R8 8 8E E E,D D DP P P P&      rG   rV  );r<  r4   r\  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  rV  r   rG   rE   <module>ru     s  &        				$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $J % $ $ $ $ $                    - , , , , , 4 4 4 4 4 4 4 4L. L. L. L. L. L. L. L.^i$ i$ i$ i$ i$ i$ i$ i$X| | | | |k | | | | |rG   