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: //proc/self/root/usr/lib/python3/dist-packages/keyring/backends/__pycache__/Windows.cpython-38.pyc
U

ۦ�\��	@s�ddlmZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
e
��TZz"dd	lmZdd
lmZejWn*ek
r�ddlZddlZejYnXW5QRXeZGdd�de�ZGd
d�d�ZdS)�)�unicode_literalsN�)�	text_type)�
properties)�KeyringBackend)�SimpleCredential)�PasswordDeleteError�ExceptionRaisedContext)�
pywintypes)�	win32credc@sfeZdZdZejedd���Zedd��Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�Zdd�ZdS)�WinVaultKeyringa�
    WinVaultKeyring stores encrypted passwords using the Windows Credential
    Manager.

    Requires pywin32

    This backend does some gymnastics to simulate multi-user support,
    which WinVault doesn't support natively. See
    https://bitbucket.org/kang/python-keyring-lib/issue/47/winvaultkeyring-only-ever-returns-last#comment-731977
    for details on the implementation, but here's the gist:

    Passwords are stored under the service name unless there is a collision
    (another password with the same service name but different user name),
    in which case the previous password is moved into a compound name:
    {username}@{service}
    cCstrtd��dS)zA
        If available, the preferred backend on Windows.
        zRequires Windows and pywin32�)�missing_deps�RuntimeError)�cls�r�:/usr/lib/python3/dist-packages/keyring/backends/Windows.py�priority0szWinVaultKeyring.prioritycCs
dt�S)Nz%(username)s@%(service)s)�vars)�username�servicerrr�_compound_name:szWinVaultKeyring._compound_namecCsF|�|�}|r|d|kr,|�|�||��}|s4dS|d}|�d�S�N�UserName�CredentialBlobzutf-16)�
_get_passwordr�decode)�selfrr�resZblobrrr�get_password>s
zWinVaultKeyring.get_passwordc
Cshztjtj|d�}WnNtjk
rb}z.t�|�}|jdkrP|jdkrPWY�
dS�W5d}~XYnX|S)N��Type�
TargetName��CredRead)	rr$�CRED_TYPE_GENERICr
�error�
OldPywinError�wrap�winerror�funcname)r�targetr�errrrIs�


zWinVaultKeyring._get_passwordcCsP|�|�}|r:|d}|�||�}|�|||d�d��|�||t|��dSr)rr�
_set_passwordrr)rrr�password�existing_pwZexisting_usernamer+rrr�set_passwordVs
�zWinVaultKeyring.set_passwordcCs(ttj|||dtjd�}t�|d�dS)NzStored using python-keyring)r!r"rr�CommentZPersistr)�dictrr%ZCRED_PERSIST_ENTERPRISEZ	CredWrite)rr+rr.Z
credentialrrrr-`s�zWinVaultKeyring._set_passwordcCsV|�||�}d}||fD],}|�|�}|r|d|krd}|�|�q|sRt|��dS)NFrT)rr�_delete_passwordr)rrrZcompoundZdeletedr+r/rrr�delete_passwordis
zWinVaultKeyring.delete_passwordc
Cshztjtj|d�WnNtjk
rb}z.t�|�}|jdkrP|jdkrPWY�
dS�W5d}~XYnXdS)Nr r#�
CredDelete)	rr5r%r
r&r'r(r)r*)rr+r,rrrr3ts�


z WinVaultKeyring._delete_passwordcCsHd}|r|�|�||��}|s0|�|�}|s0dSt|d|d�d��Sr)rrrr)rrrrrrr�get_credential�s
�zWinVaultKeyring.get_credentialN)�__name__�
__module__�__qualname__�__doc__rZ
ClassProperty�classmethodr�staticmethodrrrr0r-r4r3r6rrrrrs


	rc@s<eZdZdZdd�Zedd��Zedd��Zedd	��Z	d
S)r'z�
    A compatibility wrapper for old PyWin32 errors, such as reported in
    https://bitbucket.org/kang/python-keyring-lib/issue/140/
    cCs
||_dS)N��orig)rr>rrr�__init__�szOldPywinError.__init__cCs
|jdS)N�r=�rrrrr*�szOldPywinError.funcnamecCs
|jdS)Nrr=rArrrr)�szOldPywinError.winerrorcCs0t�t|�}tt|ddg��}|r,||�S|S)Nr*r))�	functools�partial�hasattr�all�map)rZorig_errZ
attr_checkZis_oldrrrr(�szOldPywinError.wrapN)
r7r8r9r:r?�propertyr*r)r;r(rrrrr'�s

r')Z
__future__rrBZ
py27compatr�utilrZbackendrZcredentialsr�errorsrr	rZwin32ctypes.pywin32r
rr7�ImportError�typeZ
__metaclass__rr'rrrr�<module>s$
r