SASL auth is back, ths Alexey
This commit is contained in:
parent
7c303ddcc3
commit
92b1c8226c
|
@ -96,20 +96,24 @@ class NonSASL(PlugIn):
|
|||
|
||||
class SASL(PlugIn):
|
||||
""" Implements SASL authentication. """
|
||||
def __init__(self,username,password):
|
||||
PlugIn.__init__(self)
|
||||
self.username=username
|
||||
self.password=password
|
||||
|
||||
def plugin(self,owner):
|
||||
if not self._owner.Dispatcher.Stream._document_attrs.has_key('version'): self.startsasl='not-supported'
|
||||
elif self._owner.Dispatcher.Stream.features:
|
||||
try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features)
|
||||
except NodeProcessed: pass
|
||||
elif self._owner.Dispatcher.Stream.features:
|
||||
try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features)
|
||||
except NodeProcessed: pass
|
||||
else: self.startsasl=None
|
||||
|
||||
def auth(self,username,password):
|
||||
def auth(self):
|
||||
""" Start authentication. Result can be obtained via "SASL.startsasl" attribute and will be
|
||||
either "success" or "failure". Note that successfull auth will take at least
|
||||
two Dispatcher.Process() calls. """
|
||||
self.username=username
|
||||
self.password=password
|
||||
if self._owner.Dispatcher.Stream.features:
|
||||
if self.startsasl: pass
|
||||
elif self._owner.Dispatcher.Stream.features:
|
||||
try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features)
|
||||
except NodeProcessed: pass
|
||||
else: self._owner.RegisterHandler('features',self.FeaturesHandler,xmlns=NS_STREAMS)
|
||||
|
|
|
@ -189,14 +189,14 @@ class Client(CommonClient):
|
|||
while not self.Dispatcher.Stream._document_attrs and self.Process(): pass
|
||||
if self.Dispatcher.Stream._document_attrs.has_key('version') and self.Dispatcher.Stream._document_attrs['version']=='1.0':
|
||||
while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented
|
||||
if sasl: auth.SASL().PlugIn(self)
|
||||
if sasl: auth.SASL(user,password).PlugIn(self)
|
||||
if not sasl or self.SASL.startsasl=='not-supported':
|
||||
if not resource: resource='xmpppy'
|
||||
if auth.NonSASL(user,password,resource).PlugIn(self):
|
||||
self.connected+='+old_auth'
|
||||
return 'old_auth'
|
||||
return
|
||||
self.SASL.auth(user,password)
|
||||
self.SASL.auth()
|
||||
while self.SASL.startsasl=='in-process' and self.Process(): pass
|
||||
if self.SASL.startsasl=='success':
|
||||
auth.Bind().PlugIn(self)
|
||||
|
|
Loading…
Reference in New Issue