From f8c89d07906fcef2bace34a94931f02dfe562788 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 14 Oct 2014 13:51:41 -0700 Subject: [PATCH] upload the generated public key to data-web, add getter for private key --- libraries/networking/src/AccountManager.cpp | 17 +++++++++++++++++ .../networking/src/DataServerAccountInfo.h | 1 + libraries/networking/src/LimitedNodeList.cpp | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index a8b88133d6..4d23bf5d39 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -509,6 +509,23 @@ void AccountManager::processGeneratedKeypair(const QByteArray& publicKey, const // set the private key on our data-server account info _accountInfo.setPrivateKey(privateKey); + // upload the public key so data-web has an up-to-date key + const QString PUBLIC_KEY_UPDATE_PATH = "api/v1/user/public_key"; + + // setup a multipart upload to send up the public key + QHttpMultiPart* requestMultiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); + + QHttpPart keyPart; + keyPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream")); + keyPart.setHeader(QNetworkRequest::ContentDispositionHeader, + QVariant("form-data; name=\"public_key\"; filename=\"public_key\"")); + keyPart.setBody(publicKey); + + requestMultiPart->append(keyPart); + + authenticatedRequest(PUBLIC_KEY_UPDATE_PATH, QNetworkAccessManager::PutOperation, + JSONCallbackParameters(), QByteArray(), requestMultiPart); + // get rid of the keypair generator now that we don't need it anymore sender()->deleteLater(); } diff --git a/libraries/networking/src/DataServerAccountInfo.h b/libraries/networking/src/DataServerAccountInfo.h index 8dc321bb02..14419b929c 100644 --- a/libraries/networking/src/DataServerAccountInfo.h +++ b/libraries/networking/src/DataServerAccountInfo.h @@ -42,6 +42,7 @@ public: const QUuid& getWalletID() const { return _walletID; } void setWalletID(const QUuid& walletID); + const QByteArray& getPrivateKey() const { return _privateKey; } void setPrivateKey(const QByteArray& privateKey) { _privateKey = privateKey; } qint64 getBalance() const { return _balance; } diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 919dc75c23..c33b20a8e7 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -33,7 +33,7 @@ const char SOLO_NODE_TYPES[2] = { NodeType::AudioMixer }; -const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://data.highfidelity.io"); +const QUrl DEFAULT_NODE_AUTH_URL = QUrl("http://data.highfidelity.io"); std::auto_ptr LimitedNodeList::_sharedInstance;