2 Slixmpp: The Slick XMPP Library
3 Copyright (C) 2011 Nathanael C. Fritz
4 This file is part of Slixmpp.
6 See the file LICENSE for copying permission.
11 from slixmpp
.util
import bytes
12 from slixmpp
.xmlstream
import StanzaBase
15 class Auth(StanzaBase
):
21 namespace
= 'urn:ietf:params:xml:ns:xmpp-sasl'
22 interfaces
= set(('mechanism', 'value'))
25 #: Some SASL mechs require sending values as is,
26 #: without converting base64.
27 plain_mechs
= set(['X-MESSENGER-OAUTH2'])
30 StanzaBase
.setup(self
, xml
)
31 self
.xml
.tag
= self
.tag_name()
34 if not self
['mechanism'] in self
.plain_mechs
:
35 return base64
.b64decode(bytes(self
.xml
.text
))
39 def set_value(self
, values
):
40 if not self
['mechanism'] in self
.plain_mechs
:
42 self
.xml
.text
= bytes(base64
.b64encode(values
)).decode('utf-8')
46 self
.xml
.text
= bytes(values
).decode('utf-8')