# ``twisted`.`words`.`protocols`.`jabber`.`xmlstream`.`Authenticator``

class documentation

`class Authenticator: (source)`

Known subclasses: `twisted.words.protocols.jabber.xmlstream.ConnectAuthenticator`, `twisted.words.protocols.jabber.xmlstream.ListenAuthenticator`

View In Hierarchy

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 `STREAM_AUTHD_EVENT` when the stream has been completely initialized.
2. The Authenticator SHOULD reset all state information when `associateWithStream` is called.
3. The Authenticator SHOULD override `streamStarted`, and start initialization there.

Note
the term authenticator is historical. Authenticators perform all steps required to prepare the stream for the exchange of XML stanzas.

Method | `__init__` | Undocumented
Method | `associateWithStream` | Called by the XmlStreamFactory when a connection has been made to the requested peer, and an XmlStream object has been instantiated.
Method | `connectionMade` | Called by the XmlStream when the underlying socket connection is in place.
Method | `streamStarted` | Called by the XmlStream when the stream has started.
Instance Variable | `xmlstream` | The XmlStream that needs authentication

def __init__(self): (source)
overridden in `twisted.words.protocols.jabber.component.ListenComponentAuthenticator`, `twisted.words.protocols.jabber.xmlstream.ConnectAuthenticator`

Undocumented

def associateWithStream(self, xmlstream): (source)
overridden in `twisted.words.protocols.jabber.client.BasicAuthenticator`, `twisted.words.protocols.jabber.client.XMPPAuthenticator`, `twisted.words.protocols.jabber.component.ConnectComponentAuthenticator`, `twisted.words.protocols.jabber.xmlstream.ListenAuthenticator`

Called by the XmlStreamFactory when a connection has been made to the requested peer, and an XmlStream object has been instantiated.

The default implementation just saves a handle to the new XmlStream.

Parameters
xmlstream:`XmlStream` | The XmlStream that will be passing events to this Authenticator.

def connectionMade(self): (source)
overridden in `twisted.words.protocols.jabber.xmlstream.ConnectAuthenticator`

Called by the XmlStream when the underlying socket connection is in place.

This allows the Authenticator to send an initial root element, if it's connecting, or wait for an inbound root from the peer if it's accepting the connection.

Subclasses can use self.xmlstream.send() to send any initial data to the peer.

def streamStarted(self, rootElement): (source)
overridden in `twisted.words.protocols.jabber.xmlstream.ConnectAuthenticator`, `twisted.words.protocols.jabber.xmlstream.ListenAuthenticator`

Called by the XmlStream when the stream has started.

A stream is considered to have started when the start tag of the root element has been received.

This examines `rootElement` to see if there is a version attribute. If absent, `0.0` is assumed per RFC 3920. Subsequently, the minimum of the version from the received stream header and the value stored in `xmlstream` is taken and put back in `xmlstream`.

Extensions of this method can extract more information from the stream header and perform checks on them, optionally sending stream errors and closing the stream.

xmlstream: `XmlStream` = (source)
The XmlStream that needs authentication