HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/ipaclient/plugins/__pycache__/otptoken.cpython-39.opt-1.pyc
a

}�f��@sddlmZddlZddlmZddlmZmZmZm	Z	ddlm
Z
ddlmZm
Z
ddlmZddlmZdd	lmZdd
lmZddlZddlZddlZddlmZddlZddlZejr�eZ e�Z!e!ddd
�Gdd�de��Z"Gdd�dej#j$�Z$e!�Gdd�de��Z%dS)�)�print_functionN)�MethodOverride)�api�Str�Password�_)�errors)�add_message�ResultFormattingError)�Registry)�Local)�create_https_connection)�API_VERSION)�StringIOT)�overrideZno_failcs$eZdZdd�Z�fdd�Z�ZS)�otptoken_addc
	Cs�t�}t��}|�|�|��|j|dd�ttjdd�}|durNt	�
d�}z|���|�}Wn,t
y�t||ttd�d�d�YdS0tj��r�|jjj��}t|��d�}	|	|kr�t||ttd�d�d�|S)NF)�out�tty�encodingzuUnable to display QR code using the configured output encoding. Please use the token URI to configure your OTP device��messagerzRQR code width is greater than that of the output tty. Please resize your terminal.)r�qrcodeZQRCodeZadd_dataZmake�print_ascii�getattr�sys�stdout�locale�getpreferredencoding�getvalue�encode�UnicodeErrorr	r
r�isattyrZBackend�textuiZ
get_tty_width�len�
splitlines)
�self�output�uri�versionZ	qr_output�qrrZqr_codeZoutput_widthZ
qr_code_width�r*�>/usr/lib/python3.9/site-packages/ipaclient/plugins/otptoken.py�_get_qrcode0sB

��	
���
zotptoken_add._get_qrcodecs�d|vr
n|jjjrd|d<nt|d<|d�dd�}|dur^|�dd�s^|�|||d�}nd}tt|�j||g|�Ri|��}|dur�t	d�|j
tj�
�d�t	d�|S)	Nr(z2.0�resultr'Z	no_qrcodeF�
)r)r�envZskip_version_checkr�getr,�superr�output_for_cli�printrrrr!)r%r"r&�args�optionsr'r)�rv��	__class__r*r+r2Zs*


���zotptoken_add.output_for_cli)�__name__�
__module__�__qualname__r,r2�
__classcell__r*r*r7r+r.s*rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�HTTPSHandlerz=Opens SSL HTTPS connections that perform hostname validation.cKs||_tjj�|�dS�N)�_HTTPSHandler__kwargs�urllib�requestr=�__init__)r%�kwargsr*r*r+rByszHTTPSHandler.__init__cKs$|j��}|�|�t|fi|��Sr>)r?�copy�updater
)r%�hostrC�tmpr*r*r+Z__inners

zHTTPSHandler.__innercCs|�|j|�Sr>)Zdo_open�_HTTPSHandler__inner)r%Zreqr*r*r+�
https_open�szHTTPSHandler.https_openN)r9r:r;�__doc__rBrHrIr*r*r*r+r=vsr=c@s|eZdZed�ZdZeded�d�eded�dd	�ed
ed�dd	�eded
�dd	�fZeded�d�fZ	dd�Z
dd�ZdS)�
otptoken_synczSynchronize an OTP token.zX-IPA-TokenSync-Result�userzUser ID)�label�passwordrF)rMZconfirmZ
first_codez
First CodeZsecond_codezSecond Codeztoken?zToken IDc
sBd|jdii}ttj�|jjj��}|d�dd�|d<tj�	|�}dd�|j
D���fdd	�|��D�}|r�|d
dur�|d
|d<tj�|�}|�
d�}ttjjtjjtjjd
�}tj�|��||�}|��dkr�|���|jd�|d|j<|��|d|jdk�r>ddd��|d|jd�}	tjtd�|	d��|S)Nr-�unknown�z/xmlz/session/sync_tokencSsh|]
}|j�qSr*)�name)�.0�xr*r*r+�	<setcomp>��z(otptoken_sync.forward.<locals>.<setcomp>csi|]\}}|�vr||�qSr*r*)rR�k�v�r5r*r+�
<dictcomp>�rUz)otptoken_sync.forward.<locals>.<dictcomp>r�tokenzutf-8)Zcafile�tls_version_min�tls_version_max���okzError contacting server!zInvalid Credentials!)�errorzinvalid-credentialszUnknown Error!zUnable to synchronize token: %sr)�header�listr@�parse�urlparserr/Z
xmlrpc_uri�replace�
urlunparse�
takes_options�items�	urlencoderr=Ztls_ca_certr[r\rAZbuild_opener�openZgetcode�infor0�closerZExecutionErrorr)
r%r4rC�status�segmentsZsync_uri�queryZhandlerZrsp�msgr*rXr+�forward�s:
���
�zotptoken_sync.forwardcOs|�d�dS)NzToken synchronized.)Zprint_plain)r%r"r-�keysr5r*r*r+r2�szotptoken_sync.output_for_cliN)r9r:r;rrJr`rrrfZ
takes_argsrpr2r*r*r*r+rK�s��$rK)&Z
__future__rrZipaclient.frontendrZipalibrrrrrZipalib.messagesr	r
Zipalib.plugablerZipalib.frontendrZipalib.utilr
Zipapython.versionrrrZsix�ior�urllib.parser@Zurllib.requestZPY3�strZunicode�registerrrAr=rKr*r*r*r+�<module>s.
G