use realm from first challenge response

This commit is contained in:
Dimitur Kirov 2006-04-08 15:58:50 +00:00
parent 6556d01cbe
commit 2fa30b7e1e
1 changed files with 21 additions and 14 deletions

View File

@ -30,7 +30,7 @@ class SASL(PlugIn):
self.username=username
self.password=password
self.on_sasl = on_sasl
self.realm = None
def plugin(self,owner):
if not self._owner.Dispatcher.Stream._document_attrs.has_key('version'):
self.startsasl='not-supported'
@ -123,9 +123,14 @@ class SASL(PlugIn):
if value[:1] == '"' and value[-1:] == '"':
value = value[1:-1]
chal[key] = value
if not self.realm and chal.has_key('realm'):
self.realm = chal['realm']
if chal.has_key('qop') and chal['qop']=='auth':
resp={}
resp['username'] = self.username
if self.realm:
resp['realm'] = self.realm
else:
resp['realm'] = self._owner.Server
resp['nonce']=chal['nonce']
cnonce=''
@ -135,9 +140,11 @@ class SASL(PlugIn):
resp['nc'] = ('00000001')
resp['qop'] = 'auth'
resp['digest-uri'] = 'xmpp/'+self._owner.Server
A1=C([H(C([resp['username'], resp['realm'], self.password])), resp['nonce'], resp['cnonce']])
A1=C([H(C([resp['username'], resp['realm'], self.password])),
resp['nonce'], resp['cnonce']])
A2=C(['AUTHENTICATE',resp['digest-uri']])
response= HH(C([HH(A1),resp['nonce'],resp['nc'],resp['cnonce'],resp['qop'],HH(A2)]))
response= HH(C([HH(A1), resp['nonce'], resp['nc'], resp['cnonce'],
resp['qop'], HH(A2)]))
resp['response'] = response
resp['charset'] = 'utf-8'
sasl_data=''