1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "coreidentity.h"
23 #include "signalproxy.h"
25 CoreIdentity::CoreIdentity(IdentityId id, QObject *parent)
26 : Identity(id, parent)
32 connect(this, SIGNAL(idSet(IdentityId)), &_certManager, SLOT(setId(IdentityId)));
33 connect(&_certManager, SIGNAL(updated()), this, SIGNAL(updated()));
38 CoreIdentity::CoreIdentity(const Identity &other, QObject *parent)
39 : Identity(other, parent)
45 connect(this, SIGNAL(idSet(IdentityId)), &_certManager, SLOT(setId(IdentityId)));
46 connect(&_certManager, SIGNAL(updated()), this, SIGNAL(updated()));
51 CoreIdentity::CoreIdentity(const CoreIdentity &other, QObject *parent)
52 : Identity(other, parent)
54 , _sslKey(other._sslKey),
55 _sslCert(other._sslCert),
60 connect(this, SIGNAL(idSet(IdentityId)), &_certManager, SLOT(setId(IdentityId)));
61 connect(&_certManager, SIGNAL(updated()), this, SIGNAL(updated()));
66 void CoreIdentity::synchronize(SignalProxy *proxy)
68 proxy->synchronize(this);
70 proxy->synchronize(&_certManager);
76 void CoreIdentity::setSslKey(const QByteArray &encoded)
78 QSslKey key(encoded, QSsl::Rsa);
80 key = QSslKey(encoded, QSsl::Ec);
82 key = QSslKey(encoded, QSsl::Dsa);
87 void CoreIdentity::setSslCert(const QByteArray &encoded)
89 setSslCert(QSslCertificate(encoded));
95 CoreIdentity &CoreIdentity::operator=(const CoreIdentity &identity)
97 Identity::operator=(identity);
99 _sslKey = identity._sslKey;
100 _sslCert = identity._sslCert;
107 // ========================================
109 // ========================================
111 CoreCertManager::CoreCertManager(CoreIdentity &identity)
112 : CertManager(identity.id()),
115 setAllowClientUpdates(true);
119 void CoreCertManager::setId(IdentityId id)
121 renameObject(QString::number(id.toInt()));
125 void CoreCertManager::setSslKey(const QByteArray &encoded)
127 identity.setSslKey(encoded);
128 CertManager::setSslKey(encoded);
132 void CoreCertManager::setSslCert(const QByteArray &encoded)
134 identity.setSslCert(encoded);
135 CertManager::setSslCert(encoded);