File indexing completed on 2023-09-24 05:08:01
0001 /* 0002 * Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/> 0003 * @author Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk> 0004 * Copyright (C) 2011 David Edmundson <kde@davidedmundson.co.uk> 0005 * Copyright (C) 2013 Dan Vrátil <dvratil@redhat.com> 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Lesser General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2.1 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library; if not, write to the Free Software 0019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0020 */ 0021 0022 #ifndef TLSCERTVERIFIEROP_H 0023 #define TLSCERTVERIFIEROP_H 0024 0025 #include <TelepathyQt/Account> 0026 #include <TelepathyQt/AuthenticationTLSCertificateInterface> 0027 #include <TelepathyQt/Channel> 0028 #include <TelepathyQt/Connection> 0029 #include <TelepathyQt/PendingOperation> 0030 #include <TelepathyQt/Types> 0031 0032 // FIXME: Move this to tp-qt4 itself 0033 #include "types.h" 0034 0035 #include <QtCrypto> 0036 #include <ktcpsocket.h> 0037 0038 class QSslCertificate; 0039 class TlsCertVerifierOp : public Tp::PendingOperation 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 TlsCertVerifierOp(const Tp::AccountPtr &account, 0045 const Tp::ConnectionPtr &connection, 0046 const Tp::ChannelPtr &channel); 0047 ~TlsCertVerifierOp(); 0048 0049 Q_SIGNALS: 0050 void ready(Tp::PendingOperation *self); 0051 0052 private Q_SLOTS: 0053 void gotProperties(Tp::PendingOperation *op); 0054 0055 private: 0056 bool verifyCertChain(const QCA::CertificateChain &chain); 0057 void showSslDialog(const QCA::CertificateChain &chain, const QList<KSslError> &errors) const; 0058 KSslError::Error validityToError(QCA::Validity validity) const; 0059 0060 QCA::CertificateCollection CACollection() const; 0061 QList<QSslCertificate> chainToList(const QCA::CertificateChain &chain) const; 0062 0063 Tp::AccountPtr m_account; 0064 Tp::ConnectionPtr m_connection; 0065 Tp::ChannelPtr m_channel; 0066 QString m_hostname; 0067 QStringList m_referenceIdentities; 0068 Tp::Client::AuthenticationTLSCertificateInterface *m_authTLSCertificateIface; 0069 QString m_certType; 0070 CertificateDataList m_certData; 0071 }; 0072 0073 #endif