%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/duplicity/backends/pyrax_identity/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/duplicity/backends/pyrax_identity/__pycache__/hubic.cpython-312.pyc

�

�2e&��8�ddlZddlZddlZddlZddlZddlmZmZddl	Z		ddl
Z
ddlmZm
Z
ddlmZdZdZej.j1d�ZGd�d	e	j4j6�ZGd
�de�Zy#e$rZedee�����dZ[wwxYw)�N)�quote�
quote_plus)�BaseIdentity�ServicezNHubic backend requires the pyrax library available from Rackspace.
Exception: zhttps://api.hubic.com/oauth/zhttps://api.hubic.com/1.0/z~/.hubic_tokensc��eZdZd�Zd�Zy)�BearerTokenAuthc��||_y)N)�token)�selfr
s  �I/usr/lib/python3/dist-packages/duplicity/backends/pyrax_identity/hubic.py�__init__zBearerTokenAuth.__init__&s	����
�c�>�d|j��|jd<|S)NzBearer �
Authorization)r
�headers)r�reqs  r�__call__zBearerTokenAuth.__call__)s ��)0�����'=����O�$��
rN)�__name__�
__module__�__qualname__r
r�rrrr%s���rrc�:�eZdZd�Z	d	d�Zd�Zd�Zd�Zd�Zd�Z	y)
�
HubicIdentityc��y)N�r)rs r�_get_auth_endpointz HubicIdentity._get_auth_endpoint/s��rc�~�||_||_||_||_||_||_|r|j
�yy)z(Sets the username and password directly.N)�_email�	_password�
_client_id�	tenant_id�_client_secret�
_redirect_uri�authenticate)r�email�password�	client_id�
client_secret�redirect_urir$s       r�set_credentialszHubicIdentity.set_credentials2sD�����!���#���"���+���)��������rc��|jdd�|_|jdd�|_|jdd�|_|j|_|jdd�|_|jdd�|_y)zL
        Parses the credential file with Rackspace-specific labels.
        �hubicr%r&r'r(r)N)�getrrr r!r"r#)r�cfgs  r�_read_credential_filez#HubicIdentity._read_credential_fileEsk���g�g�g�w�/�������*�5����'�'�'�;�7��������!�g�g�g��?��� �W�W�W�n�=��rc���d|jvrytjj|jd�j}ttjj
|��}|d|dd�S)N�location�error�error_description)r2r3)r�urllib�parse�urlsplit�query�dict�	parse_qsl)r�respr7�qss    r�_parse_errorzHubicIdentity._parse_errorPsb���T�\�\�)�����%�%�d�l�l�:�&>�?�E�E��
�&�,�,�(�(��/�
0���G��2�>Q�;R�S�Src�b�tjt�d�||jdd�|j|j
f��}|jdk7rB	|j�}|j|d<tjdt|��d���|j�}tj�}|jt�|j!d	�s|j#d	�|d
�A|j%d	d
|d
�t'td�5}|j)|�ddd�n"tjdt��d���|d�A|j%d	d|d�t'td�5}|j)|�ddd�ntjd
��|j+d	d�rG|j-d	d�t'td�5}|j)|�ddd�t/d�|j+d	d�rG|j-d	d�t'td�5}|j)|�ddd�t/d�|S#t$r
}i}Yd}~��d}~wwxYw#1swY��2xYw#1swY��xYw#1swY��xYw#1swY�TxYw)N�token/�authorization_code)�coder)�
grant_type��data�auth��r@�FUnable to get oauth access token, wrong client_id or client_secret ? (�)r,�access_token�wb�
refresh_tokenz Unable to get the refresh token.r%zEusername has been removed from the .hubic_tokens file sent to the CE.r&zEpassword has been removed from the .hubic_tokens file sent to the CE.)�requests�post�OAUTH_ENDPOINTr#r r"�status_code�json�	Exception�exc�AuthenticationFailed�str�configparser�ConfigParser�read�TOKENS_FILE�has_section�add_section�set�open�write�
has_option�
remove_option�print)rr@�r�err�e�oauth_token�config�
configfiles        r�_get_access_tokenzHubicIdentity._get_access_tokenWs����M�M���f�%�� $� 2� 2�2��
�/�/�4�#6�#6�7�
��
�=�=�C��
��f�f�h���m�m��F���*�*�\�]`�ad�]e�\f�fg�h��
��f�f�h���*�*�,�����K� ��!�!�'�*����w�'��~�&�2��J�J�w���N�0K�L��k�4�(�
)�J����Z�(�
)�
)��*�*�X�Y\�]`�Ya�Xb�bc�d��
���'�3��J�J�w���_�1M�N��k�4�(�
)�J����Z�(�
)�
)��*�*�+M�N�N����W�g�.�� � ��'�2��k�4�(�
)�J����Z�(�
)��Y�Z����W�j�1�� � ��*�5��k�4�(�
)�J����Z�(�
)��Y�Z����W�
����
��"
)�
)��
)�
)��
)�
)��

)�
)�sH�I'�J�J
�'J�J%�'	I=�0I8�8I=�J
�
J�J"�%J.c�*�tj�}|jt�|j	dd�}|�tjd��d}d}d}d}d}||kr�|s�tjt�d	�|dd
�|j|jf��}|jdk7r�|jd
k(r4td|d�|dz
}tj|�|dz}||kDrG|}nD	|j!�}	|j|	d<tjdt%|	��d���d}||kr|s��|stjd��j!�}|d�|Stjd��#t"$r}
i}	Yd}
~
�d}
~
wwxYw)Nr,rJz-refresh_token is null. Not acquiered before ?F�r�ir>)rJrArBrEi�zstatus_code 509: attempt #z failed��r@rFrGTz]All the attempts failed to get the refresh token: status_code = 509: Bandwidth Limit ExceededrHz*Unable to get oauth access token from json)rTrUrVrWr-rQrRrKrLrMr r"rNr_�time�sleeprOrPrS)rrdrJ�success�max_retries�retries�
sleep_time�max_sleep_timer`rarbrcs            r�_refresh_access_tokenz#HubicIdentity._refresh_access_token�s����*�*�,�����K� ��
�
�7�O�<�
�� ��*�*�+Z�[�[��������
�����#�G��
�
�!�"�&�)�%2�"1���o�o�t�':�':�;�
�A��}�}��#��=�=�C�'��6���K��q�L�G��J�J�z�*�!+�a��J�!�N�2�%3�
�!��f�f�h��&'�m�m��F���2�2�`�ad�eh�ai�`j�jk�l�����9��#�G�<��*�*�r��
��f�f�h���~�&�2����*�*�+W�X�X��'%�!� ���!�s�/E=�=	F�F
�
Fc
��tj�}|jt�|j	dd�r|j�}�nt
jtdt|j��dt|j��dtjj���zd��}|j dk7r1t#j$d	t'|j)|���d
���	ddlm}|r>|j1|j2�j5d
�}|r|dj6nd}n5t9j:d|j2�}|r|j=d�nd}|st#j$d��|j>�|j@�t#j$d��t
jBt�d�d||j>|j@ddd�d��}	tDjFjI|jJd�jL}tOtDjFjQ|��d}|jU|�}|djW�dk7rt#j$d��t
jtX�d�t[|d���}|j]�}	d |_/|	d!|_0|	d"|_1te|d#d$d%|	d&igd'��|jfd(<dx|_4|_5y#t.$rd}Y��&wxYw#tR$r}t#j$d��d}~wwxYw))Nr,rJzauth/?client_id=z&redirect_uri=z8&scope=credentials.r,account.r&response_type=code&state=F)�allow_redirectsrEz"Incorrect/unauthorized client_id (rGr)�htmlz//input[@name="oauth"]zD<input\s+[^>]*name=[\'"]?oauth[\'"]?\s+[^>]*value=[\'"]?(\d+)[\'"]?>rjz.Unable to get oauth_id from authorization pagezLCannot retrieve email and/or password. Please run expresslane-hubic-setup.shzauth/�acceptedr`)�action�oauth�login�user_pwd�account�credentials)rCrur1r@z7Unable to authorize client_id, invalid login/password ?�
token_type�bearerzUnsupported access token typezaccount/credentialsrH)rDTr
�expires�HubiC�
cloudfiles�
public_url�endpoint)�name�type�	endpoints�object_store)6rTrUrVrWr]rsrKr-rMrr rr#�pyrax�utils�random_asciirNrQrRrSr<�lxmlrv�ImportError�document_fromstring�content�xpath�value�re�search�grouprrrLr4r5r6rr7r8r9rPrf�lower�API_ENDPOINTrrO�
authenticatedr
r�r�services�usernamer&)
rrdrcr`�	lxml_htmlryr7r@rb�swift_tokens
          rr$zHubicIdentity.authenticate�s���*�*�,�����K� ����W�o�6��4�4�6�K�����$�U�4�?�?�%;�$<�N�:�VZ�Vh�Vh�Ki�Jj�J�5�;�;�Kc�Kc�Ke�Jf�h�h�!&�	�A��}�}��#��.�.�1S�TW�X\�Xi�Xi�jk�Xl�Tm�Sn�no�/p�q�q�
!�2��!�5�5�a�i�i�@�F�F�G_�`��*/��a����T���	�	�[��I�I���+0����A��T����.�.�/_�`�`��{�{�"�d�n�n�&<��.�.�e����
�
�!�"�%�(�(�"�!�[�[� $���"�#&�
�!&��A�
m����-�-�a�i�i�
�.C�D�J�J���F�L�L�2�2�5�9�:�6�B���0�0��6�K��|�$�*�*�,��8��*�*�+J�K�K��L�L��n�/�0� ��^�!<�=�
��
�f�f�h��!��� ��)��
�"�9�-���(/���$�+�[��-D�E�F�
�)
��
�
�n�%�)-�,��
��
��}�
!� �	�
!��J�
m��.�.�/k�l�l��
m�s+�8L�2A!L(�L%�$L%�(	M�1M�MN)F)
rrrrr*r/r<rfrsr$rrrrr.s/���� �&	>�T�9�v6Y�pP-rr)rT�osr�rl�urllib.parser4�requests.compatrrrKr��pyrax.base_identityrr�pyrax.exceptions�
exceptionsrQr�rb�BackendExceptionrSrMr��path�
expanduserrWrD�AuthBaserrrrr�<module>r�s����	�	��������#�0��+���g�g� � �!2�3���h�m�m�,�,��l-�L�l-��)��
�
���F�8�	�����s�A>�>B�B�B

Zerion Mini Shell 1.0