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: //usr/lib/python3/dist-packages/pymacaroons/__pycache__/macaroon.cpython-38.pyc
U

�%�Ya�@s�ddlmZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZmZd	Zd
ZGdd�de�ZdS)
�)�unicode_literalsN)�standard_b64encode)�HashSignaturesBinder)�BinarySerializer)�MacaroonInitException)�convert_to_bytes�convert_to_string�create_initial_signature)�FirstPartyCaveatDelegate�ThirdPartyCaveatDelegate��c@s�eZdZdddddefdd�Zed%dd��Zedd��Zej	dd��Zed	d
��Z
edd��Zed
d��Zej	dd��Zedd��Z
e
j	dd��Z
edd��Zdd�Zd&dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)'�MacaroonNcCsd|tkrt}||_|pg|_|p"d|_|p,d|_|p6d|_t�|_t�|_	|r`t
t|�|j�|_dS)N�)
�MACAROON_V2�_version�caveats�location�
identifier�	signaturer
�first_party_caveat_delegater�third_party_caveat_delegater	r�identifier_bytes)�selfrr�keyrr�version�r�6/usr/lib/python3/dist-packages/pymacaroons/macaroon.py�__init__s



�zMacaroon.__init__cCs$|pt�}|r|�|�Std��dS)Nz Must supply serialized macaroon.)r�deserializer)�clsZ
serialized�
serializerrrrr+s

�zMacaroon.deserializecCs
t|j�S�N)r�	_location�rrrrr5szMacaroon.locationcCst|�|_dSr")rr#�rZstring_or_bytesrrrr9scCs|jSr")rr$rrrr=szMacaroon.versioncCs|jtkrt|j�S|jSr")r�MACAROON_V1r�_identifierr$rrrrAs

zMacaroon.identifiercCs|jSr")r'r$rrrrGszMacaroon.identifier_bytescCst|�|_dSr")rr'r%rrrrKscCs
t|j�Sr")r�
_signaturer$rrrrOszMacaroon.signaturecCst|�|_dSr")rr(r%rrrrSscCs|jSr")r(r$rrr�signature_bytesWszMacaroon.signature_bytescCs
t�|�Sr")�copy�deepcopyr$rrrr*[sz
Macaroon.copycCs|pt�}|�|�Sr")r�	serialize)rr!rrrr,^s
zMacaroon.serializec	Cs�dj|jd�}z|dj|jd�7}Wn.tk
rR|djtt|j��d�7}YnX|jD]�}z|djt|j�d�7}Wn.tk
r�|djtt|j	��d�7}YnX|j
rZ|jrZtt|j
��}|d	j|d
�7}|dj|jd�7}qZ|d
j|jd�7}|S)Nzlocation {loc}
)Zloczidentifier {id}
)�idzidentifier64 {id}
z
cid {cid}
)Zcidzcid64 {cid}
z
vid {vid}
)�vidzcl {cl}
)Zclzsignature {sig})Zsig)�formatrr�UnicodeEncodeErrorrrrrZ	caveat_idZcaveat_id_bytesZverification_key_idr)rZcombined�caveatr.rrr�inspectbs0�
���zMacaroon.inspectcCsdd�|jD�S)NcSsg|]}|��r|�qSr)Zfirst_party��.0r1rrr�
<listcomp>|sz0Macaroon.first_party_caveats.<locals>.<listcomp>�rr$rrr�first_party_caveats{szMacaroon.first_party_caveatscCsdd�|jD�S)NcSsg|]}|��r|�qSr)Zthird_partyr3rrrr5sz0Macaroon.third_party_caveats.<locals>.<listcomp>r6r$rrr�third_party_caveats~szMacaroon.third_party_caveatscCs|��}t|��|�S)a$ Return a new discharge macaroon bound to the receiving macaroon's
        current signature so that it can be used in a request.

        This must be done before a discharge macaroon is sent to a server.

        :param discharge_macaroon:
        :return: bound discharge macaroon
        )r*rZbind)rZdischarge_macaroonZ	protectedrrr�prepare_for_request�s	zMacaroon.prepare_for_requestcKs|jj||f|�Sr")r�add_first_party_caveat)rZ	predicate�kwargsrrrr:�s��zMacaroon.add_first_party_caveatcKs|jj||||f|�Sr")r�add_third_party_caveat)rrrZkey_idr;rrrr<�s��zMacaroon.add_third_party_caveat)N)N)�__name__�
__module__�__qualname__r&r�classmethodr�propertyr�setterrrrrr)r*r,r2r7r8r9r:r<rrrrrsF�
	









r)Z
__future__rr*�base64rZpymacaroons.bindersrZ)pymacaroons.serializers.binary_serializerrZpymacaroons.exceptionsrZpymacaroons.utilsrrr	Zpymacaroons.caveat_delegatesr
rr&r�objectrrrrr�<module>s