Esempio n. 1
0
    def feature(self):
        self.external = hasattr(self.xmlstream.transport, 'getPeerCertificate') or tls.isTLS(self.xmlstream)

        feature = domish.Element((sasl.NS_XMPP_SASL, 'mechanisms'), defaultUri=sasl.NS_XMPP_SASL)
        if self.external:
            feature.addElement('mechanism', content='EXTERNAL')

        feature.addElement('mechanism', content='KONTALK-TOKEN')
        feature.addElement('mechanism', content='PLAIN')
        return feature
Esempio n. 2
0
    def feature(self):
        self.external = tls.isTLS(self.xmlstream)

        feature = domish.Element((sasl.NS_XMPP_SASL, 'mechanisms'), defaultUri=sasl.NS_XMPP_SASL)
        if self.external:
            feature.addElement('mechanism', content='EXTERNAL')

        feature.addElement('mechanism', content='KONTALK-TOKEN')
        feature.addElement('mechanism', content='PLAIN')
        return feature
Esempio n. 3
0
    def feature(self):
        if self.xmlstream.factory.getSSLContext() is None:
            log.warn("TLS not supported")
            return None

        if not tls.isTLS(self.xmlstream):
            feature = domish.Element((xmlstream.NS_XMPP_TLS, 'starttls'), defaultUri=xmlstream.NS_XMPP_TLS)
            if self.required:
                feature.addElement((xmlstream.NS_XMPP_TLS, 'required'))
            return feature

        return None
Esempio n. 4
0
    def feature(self):
        self.external = hasattr(self.xmlstream.transport,
                                'getPeerCertificate') or tls.isTLS(
                                    self.xmlstream)

        feature = domish.Element((sasl.NS_XMPP_SASL, 'mechanisms'),
                                 defaultUri=sasl.NS_XMPP_SASL)
        if self.external:
            feature.addElement('mechanism', content='EXTERNAL')

        feature.addElement('mechanism', content='KONTALK-TOKEN')
        feature.addElement('mechanism', content='PLAIN')
        return feature
Esempio n. 5
0
    def onStartTLS(self, element):
        # TLS not supported or already negotiated
        if self.xmlstream.factory.getSSLContext() is None or tls.isTLS(self.xmlstream):
            failure = domish.Element((sasl.NS_XMPP_SASL, 'failure'), defaultUri=xmlstream.NS_XMPP_TLS)
            self.xmlstream.send(failure)
            self.xmlstream.sendFooter()
            self.xmlstream.transport.loseConnection()

        elif self.canInitialize(self):
            self.xmlstream.dispatch(self, INIT_SUCCESS_EVENT)
            self.xmlstream.send(domish.Element((xmlstream.NS_XMPP_TLS, 'proceed')))
            self.xmlstream.transport.startTLS(self.xmlstream.factory.getSSLContext())
            self.xmlstream.reset()