mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
allow for creation of domain-server keypair in AccountManager
This commit is contained in:
parent
75429e39bc
commit
af181e00b1
4 changed files with 35 additions and 9 deletions
|
@ -526,6 +526,8 @@ void DomainServer::setupICEHeartbeatForFullNetworking() {
|
|||
// we need this DS to know what our public IP is - start trying to figure that out now
|
||||
limitedNodeList->startSTUNPublicSocketUpdate();
|
||||
|
||||
// to send ICE heartbeats we'd better have a private key locally with an uploaded public key
|
||||
|
||||
if (!_iceHeartbeatTimer) {
|
||||
// setup a timer to heartbeat with the ice-server every so often
|
||||
_iceHeartbeatTimer = new QTimer { this };
|
||||
|
|
|
@ -82,7 +82,7 @@ AccountManager::AccountManager() :
|
|||
connect(&_accountInfo, &DataServerAccountInfo::balanceChanged, this, &AccountManager::accountInfoBalanceChanged);
|
||||
|
||||
// once we have a profile in account manager make sure we generate a new keypair
|
||||
connect(this, &AccountManager::profileChanged, this, &AccountManager::generateNewKeypair);
|
||||
connect(this, &AccountManager::profileChanged, this, &AccountManager::generateNewUserKeypair);
|
||||
}
|
||||
|
||||
const QString DOUBLE_SLASH_SUBSTITUTE = "slashslash";
|
||||
|
@ -482,23 +482,32 @@ void AccountManager::requestProfileError(QNetworkReply::NetworkError error) {
|
|||
qCDebug(networking) << "AccountManager requestProfileError - " << error;
|
||||
}
|
||||
|
||||
void AccountManager::generateNewKeypair() {
|
||||
void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainID) {
|
||||
if (!isUserKeypair && domainID.isNull()) {
|
||||
qWarning() << "AccountManager::generateNewKeypair called for domain keypair with no domain ID. Will not generate keypair.";
|
||||
return;
|
||||
}
|
||||
|
||||
// setup a new QThread to generate the keypair on, in case it takes a while
|
||||
QThread* generateThread = new QThread(this);
|
||||
generateThread->setObjectName("Account Manager Generator Thread");
|
||||
|
||||
|
||||
// setup a keypair generator
|
||||
RSAKeypairGenerator* keypairGenerator = new RSAKeypairGenerator();
|
||||
|
||||
|
||||
if (!isUserKeypair) {
|
||||
keypairGenerator->setDomainID(domainID);
|
||||
}
|
||||
|
||||
connect(generateThread, &QThread::started, keypairGenerator, &RSAKeypairGenerator::generateKeypair);
|
||||
connect(keypairGenerator, &RSAKeypairGenerator::generatedKeypair, this, &AccountManager::processGeneratedKeypair);
|
||||
connect(keypairGenerator, &RSAKeypairGenerator::errorGeneratingKeypair,
|
||||
this, &AccountManager::handleKeypairGenerationError);
|
||||
connect(keypairGenerator, &QObject::destroyed, generateThread, &QThread::quit);
|
||||
connect(generateThread, &QThread::finished, generateThread, &QThread::deleteLater);
|
||||
|
||||
|
||||
keypairGenerator->moveToThread(generateThread);
|
||||
|
||||
|
||||
qCDebug(networking) << "Starting worker thread to generate 2048-bit RSA key-pair.";
|
||||
generateThread->start();
|
||||
}
|
||||
|
|
|
@ -87,7 +87,9 @@ public slots:
|
|||
void logout();
|
||||
void updateBalance();
|
||||
void accountInfoBalanceChanged(qint64 newBalance);
|
||||
void generateNewKeypair();
|
||||
void generateNewUserKeypair() { generateNewKeypair(); }
|
||||
void generateNewDomainKeypair(const QUuid& domainID) { generateNewKeypair(false, domainID); }
|
||||
|
||||
signals:
|
||||
void authRequired();
|
||||
void authEndpointChanged();
|
||||
|
@ -97,10 +99,12 @@ signals:
|
|||
void loginFailed();
|
||||
void logoutComplete();
|
||||
void balanceChanged(qint64 newBalance);
|
||||
|
||||
private slots:
|
||||
void processReply();
|
||||
void handleKeypairGenerationError();
|
||||
void processGeneratedKeypair(const QByteArray& publicKey, const QByteArray& privateKey);
|
||||
|
||||
private:
|
||||
AccountManager();
|
||||
AccountManager(AccountManager const& other); // not implemented
|
||||
|
@ -111,6 +115,8 @@ private:
|
|||
void passSuccessToCallback(QNetworkReply* reply);
|
||||
void passErrorToCallback(QNetworkReply* reply);
|
||||
|
||||
void generateNewKeypair(bool isUserKeypair = true, const QUuid& domainID = QUuid());
|
||||
|
||||
QUrl _authURL;
|
||||
QMap<QNetworkReply*, JSONCallbackParameters> _pendingCallbackMap;
|
||||
|
||||
|
|
|
@ -12,17 +12,26 @@
|
|||
#ifndef hifi_RSAKeypairGenerator_h
|
||||
#define hifi_RSAKeypairGenerator_h
|
||||
|
||||
#include <qobject.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
class RSAKeypairGenerator : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RSAKeypairGenerator(QObject* parent = 0);
|
||||
|
||||
void setDomainID(const QUuid& domainID) { _domainID = domainID; }
|
||||
const QUuid& getDomainID() const { return _domainID; }
|
||||
|
||||
public slots:
|
||||
void generateKeypair();
|
||||
|
||||
signals:
|
||||
void errorGeneratingKeypair();
|
||||
void generatedKeypair(const QByteArray& publicKey, const QByteArray& privateKey);
|
||||
|
||||
private:
|
||||
QUuid _domainID;
|
||||
};
|
||||
|
||||
#endif // hifi_RSAKeypairGenerator_h
|
||||
#endif // hifi_RSAKeypairGenerator_h
|
||||
|
|
Loading…
Reference in a new issue