File manager - Edit - /usr/lib/python3/dist-packages/twisted/words/protocols/jabber/__pycache__/xmlstream.cpython-310.pyc
Back
o �b� � @ sr d Z ddlmZ ddlmZ ddlmZ ddlmZm Z ddl mZmZ ddl mZmZ ddlmZ dd lmZmZmZ dd lmZmZmZ ddlmZmZ ddlmZmZm Z m!Z! zdd l m"Z# W n e$ym dZ"Y n w e#j%stdZ"ne#Z"ed�Z&ed�Z'dZ(dZ)e*� Z+dd� Z,G dd� d�Z-G dd� de-�Z.G dd� de-�Z/G dd� de0�Z1eej2�G dd� d��Z3G dd � d e0�Z4G d!d"� d"e4�Z5G d#d$� d$e4�Z6G d%d&� d&e4�Z7G d'd(� d(e3�Z8G d)d*� d*ej9�Z9G d+d,� d,ej:�Z:G d-d.� d.ej;ej<�Z=G d/d0� d0e0�Z>d1d2� Z?G d3d4� d4ej@�ZAd>d5d6�ZBeejC�G d7d8� d8��ZDeejE�G d9d:� d:��ZFG d;d<� d<eF�ZGg d=�ZHdS )?a2 XMPP XML Streams Building blocks for setting up XML Streams, including helping classes for doing authentication on either client or server side, and working with XML Stanzas. @var STREAM_AUTHD_EVENT: Token dispatched by L{Authenticator} when the stream has been completely initialized @type STREAM_AUTHD_EVENT: L{str}. @var INIT_FAILED_EVENT: Token dispatched by L{Authenticator} when the stream has failed to be initialized @type INIT_FAILED_EVENT: L{str}. @var Reset: Token to signal that the XML stream has been reset. @type Reset: Basic object. � )�hexlify)�sha1)�intern)�Optional�Tuple)�directlyProvides�implementer)�defer�protocol)�ConnectionLost)�failure�log� randbytes)�error�ijabber�jid)�domish� xmlstream)�STREAM_CONNECTED_EVENT�STREAM_END_EVENT�STREAM_ERROR_EVENT�STREAM_START_EVENT)�sslNz//event/stream/authdz//event/xmpp/initfailedz http://etherx.jabber.org/streamszurn:ietf:params:xml:ns:xmpp-tlsc C sB t | t�s td��t |t�std��| � |� �}t|�d���� S )z� Create a SHA1-digest string of a session identifier and password. @param sid: The stream session identifier. @type sid: C{unicode}. @param password: The password to be hashed. @type password: C{unicode}. z/The session identifier must be a unicode objectz%The password must be a unicode objectzutf-8)� isinstance�str� TypeErrorr �encode� hexdigest)�sid�password�input� r! �J/usr/lib/python3/dist-packages/twisted/words/protocols/jabber/xmlstream.py�hashPassword@ s r# c @ �0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd S )� AuthenticatoraD Base class for business logic of initializing an XmlStream Subclass this object to enable an XmlStream to initialize and authenticate to different types of stream hosts (such as clients, components, etc.). Rules: 1. The Authenticator MUST dispatch a L{STREAM_AUTHD_EVENT} when the stream has been completely initialized. 2. The Authenticator SHOULD reset all state information when L{associateWithStream} is called. 3. The Authenticator SHOULD override L{streamStarted}, and start initialization there. @type xmlstream: L{XmlStream} @ivar xmlstream: The XmlStream that needs authentication @note: the term authenticator is historical. Authenticators perform all steps required to prepare the stream for the exchange of XML stanzas. c C s d | _ d S �N�r ��selfr! r! r"