summaryrefslogtreecommitdiff
path: root/sleekxmpp/features/feature_mechanisms/stanza
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/features/feature_mechanisms/stanza')
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/__init__.py16
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/abort.py24
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/auth.py49
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/challenge.py39
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/failure.py76
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/mechanisms.py53
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/response.py39
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza/success.py38
8 files changed, 0 insertions, 334 deletions
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/__init__.py b/sleekxmpp/features/feature_mechanisms/stanza/__init__.py
deleted file mode 100644
index 38991d89..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-
-from sleekxmpp.features.feature_mechanisms.stanza.mechanisms import Mechanisms
-from sleekxmpp.features.feature_mechanisms.stanza.auth import Auth
-from sleekxmpp.features.feature_mechanisms.stanza.success import Success
-from sleekxmpp.features.feature_mechanisms.stanza.failure import Failure
-from sleekxmpp.features.feature_mechanisms.stanza.challenge import Challenge
-from sleekxmpp.features.feature_mechanisms.stanza.response import Response
-from sleekxmpp.features.feature_mechanisms.stanza.abort import Abort
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/abort.py b/sleekxmpp/features/feature_mechanisms/stanza/abort.py
deleted file mode 100644
index aaca348d..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/abort.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-from sleekxmpp.xmlstream import StanzaBase
-
-
-class Abort(StanzaBase):
-
- """
- """
-
- name = 'abort'
- namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
- interfaces = set()
- plugin_attrib = name
-
- def setup(self, xml):
- StanzaBase.setup(self, xml)
- self.xml.tag = self.tag_name()
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/auth.py b/sleekxmpp/features/feature_mechanisms/stanza/auth.py
deleted file mode 100644
index 6b6f85a3..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/auth.py
+++ /dev/null
@@ -1,49 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-import base64
-
-from sleekxmpp.util import bytes
-from sleekxmpp.xmlstream import StanzaBase
-
-
-class Auth(StanzaBase):
-
- """
- """
-
- name = 'auth'
- namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
- interfaces = set(('mechanism', 'value'))
- plugin_attrib = name
-
- #: Some SASL mechs require sending values as is,
- #: without converting base64.
- plain_mechs = set(['X-MESSENGER-OAUTH2'])
-
- def setup(self, xml):
- StanzaBase.setup(self, xml)
- self.xml.tag = self.tag_name()
-
- def get_value(self):
- if not self['mechanism'] in self.plain_mechs:
- return base64.b64decode(bytes(self.xml.text))
- else:
- return self.xml.text
-
- def set_value(self, values):
- if not self['mechanism'] in self.plain_mechs:
- if values:
- self.xml.text = bytes(base64.b64encode(values)).decode('utf-8')
- elif values == b'':
- self.xml.text = '='
- else:
- self.xml.text = bytes(values).decode('utf-8')
-
- def del_value(self):
- self.xml.text = ''
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/challenge.py b/sleekxmpp/features/feature_mechanisms/stanza/challenge.py
deleted file mode 100644
index 24290281..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/challenge.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-import base64
-
-from sleekxmpp.util import bytes
-from sleekxmpp.xmlstream import StanzaBase
-
-
-class Challenge(StanzaBase):
-
- """
- """
-
- name = 'challenge'
- namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
- interfaces = set(('value',))
- plugin_attrib = name
-
- def setup(self, xml):
- StanzaBase.setup(self, xml)
- self.xml.tag = self.tag_name()
-
- def get_value(self):
- return base64.b64decode(bytes(self.xml.text))
-
- def set_value(self, values):
- if values:
- self.xml.text = bytes(base64.b64encode(values)).decode('utf-8')
- else:
- self.xml.text = '='
-
- def del_value(self):
- self.xml.text = ''
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/failure.py b/sleekxmpp/features/feature_mechanisms/stanza/failure.py
deleted file mode 100644
index b9f32605..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/failure.py
+++ /dev/null
@@ -1,76 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-from sleekxmpp.xmlstream import StanzaBase, ET
-
-
-class Failure(StanzaBase):
-
- """
- """
-
- name = 'failure'
- namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
- interfaces = set(('condition', 'text'))
- plugin_attrib = name
- sub_interfaces = set(('text',))
- conditions = set(('aborted', 'account-disabled', 'credentials-expired',
- 'encryption-required', 'incorrect-encoding', 'invalid-authzid',
- 'invalid-mechanism', 'malformed-request', 'mechansism-too-weak',
- 'not-authorized', 'temporary-auth-failure'))
-
- def setup(self, xml=None):
- """
- Populate the stanza object using an optional XML object.
-
- Overrides ElementBase.setup.
-
- Sets a default error type and condition, and changes the
- parent stanza's type to 'error'.
-
- Arguments:
- xml -- Use an existing XML object for the stanza's values.
- """
- # StanzaBase overrides self.namespace
- self.namespace = Failure.namespace
-
- if StanzaBase.setup(self, xml):
- #If we had to generate XML then set default values.
- self['condition'] = 'not-authorized'
-
- self.xml.tag = self.tag_name()
-
- def get_condition(self):
- """Return the condition element's name."""
- for child in self.xml:
- if "{%s}" % self.namespace in child.tag:
- cond = child.tag.split('}', 1)[-1]
- if cond in self.conditions:
- return cond
- return 'not-authorized'
-
- def set_condition(self, value):
- """
- Set the tag name of the condition element.
-
- Arguments:
- value -- The tag name of the condition element.
- """
- if value in self.conditions:
- del self['condition']
- self.xml.append(ET.Element("{%s}%s" % (self.namespace, value)))
- return self
-
- def del_condition(self):
- """Remove the condition element."""
- for child in self.xml:
- if "{%s}" % self.condition_ns in child.tag:
- tag = child.tag.split('}', 1)[-1]
- if tag in self.conditions:
- self.xml.remove(child)
- return self
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/mechanisms.py b/sleekxmpp/features/feature_mechanisms/stanza/mechanisms.py
deleted file mode 100644
index bbd56813..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/mechanisms.py
+++ /dev/null
@@ -1,53 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-from sleekxmpp.xmlstream import ElementBase, ET
-
-
-class Mechanisms(ElementBase):
-
- """
- """
-
- name = 'mechanisms'
- namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
- interfaces = set(('mechanisms', 'required'))
- plugin_attrib = name
- is_extension = True
-
- def get_required(self):
- """
- """
- return True
-
- def get_mechanisms(self):
- """
- """
- results = []
- mechs = self.findall('{%s}mechanism' % self.namespace)
- if mechs:
- for mech in mechs:
- results.append(mech.text)
- return results
-
- def set_mechanisms(self, values):
- """
- """
- self.del_mechanisms()
- for val in values:
- mech = ET.Element('{%s}mechanism' % self.namespace)
- mech.text = val
- self.append(mech)
-
- def del_mechanisms(self):
- """
- """
- mechs = self.findall('{%s}mechanism' % self.namespace)
- if mechs:
- for mech in mechs:
- self.xml.remove(mech)
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/response.py b/sleekxmpp/features/feature_mechanisms/stanza/response.py
deleted file mode 100644
index ca7624f1..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/response.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-import base64
-
-from sleekxmpp.util import bytes
-from sleekxmpp.xmlstream import StanzaBase
-
-
-class Response(StanzaBase):
-
- """
- """
-
- name = 'response'
- namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
- interfaces = set(('value',))
- plugin_attrib = name
-
- def setup(self, xml):
- StanzaBase.setup(self, xml)
- self.xml.tag = self.tag_name()
-
- def get_value(self):
- return base64.b64decode(bytes(self.xml.text))
-
- def set_value(self, values):
- if values:
- self.xml.text = bytes(base64.b64encode(values)).decode('utf-8')
- else:
- self.xml.text = '='
-
- def del_value(self):
- self.xml.text = ''
diff --git a/sleekxmpp/features/feature_mechanisms/stanza/success.py b/sleekxmpp/features/feature_mechanisms/stanza/success.py
deleted file mode 100644
index 7a4eab8e..00000000
--- a/sleekxmpp/features/feature_mechanisms/stanza/success.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2011 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-import base64
-
-from sleekxmpp.util import bytes
-from sleekxmpp.xmlstream import StanzaBase
-
-class Success(StanzaBase):
-
- """
- """
-
- name = 'success'
- namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
- interfaces = set(['value'])
- plugin_attrib = name
-
- def setup(self, xml):
- StanzaBase.setup(self, xml)
- self.xml.tag = self.tag_name()
-
- def get_value(self):
- return base64.b64decode(bytes(self.xml.text))
-
- def set_value(self, values):
- if values:
- self.xml.text = bytes(base64.b64encode(values)).decode('utf-8')
- else:
- self.xml.text = '='
-
- def del_value(self):
- self.xml.text = ''