
    .Ph                         d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZmZmZmZmZ ddlmZmZmZ dd	lmZ ed
z   Z G d d
          ZdS )aQ  SecretStorage 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.    )DictOptional)DBusConnection)	SS_PREFIX)Session)LockedExceptionPromptDismissedException)DBusAddressWrapperexec_promptopen_sessionformat_secretunlock_objects)Cipher
algorithmsmodes)default_backendItemc            	          e Zd ZdZ	 ddededee         ddfdZdd	de	fd
Z
de	fdZddZde	fdZdeeef         fdZdeeef         ddfdZdefdZdeddfdZddZdefdZdefdZ	 ddededdfdZdefdZdefdZdS ) r   zRepresents a secret item.N
connection	item_pathsessionreturnc                     || _         t          |t          |          | _        | j                            d           || _        || _        d S )NLabel)r   r
   
ITEM_IFACE_itemget_propertyr   r   )selfr   r   r   s       R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/secretstorage/item.py__init__zItem.__init__   sD    "'	:zJJ

((($    otherr   c                 Z    t          |j        t                    sJ | j        |j        k    S N)
isinstancer   str)r   r"   s     r   __eq__zItem.__eq__$   s)    %/3/////~00r!   c                 P    t          | j                            d                    S )zJReturns :const:`True` if item is locked, otherwise
        :const:`False`.Locked)boolr   r   r   s    r   	is_lockedzItem.is_locked(   s"     DJ++H55666r!   c                 L    |                                  rt          d          dS )zYIf collection is locked, raises
        :exc:`~secretstorage.exceptions.LockedException`.zItem is locked!N)r,   r   r+   s    r   ensure_not_lockedzItem.ensure_not_locked-   s/     >> 	5!"3444	5 	5r!   c                 8    t          | j        | j        g          S )a  Requests unlocking the item. Usually, this means that the
        whole collection containing this item will be unlocked.

        Returns a boolean representing whether the prompt has been
        dismissed; that means :const:`False` on successful unlocking
        and :const:`True` if it has been dismissed.

        .. versionadded:: 2.1.2

        .. versionchanged:: 3.0
           No longer accepts the ``callback`` argument.
        )r   r   r   r+   s    r   unlockzItem.unlock3   s     do/?@@@r!   c                 T    | j                             d          }t          |          S )z%Returns item attributes (dictionary).
Attributes)r   r   dict)r   attrss     r   get_attributeszItem.get_attributesB   s#    
''55E{{r!   
attributesc                 >    | j                             dd|           dS )z2Sets item attributes to `attributes` (dictionary).r2   za{ss}N)r   set_property)r   r6   s     r   set_attributeszItem.set_attributesG   s"    
gzBBBBBr!   c                 h    | j                             d          }t          |t                    sJ |S )z$Returns item label (unicode string).r   )r   r   r%   r&   r   labels     r   	get_labelzItem.get_labelK   s2    
''00%%%%%%r!   r<   c                 f    |                                   | j                            dd|           dS )zSets item label to `label`.r   sN)r.   r   r8   r;   s     r   	set_labelzItem.set_labelQ   s4       
e44444r!   c                     |                                   | j                            dd          \  }|dk    r)t          | j        |          \  }}|rt          d          dS dS )zDeletes the item.Delete /zPrompt dismissed.N)r.   r   callr   r   r	   )r   prompt	dismissed_results       r   deletezItem.deleteV   su       *//(B//S==!,T_f!E!EIw D./BCCC =D Dr!   c                    |                                   | j        st          | j                  | _        | j                            dd| j        j                  \  }| j        j        st          |d                   S | j        j	        J t          j        | j        j	                  }t          |d                   }t          |t          j        |          t                                                                }|d         }|                    t          |                    |                                z   }t'          |t                    sJ |d|d                   S )z!Returns item secret (bytestring).	GetSecreto   N   )r.   r   r   r   r   rE   object_path	encryptedbytesaes_keyr   AESr   r   CBCr   	decryptorupdatefinalizer%   )r   secretaesaes_ivrV   encrypted_secretpadded_secrets          r   
get_secretzItem.get_secret_   s5      | 	9'88DL*//+sDL4LMM|% 	$###|#///nT\122vay!!3	& 1 1?3D3DEEOOQQ	!!9!((/?)@)@AAIDVDVDXDXX-/////0}R00011r!   c                     |                                   | j        st          | j                  | _        | j                            dd| j        j                  \  }t          |d                   S )z-Returns content type of item secret (string).rK   rL      )r.   r   r   r   r   rE   rP   r&   )r   rY   s     r   get_secret_content_typezItem.get_secret_content_typep   s]       | 	9'88DL*//+sDL4LMM6!9~~r!   
text/plainrY   content_typec                     |                                   | j        st          | j                  | _        t	          | j        ||          }| j                            dd|           dS )zSets item secret to `secret`. If `content_type` is given,
        also sets the content type of the secret (``text/plain`` by
        default).	SetSecretz(oayays)N)r.   r   r   r   r   r   rE   )r   rY   rc   _secrets       r   
set_secretzItem.set_secretx   sb    
 	   | 	9'88DLflCC
Z99999r!   c                 h    | j                             d          }t          |t                    sJ |S )zxReturns UNIX timestamp (integer) representing the time
        when the item was created.

        .. versionadded:: 1.1Createdr   r   r%   int)r   createds     r   get_createdzItem.get_created   s4    
 *)))44'3'''''r!   c                 h    | j                             d          }t          |t                    sJ |S )z_Returns UNIX timestamp (integer) representing the time
        when the item was last modified.Modifiedrj   )r   modifieds     r   get_modifiedzItem.get_modified   s4     :**:66(C(((((r!   r$   )r   N)rb   )__name__
__module____qualname____doc__r   r&   r   r   r    r*   r'   r,   r.   r0   r   r5   r9   r=   r@   rI   rR   r^   ra   rg   rk   rm   rq    r!   r   r   r      s       ## ?C% %> %%*27*;%GK% % % %1, 1 1 1 1 174 7 7 7 7
5 5 5 5A A A A AS#X    
Cc3h CD C C C C3    5s 5t 5 5 5 5
D D D D2E 2 2 2 2"     (4	: 	: 	:!$	:8<	: 	: 	: 	:S    c      r!   N)ru   typingr   r   jeepney.io.blockingr   secretstorage.definesr   secretstorage.dhcryptor   secretstorage.exceptionsr   r	   secretstorage.utilr
   r   r   r   r   &cryptography.hazmat.primitives.ciphersr   r   r   cryptography.hazmat.backendsr   r   r   rv   r!   r   <module>r      s3  ? ? " ! ! ! ! ! ! ! . . . . . . + + + + + + * * * * * * N N N N N N N N: : : : : : : : : : : : : : L L L L L L L L L L 8 8 8 8 8 8
x x x x x x x x x xr!   