Correct handling SASL auth failures when forcing the use of a specific mechanism.

This commit is contained in:
Lance Stout 2012-03-13 11:07:14 -07:00
parent 7284ceb90c
commit 1b00b7e8df

View file

@ -105,14 +105,17 @@ class FeatureMechanisms(BasePlugin):
# server has incorrectly offered it again. # server has incorrectly offered it again.
return False return False
self.mech_list = set(features['mechanisms']) if not self.use_mech:
self.mech_list = set(features['mechanisms'])
else:
self.mech_list = set([self.use_mech])
return self._send_auth() return self._send_auth()
def _send_auth(self): def _send_auth(self):
mech_list = self.mech_list - self.attempted_mechs mech_list = self.mech_list - self.attempted_mechs
self.mech = self.sasl.choose_mechanism(mech_list) self.mech = self.sasl.choose_mechanism(mech_list)
if self.mech is not None: if mech_list and self.mech is not None:
resp = stanza.Auth(self.xmpp) resp = stanza.Auth(self.xmpp)
resp['mechanism'] = self.mech.name resp['mechanism'] = self.mech.name
try: try: