summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0078.py
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/plugins/xep_0078.py')
-rw-r--r--sleekxmpp/plugins/xep_0078.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/sleekxmpp/plugins/xep_0078.py b/sleekxmpp/plugins/xep_0078.py
index 4b3ab829..d2c81b16 100644
--- a/sleekxmpp/plugins/xep_0078.py
+++ b/sleekxmpp/plugins/xep_0078.py
@@ -2,7 +2,7 @@
SleekXMPP: The Sleek XMPP Library
Copyright (C) 2010 Nathanael C. Fritz
This file is part of SleekXMPP.
-
+
See the file LICENSE for copying permission.
"""
from __future__ import with_statement
@@ -12,6 +12,9 @@ import hashlib
from . import base
+log = logging.getLogger(__name__)
+
+
class xep_0078(base.base_plugin):
"""
XEP-0078 NON-SASL Authentication
@@ -23,14 +26,14 @@ class xep_0078(base.base_plugin):
#disabling until I fix conflict with PLAIN
#self.xmpp.registerFeature("<auth xmlns='http://jabber.org/features/iq-auth'/>", self.auth)
self.streamid = ''
-
+
def check_stream(self, xml):
self.streamid = xml.attrib['id']
if xml.get('version', '0') != '1.0':
self.auth()
-
+
def auth(self, xml=None):
- logging.debug("Starting jabber:iq:auth Authentication")
+ log.debug("Starting jabber:iq:auth Authentication")
auth_request = self.xmpp.makeIqGet()
auth_request_query = ET.Element('{jabber:iq:auth}query')
auth_request.attrib['to'] = self.xmpp.server
@@ -47,12 +50,12 @@ class xep_0078(base.base_plugin):
query.append(username)
query.append(resource)
if rquery.find('{jabber:iq:auth}digest') is None:
- logging.warning("Authenticating via jabber:iq:auth Plain.")
+ log.warning("Authenticating via jabber:iq:auth Plain.")
password = ET.Element('password')
password.text = self.xmpp.password
query.append(password)
else:
- logging.debug("Authenticating via jabber:iq:auth Digest")
+ log.debug("Authenticating via jabber:iq:auth Digest")
digest = ET.Element('digest')
digest.text = hashlib.sha1(b"%s%s" % (self.streamid, self.xmpp.password)).hexdigest()
query.append(digest)
@@ -64,6 +67,6 @@ class xep_0078(base.base_plugin):
self.xmpp.sessionstarted = True
self.xmpp.event("session_start")
else:
- logging.info("Authentication failed")
+ log.info("Authentication failed")
self.xmpp.disconnect()
self.xmpp.event("failed_auth")