summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-02 21:57:50 -0700
committerLance Stout <lancestout@gmail.com>2011-07-02 21:57:50 -0700
commitfba235a801a3a1c06d1769cdc944b72dce33f88a (patch)
tree905c3243cee4991b0fc81332809f34042a2031c6 /sleekxmpp
parentb0297af38d6dcd9ebfdaa0131ea798c9fe2b8c63 (diff)
downloadslixmpp-fba235a801a3a1c06d1769cdc944b72dce33f88a.tar.gz
slixmpp-fba235a801a3a1c06d1769cdc944b72dce33f88a.tar.bz2
slixmpp-fba235a801a3a1c06d1769cdc944b72dce33f88a.tar.xz
slixmpp-fba235a801a3a1c06d1769cdc944b72dce33f88a.zip
Simplify SASL mech registration.
Moved SASL registration completely to the feature plugin, instead of keeping a portion of it in ClientXMPP.
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/clientxmpp.py26
-rw-r--r--sleekxmpp/features/feature_mechanisms/mechanisms.py4
-rw-r--r--sleekxmpp/features/sasl_anonymous.py5
-rw-r--r--sleekxmpp/features/sasl_plain.py5
-rw-r--r--sleekxmpp/stanza/stream/__init__.py8
5 files changed, 8 insertions, 40 deletions
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py
index 17a7582f..5b36e845 100644
--- a/sleekxmpp/clientxmpp.py
+++ b/sleekxmpp/clientxmpp.py
@@ -197,32 +197,6 @@ class ClientXMPP(BaseXMPP):
self._stream_feature_order.append((order, name))
self._stream_feature_order.sort()
- def register_sasl_mechanism(self, name, handler, priority=0):
- """
- Register a handler for a SASL authentication mechanism.
-
- Arguments:
- name -- The name of the mechanism (all caps)
- handler -- The function that will perform the
- authentication. The function must
- return True if it is able to carry
- out the authentication, False if
- a required condition is not met.
- priority -- An integer value indicating the
- preferred ordering for the mechanism.
- High values will be attempted first.
- """
- self['feature_mechanisms'].register_mechanism(name, handler, priority)
-
- def remove_sasl_mechanism(self, name):
- """
- Remove support for a given SASL authentication mechanism.
-
- Arguments:
- name -- The name of the mechanism to remove (all caps)
- """
- self['feature_mechanisms'].remove_mechanism(name)
-
def update_roster(self, jid, name=None, subscription=None, groups=[],
block=True, timeout=None, callback=None):
"""
diff --git a/sleekxmpp/features/feature_mechanisms/mechanisms.py b/sleekxmpp/features/feature_mechanisms/mechanisms.py
index 3cdb1b0a..a8a046e4 100644
--- a/sleekxmpp/features/feature_mechanisms/mechanisms.py
+++ b/sleekxmpp/features/feature_mechanisms/mechanisms.py
@@ -51,7 +51,7 @@ class feature_mechanisms(base_plugin):
restart=True,
order=self.config.get('order', 100))
- def register_mechanism(self, name, handler, priority=0):
+ def register(self, name, handler, priority=0):
"""
Register a handler for a SASL authentication mechanism.
@@ -70,7 +70,7 @@ class feature_mechanisms(base_plugin):
self._mechanism_priorities.append((priority, name))
self._mechanism_priorities.sort(reverse=True)
- def remove_mechanism(self, name):
+ def remove(self, name):
"""
Remove support for a given SASL authentication mechanism.
diff --git a/sleekxmpp/features/sasl_anonymous.py b/sleekxmpp/features/sasl_anonymous.py
index 71a4b2e5..98a0d36e 100644
--- a/sleekxmpp/features/sasl_anonymous.py
+++ b/sleekxmpp/features/sasl_anonymous.py
@@ -14,8 +14,9 @@ class sasl_anonymous(base_plugin):
self.name = 'SASL ANONYMOUS'
self.rfc = '6120'
self.description = 'SASL ANONYMOUS Mechanism'
+ self.stanza = self.xmpp['feature_mechanisms'].stanza
- self.xmpp.register_sasl_mechanism('ANONYMOUS',
+ self.xmpp['feature_mechanisms'].register('ANONYMOUS',
self._handle_anonymous,
priority=self.config.get('priority', 0))
@@ -23,7 +24,7 @@ class sasl_anonymous(base_plugin):
if self.xmpp.boundjid.user:
return False
- resp = self.xmpp['feature_sasl'].stanza.Auth(self.xmpp)
+ resp = self.stanza.Auth(self.xmpp)
resp['mechanism'] = 'ANONYMOUS'
resp.send(now=True)
diff --git a/sleekxmpp/features/sasl_plain.py b/sleekxmpp/features/sasl_plain.py
index 270d28fe..427660ab 100644
--- a/sleekxmpp/features/sasl_plain.py
+++ b/sleekxmpp/features/sasl_plain.py
@@ -14,8 +14,9 @@ class sasl_plain(base_plugin):
self.name = 'SASL PLAIN'
self.rfc = '6120'
self.description = 'SASL PLAIN Mechanism'
+ self.stanza = self.xmpp['feature_mechanisms'].stanza
- self.xmpp.register_sasl_mechanism('PLAIN',
+ self.xmpp['feature_mechanisms'].register('PLAIN',
self._handle_plain,
priority=self.config.get('priority', 1))
@@ -33,7 +34,7 @@ class sasl_plain(base_plugin):
auth = base64.b64encode(b'\x00' + user + \
b'\x00' + password).decode('utf-8')
- resp = self.xmpp['feature_mechanisms'].stanza.Auth(self.xmpp)
+ resp = self.stanza.Auth(self.xmpp)
resp['mechanism'] = 'PLAIN'
resp['value'] = auth
resp.send(now=True)
diff --git a/sleekxmpp/stanza/stream/__init__.py b/sleekxmpp/stanza/stream/__init__.py
deleted file mode 100644
index 2cb79673..00000000
--- a/sleekxmpp/stanza/stream/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2010 Nathanael C. Fritz
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-