HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/amqp/__pycache__/sasl.cpython-310.pyc
o

%web�@s�dZddlZddlZddlmZddlmZGdd�d�ZGdd�de�ZGd	d
�d
e�Z	dd�Z
e
�ZGd
d�de�ZGdd�de�Z
dS)z(SASL mechanisms for AMQP authentication.�N)�BytesIO)�_write_tablec@s$eZdZdZedd��Zdd�ZdS)�SASLz�The base class for all amqp SASL authentication mechanisms.

    You should sub-class this if you're implementing your own authentication.
    cC�t�)z2Return a bytes containing the SASL mechanism name.��NotImplementedError��self�r
�B/home/arjun/projects/env/lib/python3.10/site-packages/amqp/sasl.py�	mechanismszSASL.mechanismcCr)z@Return the first response to a SASL challenge as a bytes object.r�r	�
connectionr
r
r�startsz
SASL.startN)�__name__�
__module__�__qualname__�__doc__�propertyrrr
r
r
rr
s

rc@�(eZdZdZdZdd�ZdZdd�ZdS)	�PLAINzbPLAIN SASL authentication mechanism.

    See https://tools.ietf.org/html/rfc4616 for details
    sPLAINcC�|||_|_dS�N��username�password�r	rrr
r
r�__init__"�zPLAIN.__init__rcCs^|jdus
|jdurtSt�}|�d�|�|j�d��|�d�|�|j�d��|��S)N�zutf-8)rr�NotImplementedr�write�encode�getvalue�r	r�login_responser
r
rr*s

zPLAIN.startN�rrrrrr�	__slots__rr
r
r
rr�rc@r)	�AMQPLAINzhAMQPLAIN SASL authentication mechanism.

    This is a non-standard mechanism used by AMQP servers.
    sAMQPLAINcCrrrrr
r
rr=rzAMQPLAIN.__init__rcCsF|jdus
|jdurtSt�}t|j|jd�|jg�|��dd�S)N)sLOGINsPASSWORD�)rrr rrr!r#r$r
r
rrEs�zAMQPLAIN.startNr&r
r
r
rr)5r(r)csTz
ddl�ddl�WntyGdd�dt�}|YSwG�fdd�dt�}|S)Nrc@s*eZdZdZdZ		d	dd�Zdd�ZdS)
z)_get_gssapi_mechanism.<locals>.FakeGSSAPIz7A no-op SASL mechanism for when gssapi isn't available.N�amqpFcSs|std��dS)Nz?You need to install the `gssapi` module for GSSAPI SASL supportr�r	�client_name�service�rdns�	fail_softr
r
rrYs
��z2_get_gssapi_mechanism.<locals>.FakeGSSAPI.__init__cSstSr)r rr
r
rr`�z/_get_gssapi_mechanism.<locals>.FakeGSSAPI.start�Nr+FF�rrrrrrrr
r
r
r�
FakeGSSAPITs
�r4cs:eZdZdZdZ		d
dd�ZdZd	d
�Z�fdd�ZdS)z%_get_gssapi_mechanism.<locals>.GSSAPIzsGSSAPI SASL authentication mechanism.

            See https://tools.ietf.org/html/rfc4752 for details
            sGSSAPINr+FcSs4|rt|t�s|�d�}||_||_||_||_dS)N�ascii)�
isinstance�bytesr"r-r0r.r/r,r
r
rrls

z._get_gssapi_mechanism.<locals>.GSSAPI.__init__)r-r0r.r/cSs^|jj}|jr|jtjtjfvr|��}t�|d�\}}}n|jj	}t
|t�s-|�d�}|S)Nrr5)
�	transport�sockr/�family�socket�AF_INET�AF_INET6�getpeername�
gethostbyaddr�hostr6r7r")r	rr9�peer�hostname�_r
r
r�get_hostname|s�

z2_get_gssapi_mechanism.<locals>.GSSAPI.get_hostnamecs�z0|jr�j��|j�d�}nd}|�|�}��d�|j|g��jj�}�j||d�}|�	d�WS�j
jjyB|j
rAtYS�w)N)�name�@)rE�creds)r-�Credentials�NamerD�joinr.�NameType�hostbased_service�SecurityContext�step�raw�misc�GSSErrorr0r )r	rrGrBrE�context��gssapir
rr�s"
�
��z+_get_gssapi_mechanism.<locals>.GSSAPI.startr2)	rrrrrrr'rDrr
rSr
r�GSSAPIds
�	rU)rT�gssapi.raw.misc�ImportErrorr)r4rUr
rSr�_get_gssapi_mechanismOs�5rXc@seZdZdZdZdd�ZdS)�EXTERNALz�EXTERNAL SASL mechanism.

    Enables external authentication, i.e. not handled through this protocol.
    Only passes 'EXTERNAL' as authentication mechanism, but no further
    authentication data.
    sEXTERNALcCsdS)N�r
r
r
r
rr�r1zEXTERNAL.startN)rrrrrrr
r
r
rrY�srYc@s$eZdZdZdZdd�Zdd�ZdS)�RAWz�A generic custom SASL mechanism.

    This mechanism takes a mechanism name and response to send to the server,
    so can be used for simple custom authentication schemes.
    NcCs:t|t�sJ�t|t�sJ�|||_|_t�dt�dS)NznPassing login_method and login_response to Connection is deprecated. Please implement a SASL subclass instead.)r6r7r�response�warnings�warn�DeprecationWarning)r	rr\r
r
rr�s�zRAW.__init__cCs|jSr)r\r
r
r
rr�sz	RAW.startr3r
r
r
rr[�s
r[)rr;r]�ior�amqp.serializationrrrr)rXrUrYr[r
r
r
r�<module>sM