mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-13 15:46:01 +03:00
[cse] Start the job to sign the public key.
This commit is contained in:
parent
ecb05020a9
commit
304231811d
2 changed files with 73 additions and 0 deletions
|
@ -49,6 +49,7 @@ Q_LOGGING_CATEGORY(lcMkColJob, "sync.networkjob.mkcol", QtInfoMsg)
|
|||
Q_LOGGING_CATEGORY(lcProppatchJob, "sync.networkjob.proppatch", QtInfoMsg)
|
||||
Q_LOGGING_CATEGORY(lcJsonApiJob, "sync.networkjob.jsonapi", QtInfoMsg)
|
||||
Q_LOGGING_CATEGORY(lcDetermineAuthTypeJob, "sync.networkjob.determineauthtype", QtInfoMsg)
|
||||
Q_LOGGING_CATEGORY(lcSignPublicKeyApiJob, "sync.networkjob.sendcsr", QtInfoMsg);
|
||||
|
||||
RequestEtagJob::RequestEtagJob(AccountPtr account, const QString &path, QObject *parent)
|
||||
: AbstractNetworkJob(account, path, parent)
|
||||
|
@ -941,4 +942,30 @@ bool DeleteApiJob::finished()
|
|||
const auto replyData = QString::fromUtf8(reply()->readAll());
|
||||
qCInfo(lcJsonApiJob()) << "TMX Delete Job" << replyData;
|
||||
}
|
||||
|
||||
SignPublicKeyApiJob::SignPublicKeyApiJob(const AccountPtr& account, const QString& path, QObject* parent)
|
||||
: AbstractNetworkJob(account, path, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void SignPublicKeyApiJob::setCsr(const QByteArray& csr)
|
||||
{
|
||||
_csr.setData(csr);
|
||||
}
|
||||
|
||||
void SignPublicKeyApiJob::start()
|
||||
{
|
||||
QNetworkRequest req;
|
||||
req.setRawHeader("OCS-APIREQUEST", "true");
|
||||
QUrl url = Utility::concatUrlPath(account()->url(), path());
|
||||
sendRequest("POST", url, req, &_csr);
|
||||
AbstractNetworkJob::start();
|
||||
}
|
||||
|
||||
bool SignPublicKeyApiJob::finished()
|
||||
{
|
||||
qCInfo(lcSignPublicKeyApiJob()) << "Sending CSR ended with" << path() << errorString() << reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
||||
qCInfo(lcSignPublicKeyApiJob()) << reply()->readAll();
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "abstractnetworkjob.h"
|
||||
|
||||
#include <QBuffer>
|
||||
|
||||
class QUrl;
|
||||
class QJsonObject;
|
||||
|
||||
|
@ -427,6 +429,50 @@ private slots:
|
|||
bool finished() Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
/*
|
||||
* @brief Job to sigh the CSR that return JSON
|
||||
*
|
||||
* To be used like this:
|
||||
* \code
|
||||
* _job = new SignPublicKeyApiJob(account, QLatin1String("ocs/v1.php/foo/bar"), this);
|
||||
* _job->setCsr( csr );
|
||||
* connect(_job...);
|
||||
* _job->start();
|
||||
* \encode
|
||||
*
|
||||
* @ingroup libsync
|
||||
*/
|
||||
class OWNCLOUDSYNC_EXPORT SignPublicKeyApiJob : public AbstractNetworkJob
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SignPublicKeyApiJob(const AccountPtr &account, const QString &path, QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* @brief setCsr - the CSR with the public key.
|
||||
* This function needs to be called before start() obviously.
|
||||
*/
|
||||
void setCsr(const QByteArray& csr);
|
||||
|
||||
public slots:
|
||||
void start() override;
|
||||
|
||||
protected:
|
||||
bool finished() override;
|
||||
signals:
|
||||
|
||||
/**
|
||||
* @brief jsonReceived - signal to report the json answer from ocs
|
||||
* @param json - the parsed json document
|
||||
* @param statusCode - the OCS status code: 100 (!) for success
|
||||
*/
|
||||
void jsonReceived(const QJsonDocument &json, int statusCode);
|
||||
|
||||
private:
|
||||
QBuffer _csr;
|
||||
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
#endif // NETWORKJOBS_H
|
||||
|
|
Loading…
Reference in a new issue