HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/secretstorage/__pycache__/item.cpython-38.pyc
U

��zW��@s�dZddlZddlmZddlmZddlmZmZm	Z	m
Z
mZmZddl
mZmZmZddlmZedZGd	d�de�ZdS)
aQSecretStorage item contains a *secret*, some *attributes* and a
*label* visible to user. Editing all these properties and reading the
secret is possible only when the :doc:`collection <collection>` storing
the item is unlocked. The collection can be unlocked using collection's
:meth:`~secretstorage.collection.Collection.unlock` method.�N)�	SS_PREFIX)�LockedException)�InterfaceWrapper�bus_get_object�open_session�
format_secret�
to_unicode�unlock_objects)�Cipher�
algorithms�modes)�default_backend�Itemc@s�eZdZdZd$dd�Zdd�Zdd�Zd	d
�Zd%dd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd&dd�Zdd�Zd d!�Zd"d#�ZdS)'rzRepresents a secret item.NcCsL||_t||�}||_||_t|t�|_t|tj�|_	|j	j
tddd�dS)N�Label�ss�Z	signature)�	item_pathr�session�busr�
ITEM_IFACE�
item_iface�dbusZPROPERTIES_IFACE�item_props_iface�Get)�selfrrrZitem_obj�r�4/usr/lib/python3/dist-packages/secretstorage/item.py�__init__s
�z
Item.__init__cCs|j|jkS)N)r)r�otherrrr�__eq__#szItem.__eq__cCst|jjtddd��S)zDReturns :const:`True` if item is locked, otherwise
		:const:`False`.ZLockedrr)�boolrrr�rrrr�	is_locked&s�zItem.is_lockedcCs|��rtd��dS)zSIf collection is locked, raises
		:exc:`~secretstorage.exceptions.LockedException`.zItem is locked!N)r"rr!rrr�ensure_not_locked,szItem.ensure_not_lockedcCst|j|jg|�S)a�Requests unlocking the item. Usually, this will mean that the
		whole collection containing this item will be unlocked.

		If `callback` is specified, calls it when unlocking is complete
		(see :func:`~secretstorage.util.exec_prompt` description for
		details). Otherwise, uses the loop from GLib API and returns a
		boolean representing whether the operation was dismissed.

		.. versionadded:: 2.1.2)r	rr)r�callbackrrr�unlock2s
zItem.unlockcCs$|jjtddd�}dd�|��D�S)z%Returns item attributes (dictionary).�
AttributesrrcSsi|]\}}t|�t|��qSr)r)�.0�key�valuerrr�
<dictcomp>Bs�z'Item.get_attributes.<locals>.<dictcomp>)rrr�items)rZattrsrrr�get_attributes>s
��zItem.get_attributescCs|jjtd|dd�dS)z2Sets item attributes to `attributes` (dictionary).r&�ssvrN)r�Setr)rZ
attributesrrr�set_attributesEs�zItem.set_attributescCs|jjtddd�}t|�S)z$Returns item label (unicode string).rrr)rrrr�rZlabelrrr�	get_labelJs
�zItem.get_labelcCs |��|jjtd|dd�dS)zSets item label to `label`.rr-rN)r#rr.rr0rrr�	set_labelPs�zItem.set_labelcCs|��|jjdd�S)zDeletes the item.�r)r#rZDeleter!rrr�deleteVszItem.deletecCs�|��|jst|j�|_|jj|jjdd�}|jjsFtt	|d��St
�|jj�}tt	|d��}t
|t�|�t����}tt	|d��}|�|�|��}t	|�}t|d|d��S)z!Returns item secret (bytestring).�or��N���)r#rrrr�	GetSecret�object_pathZ	encrypted�bytes�	bytearrayrZAESZaes_keyr
rZCBCr
�	decryptor�update�finalize)r�secretZaesZaes_ivr=Zencrypted_secretZ
padded_secretrrr�
get_secret[s�zItem.get_secretcCs:|��|jst|j�|_|jj|jjdd�}t|d�S)z-Returns content type of item secret (string).r5r�)r#rrrrr9r:�str)rr@rrr�get_secret_content_typels�zItem.get_secret_content_type�
text/plaincCs<|��|jst|j�|_t|j||�}|jj|dd�dS)z�Sets item secret to `secret`. If `content_type` is given,
		also sets the content type of the secret (``text/plain`` by
		default).z(oayays)rN)r#rrrrrZ	SetSecret)rr@Zcontent_typerrr�
set_secretus
zItem.set_secretcCst|jjtddd��S)zlReturns UNIX timestamp (integer) representing the time
		when the item was created.

		.. versionadded:: 1.1ZCreatedrr��intrrrr!rrr�get_createds�zItem.get_createdcCst|jjtddd��S)zYReturns UNIX timestamp (integer) representing the time
		when the item was last modified.ZModifiedrrrGr!rrr�get_modified�s�zItem.get_modifiedcCs|��|��|��fS)z?Returns (*attributes*, *secret*) tuple representing the
		item.)r#r,rAr!rrr�to_tuple�sz
Item.to_tuple)N)N)rE)�__name__�
__module__�__qualname__�__doc__rrr"r#r%r,r/r1r2r4rArDrFrIrJrKrrrrrs"


	

)rOrZsecretstorage.definesrZsecretstorage.exceptionsrZsecretstorage.utilrrrrrr	Z&cryptography.hazmat.primitives.ciphersr
rrZcryptography.hazmat.backendsr
r�objectrrrrr�<module>s