Package spade :: Package xmppd :: Package modules :: Module stream :: Class SASL
[hide private]
[frames] | no frames]

Class SASL

source code


Instance Methods [hide private]
 
plugin(self, server) source code
 
commit_auth(self, session, authzid) source code
 
reject_auth(self, session, authzid='unknown') source code
 
SASLHandler(self, session, stanza)
simple username: servername _or_ node@servername : 6.1 (6)
source code

Inherited from xmpp.client.PlugIn: DEBUG, PlugIn, PlugOut, __init__

Class Variables [hide private]
  NS = 'urn:ietf:params:xml:ns:xmpp-sasl'
<features/>
Instance Variables [hide private]
  mechanisms
def startauth(self,session,username,password): session.username=username session.password=password if session.Stream.features: try: self.FeaturesHandler(session,session.Stream.features) except NodeProcessed: pass
Instance Variable Details [hide private]

mechanisms

def startauth(self,session,username,password):
    session.username=username
    session.password=password
    if session.Stream.features:
        try: self.FeaturesHandler(session,session.Stream.features)
        except NodeProcessed: pass

def FeaturesHandler(self,session,feats):
    if session.feature_in_process: return     # some other feature is already underway
    if not session.__dict__.has_key('username'): return
    if not feats.getTag('mechanisms',namespace=NS_SASL):
        session.unfeature(NS_SASL)
        self.DEBUG('SASL not supported by server','error')
        return
    mecs=[]
    for mec in feats.getTag('mechanisms',namespace=NS_SASL).getTags('mechanism'):
        mecs.append(mec.getData())
    if "DIGEST-MD5" in mecs:
        node=Node('auth',attrs={'xmlns':NS_SASL,'mechanism':'DIGEST-MD5'})
    elif "PLAIN" in mecs:
        sasl_data='%s%s%s'%(self.username+'@'+session.peer,self.username,self.password)
        node=Node('auth',attrs={'xmlns':NS_SASL,'mechanism':'PLAIN'},payload=[base64.encodestring(sasl_data)])
    else:
        session.startsasl='failure'
        self.DEBUG('I can only use DIGEST-MD5 and PLAIN mecanisms.','error')
        return
    session.startsasl='in-process'
    session.send(node)
    raise NodeProcessed