def onAuth(self, element): if not self.canInitialize(self): return mechanism = element.getAttribute('mechanism') if self.external and mechanism == 'EXTERNAL': self.mechanism = ExternalMechanism(self.xmlstream.portal, self.xmlstream.transport.getPeerCertificate()) elif mechanism == 'KONTALK-TOKEN': self.mechanism = KontalkTokenMechanism(self.xmlstream.portal) elif mechanism == 'PLAIN': self.mechanism = PlainMechanism(self.xmlstream.portal) else: self._sendFailure('invalid-mechanism') return response = str(element) # HACK this a workaround for naughty clients if mechanism == 'EXTERNAL' and not response: response = '=' if response: # TODO base64 might fail - UNHANDLED ERROR deferred = self.mechanism.parseInitialResponse(sasl.fromBase64(response)) deferred.addCallbacks(self.onSuccess, self.onFailure) else: self._sendChallenge(self.mechanism.getInitialChallenge())
def onAuth(self, element): if not self.canInitialize(self): return mechanism = element.getAttribute('mechanism') if mechanism == 'PLAIN': self.mechanism = Plain(self.xmlstream.portal) elif mechanism == 'DIGEST-MD5': self.mechanism = DigestMD5('xmpp', 'localhost', None, portal=self.xmlstream.portal ) #TODO: Make serv_type configurable else: self._sendFailure('invalid-mechanism') return response = str(element) if response: deferred = self.mechanism.parseInitialResponse( sasl.fromBase64(response)) deferred.addCallbacks(self.onSucces, self.onFailure) else: self._sendChallenge(self.mechanism.getInitialChallenge())
def onAuth(self, element): if not self.canInitialize(self): return mechanism = element.getAttribute('mechanism') if self.external and mechanism == 'EXTERNAL': self.mechanism = ExternalMechanism( self.xmlstream.portal, self.xmlstream.transport.getPeerCertificate()) elif mechanism == 'KONTALK-TOKEN': self.mechanism = KontalkTokenMechanism(self.xmlstream.portal) elif mechanism == 'PLAIN': self.mechanism = PlainMechanism(self.xmlstream.portal) else: self._sendFailure('invalid-mechanism') return response = str(element) # HACK this a workaround for naughty clients if mechanism == 'EXTERNAL' and not response: response = '=' if response: # TODO base64 might fail - UNHANDLED ERROR deferred = self.mechanism.parseInitialResponse( sasl.fromBase64(response)) deferred.addCallbacks(self.onSuccess, self.onFailure) else: self._sendChallenge(self.mechanism.getInitialChallenge())
def check(self, fingerprint, kr, verify_cb): try: if self.decode_b64: data = sasl.fromBase64(self.token) else: data = self.token return kr.check_token(data) except: # TODO logging or throw exception back import traceback traceback.print_exc() log.debug("token verification failed!")
def onAuth(self, element): if not self.canInitialize(self): return mechanism = element.getAttribute('mechanism') if mechanism == 'PLAIN': self.mechanism = Plain(self.xmlstream.portal) elif mechanism == 'DIGEST-MD5': self.mechanism = DigestMD5('xmpp', 'localhost', None, portal=self.xmlstream.portal) #TODO: Make serv_type configurable else: self._sendFailure('invalid-mechanism') return response = str(element) if response: deferred = self.mechanism.parseInitialResponse(sasl.fromBase64(response)) deferred.addCallbacks(self.onSucces, self.onFailure) else: self._sendChallenge(self.mechanism.getInitialChallenge())
def onResponse(self, element): response = sasl.fromBase64(str(element)) deferred = self.mechanism.parseResponse(response) deferred.addCallbacks(self.onSuccess, self.onFailure)
def onResponse(self, element): response = sasl.fromBase64(str(element)) deferred = self.mechanism.parseResponse(response) deferred.addCallbacks(self.onSucces, self.onFailure)