'Used to determine if server supports SASL auth. Used internally.'

def FeaturesHandler(self, conn, feats):

    if (not feats.getTag('mechanisms', namespace=NS_SASL)):
        self.startsasl = 'not-supported'
        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())
    self._owner.RegisterHandler('challenge', self.SASLHandler, xmlns=NS_SASL)
    self._owner.RegisterHandler('failure', self.SASLHandler, xmlns=NS_SASL)
    self._owner.RegisterHandler('success', self.SASLHandler, xmlns=NS_SASL)
    if (('ANONYMOUS' in mecs) and (self.username == None)):
        node = Node('auth', attrs={'xmlns': NS_SASL, 'mechanism': 'ANONYMOUS'})
    elif ('DIGEST-MD5' in mecs):
        node = Node('auth', attrs={'xmlns': NS_SASL, 'mechanism': 'DIGEST-MD5'})
    elif ('PLAIN' in mecs):
        sasl_data = ('%s\x00%s\x00%s' % (((self.username + '@') + self._owner.Server), self.username, self.password))
        node = Node('auth', attrs={'xmlns': NS_SASL, 'mechanism': 'PLAIN'}, payload=[base64.encodestring(sasl_data).replace('\r', '').replace('\n', '')])
    else:
        self.startsasl = 'failure'
        self.DEBUG('I    can    only    use    DIGEST-MD5    and    PLAIN    mecanisms.', 'error')
        return
    self.startsasl = 'in-process'
    self._owner.send(node.__str__())
    raise NodeProcessed
