Пример #1
0
    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())
Пример #2
0
    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())
Пример #3
0
    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())
Пример #4
0
    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!")
Пример #5
0
    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!")
Пример #6
0
	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())
Пример #7
0
 def onResponse(self, element):
     response = sasl.fromBase64(str(element))
     deferred = self.mechanism.parseResponse(response)
     deferred.addCallbacks(self.onSuccess, self.onFailure)
Пример #8
0
 def onResponse(self, element):
     response = sasl.fromBase64(str(element))
     deferred = self.mechanism.parseResponse(response)
     deferred.addCallbacks(self.onSucces, self.onFailure)