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_yubikey.cpython-39.pyc
a

}�f��@s ddlZddlZddlmZmZmZddlmZmZddl	m
Z
mZmZddl
mZddlmZzddlZddlZWn ey�eed�d��Yn0ejr�eZed	�ed
�ed�ed�ed
�Ze�ZdZedd�Gdd�de��Zedd�Gdd�de��Ze�Gdd�de
��ZdS)�N)�_�api�IntEnum)�NotFound�SkipPluginModule)�Command�Method�Object)�Registry)�
classpropertyzpython-yubico is not installed.��reasonz
YubiKey Tokens
z
Manage YubiKey tokens.
zt
This code is an extension to the otptoken plugin and provides support for
reading/writing YubiKey tokens directly.
z
EXAMPLES:
zP
 Add a new token:
   ipa otptoken-add-yubikey --owner=jdoe --desc="My YubiKey"
ZotpT)Zno_failc@seZdZdZdS)�_fake_otptokenZotptokenN)�__name__�
__module__�__qualname__�name�rr�F/usr/lib/python3.9/site-packages/ipaclient/plugins/otptoken_yubikey.pyr;src@seZdZdZdZdS)�_fake_otptoken_add�otptoken_addTN)rrrr�NO_CLIrrrrr@srcs�eZdZed�Zedded�dd�fZeZedd��Z	e
e	�Zed	d
��Z
�fdd�Z�fd
d�Z�fdd�Zdd�Zdd�Z�ZS)�otptoken_add_yubikeyzAdd a new YubiKey OTP token.zslot?�slotzYubiKey slot)��)Zcli_nameZlabel�valuescCstj�d�tuS)Nr)rrZ
get_pluginr)�clsrrrZ__NO_CLI_getterSsz$otptoken_add_yubikey.__NO_CLI_gettercCs|jjjjS�N)rrr�api_version��selfrrrrYsz otptoken_add_yubikey.api_versionc#s8|jjj��D]
}|Vqtt|���D]
}|Vq(dSr)rrr�args�superr�get_args)r!�arg��	__class__rrr$]szotptoken_add_yubikey.get_argsc#sB|jjj��D]}|jdvr|Vqtt|���D]
}|Vq2dS)N)�type�ipatokenvendor�
ipatokenmodel�ipatokenserial�ipatokenotpalgorithm�ipatokenhotpcounter�ipatokenotpkeyZipatokentotpclockoffsetZipatokentotptimestep�	no_qrcodeZqrcode�version)rrr�optionsrr#r�get_options)r!�optionr&rrr2cs

z otptoken_add_yubikey.get_optionsc#s8|jjj��D]
}|Vqtt|���D]
}|Vq(dSr)rrrZ
output_paramsr#r�get_output_params)r!Zparamr&rrr4usz&otptoken_add_yubikey.get_output_paramscCs|jjj��Sr)rrr�outputr rrr�_iter_output{sz!otptoken_add_yubikey._iter_outputcOs�zt��}Wn�tjjyD}ztd|jd��WYd}~npd}~0tjjyv}zt|j	d��WYd}~n>d}~0t
y�}ztt|�dd��WYd}~n
d}~00|��dks�J�|�
dd�du�rz*|����}tddh�|��d|d<Wn"t�yttd	�d��Yn0t�d
�}|��}|�||�
d|�d���|�dd
�|j||dd�dd�|��D�}|jjjdg|�Rddt|j �t|�!��dd|d
d�|��}	dD]"}
|
|	�
di�v�r�|	d|
=�q�|d|	�
di�d<|	S)NzNo YubiKey found: %srz:. Please install 'libyubikey' and 'libusb' packages first.)rrrrrrzNo free YubiKey slot!��ipatokenotpdigitsZSERIAL_API_VISIBLET)rcSsi|]\}}|dvr||�qS))r0�descriptionZ
ipatokenownerZipatokendisabledZipatokennotbeforeZipatokennotafterr8r)�.0�k�vrrr�
<dictcomp>��z0otptoken_add_yubikey.forward.<locals>.<dictcomp>rZhotpZYubiCoZsha1)r(r)r*r+r,r-r.r/)Zurir.�result)"�yubicoZfind_yubikey�usbZcoreZUSBErrorr�strerrorZyubikeyZYubiKeyErrorr
�
ValueError�strZversion_num�get�statusZ
valid_configs�sorted�
difference�
IndexErrorr�os�urandomZinit_configZmode_oath_hotpZget_default_ofZ
extended_flagZwrite_config�itemsZBackendZ	rpcclient�forward�unicodeZmodel�serial)r!r"�kwargsZyk�e�used�keyZcfgr1Zanswerr;rrrrM~sV$ (

��
�
�
zotptoken_add_yubikey.forward)rrrr�__doc__rZ
takes_optionsZhas_output_params�classmethodZ$_otptoken_add_yubikey__NO_CLI_getterrr�propertyrr$r2r4r6rM�
__classcell__rrr&rrFs$��

r)rJZsixZipalibrrrZ
ipalib.errorsrrZipalib.frontendrrr	Zipalib.plugabler
Zipalib.utilrZusb.corerAr@�ImportErrorZPY3rDrNrT�registerZtopicrrrrrrr�<module>s<���	�