# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
XMPP-specific SASL profile.
"""

import re
from twisted.internet import defer
from twisted.words.protocols.jabber import sasl_mechanisms, xmlstream
from twisted.words.xish import domish

# The b64decode and b64encode functions from the base64 module are new in
# Python 2.4. For Python 2.3 compatibility, the legacy interface is used while
# working around MIMEisms.

try:
    from base64 import b64decode, b64encode
except ImportError:
    import base64

    def b64encode(s):
        return "".join(base64.encodestring(s).split("\n"))

    b64decode = base64.decodestring

NS_XMPP_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl'

def get_mechanisms(xs):