Esempio n. 1
0
    def check(self, fingerprint, kr, verify_cb):
        _jid = None

        if isinstance(self.cert, OpenPGPCertificate):
            uid = self.cert.uid(0)
            _jid = jid.JID(uid.email)
            fpr = self.cert.fingerprint

        elif isinstance(self.cert, X509):
            if keyring.verify_certificate(self.cert):
                keydata = keyring.get_pgp_publickey_extension(self.cert)
                if keydata:
                    pkey = OpenPGPCertificate(keydata)
                    if pkey:
                        uid = pkey.uid(0)
                        if uid:
                            _jid = jid.JID(uid.email)
                            fpr = kr.check_user_key(keydata, _jid.user)
                            if not fpr:
                                _jid = None

        if _jid:
            def _continue(userjid):
                return userjid
            def _error(reason):
                return None

            # deferred to check fingerprint against resolver data
            d = verify_cb(_jid, fpr)
            d.addCallback(_continue)
            d.addErrback(_error)
            return d

        return None
Esempio n. 2
0
    def check(self, fingerprint, kr, verify_cb=None):
        _jid = None

        if isinstance(self.cert, OpenPGPCertificate):
            uid = self.cert.uid(0)
            _jid = jid.JID(uid.email)
            fpr = self.cert.fingerprint

        elif isinstance(self.cert, X509):
            if keyring.verify_certificate(self.cert):
                keydata = keyring.get_pgp_publickey_extension(self.cert)
                if keydata:
                    pkey = OpenPGPCertificate(keydata)
                    if pkey:
                        uid = pkey.uid(0)
                        if uid:
                            _jid = jid.JID(uid.email)
                            fpr = kr.check_user_key(keydata, _jid.user)
                            if not fpr:
                                _jid = None

        if _jid:

            def _continue(userjid):
                return userjid

            def _error(reason):
                return None

            # deferred to check fingerprint against JID cache data
            if verify_cb:
                d = verify_cb(_jid, fpr)
                d.addCallback(_continue)
                d.addErrback(_error)
                return d
            else:
                return _jid

        return None
Esempio n. 3
0
    def check(self, fingerprint, kr, verify_cb=None):
        _jid = None
        fpr = None

        if isinstance(self.cert, OpenPGPCertificate):
            uid = self.cert.uid(0)
            _jid = jid.JID(uid.email)
            fpr = self.cert.fingerprint

        elif isinstance(self.cert, X509):
            fpr = keyring.verify_certificate(self.cert, kr)
            if fpr:
                pkey = kr.get_key(fpr)
                uid = pkey.uids[0]
                if uid:
                    _jid = jid.JID(uid.email)
                    fpr = kr.check_user_key(pkey, _jid.user)
                    if not fpr:
                        _jid = None

        if _jid:
            def _continue(userjid):
                return userjid
            def _error(reason):
                return None

            # deferred to check fingerprint against JID cache data
            if verify_cb:
                d = verify_cb(_jid, fpr)
                d.addCallback(_continue)
                d.addErrback(_error)
                return d
            else:
                return _jid

        return None