mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 15:05:19 +03:00
[cse] Start to fetch the basics to fetch the key from the server
This commit is contained in:
parent
3f4d915a17
commit
29b64640fa
6 changed files with 73 additions and 4 deletions
|
@ -19,7 +19,9 @@
|
|||
#include "creds/abstractcredentials.h"
|
||||
#include "capabilities.h"
|
||||
#include "theme.h"
|
||||
|
||||
#include "common/asserts.h"
|
||||
#include "clientsideencryption.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QNetworkReply>
|
||||
|
@ -39,6 +41,7 @@ Q_LOGGING_CATEGORY(lcAccount, "sync.account", QtInfoMsg)
|
|||
Account::Account(QObject *parent)
|
||||
: QObject(parent)
|
||||
, _capabilities(QVariantMap())
|
||||
, _encryption(new ClientSideEncryption(this))
|
||||
, _davPath(Theme::instance()->webDavPath())
|
||||
{
|
||||
qRegisterMetaType<AccountPtr>("AccountPtr");
|
||||
|
@ -482,4 +485,9 @@ void Account::setNonShib(bool nonShib)
|
|||
}
|
||||
}
|
||||
|
||||
ClientSideEncryption *Account::cse() const
|
||||
{
|
||||
return _encryption;
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "common/utility.h"
|
||||
#include <memory>
|
||||
#include "capabilities.h"
|
||||
#include "clientsideencryption.h"
|
||||
|
||||
class QSettings;
|
||||
class QNetworkReply;
|
||||
|
@ -225,6 +226,7 @@ public:
|
|||
/// Called by network jobs on credential errors, emits invalidCredentials()
|
||||
void handleInvalidCredentials();
|
||||
|
||||
ClientSideEncryption *cse() const;
|
||||
public slots:
|
||||
/// Used when forgetting credentials
|
||||
void clearQNAMCache();
|
||||
|
@ -274,6 +276,7 @@ private:
|
|||
QuotaInfo *_quotaInfo;
|
||||
QSharedPointer<QNetworkAccessManager> _am;
|
||||
QScopedPointer<AbstractCredentials> _credentials;
|
||||
ClientSideEncryption *_encryption;
|
||||
bool _http2Supported = false;
|
||||
|
||||
/// Certificates that were explicitly rejected by the user
|
||||
|
|
|
@ -1,4 +1,34 @@
|
|||
#include "clientsideencryption.h"
|
||||
#include "account.h"
|
||||
#include "capabilities.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
namespace OCC
|
||||
{
|
||||
|
||||
Q_LOGGING_CATEGORY(lcCse, "sync.connectionvalidator", QtInfoMsg)
|
||||
|
||||
QString baseUrl = QStringLiteral("ocs/v2.php/apps/client_side_encryption/api/v1/");
|
||||
|
||||
ClientSideEncryption::ClientSideEncryption(Account *parent) : _account(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void OCC::ClientSideEncryption::initialize()
|
||||
{
|
||||
if (!_account->capabilities().clientSideEncryptionAvaliable()) {
|
||||
qCInfo(lcCse()) << "No client side encryption, do not initialize anything.";
|
||||
emit initializationFinished();
|
||||
}
|
||||
|
||||
fetchPrivateKey();
|
||||
}
|
||||
|
||||
void ClientSideEncryption::fetchPrivateKey()
|
||||
{
|
||||
qCInfo(lcCse()) << "Client side encryption enabled, trying to retrieve the key.";
|
||||
}
|
||||
|
||||
namespace ClientSideEncryption {
|
||||
}
|
||||
|
|
|
@ -2,9 +2,27 @@
|
|||
#define CLIENTSIDEENCRYPTION_H
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class Account;
|
||||
|
||||
class ClientSideEncryption : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClientSideEncryption(OCC::Account *parent);
|
||||
void initialize();
|
||||
|
||||
void fetchPrivateKey();
|
||||
signals:
|
||||
void initializationFinished();
|
||||
|
||||
private:
|
||||
OCC::Account *_account;
|
||||
bool isInitialized = false;
|
||||
};
|
||||
|
||||
namespace ClientSideEncryption {
|
||||
QString baseUrl = QStringLiteral("ocs/v2.php/apps/client_side_encryption/api/v1/");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -326,6 +326,11 @@ void ConnectionValidator::slotUserFetched(const QJsonDocument &json)
|
|||
void ConnectionValidator::slotAvatarImage(const QImage &img)
|
||||
{
|
||||
_account->setAvatar(img);
|
||||
connect(_account->cse(), &ClientSideEncryption::initializationFinished, this, &ConnectionValidator::reportConnected);
|
||||
_account->cse()->initialize();
|
||||
}
|
||||
|
||||
void ConnectionValidator::reportConnected() {
|
||||
reportResult(Connected);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,11 @@ namespace OCC {
|
|||
|
|
||||
+-----------------------------------+
|
||||
|
|
||||
+-> fetchUser
|
||||
+-> Client Side Encryption Checks --+
|
||||
|
|
||||
+---------------------------------+
|
||||
|
|
||||
fetchUser
|
||||
PropfindJob
|
||||
|
|
||||
+-> slotUserFetched
|
||||
|
@ -126,6 +130,7 @@ protected slots:
|
|||
void slotAvatarImage(const QImage &img);
|
||||
|
||||
private:
|
||||
void reportConnected();
|
||||
void reportResult(Status status);
|
||||
void checkServerCapabilities();
|
||||
void fetchUser();
|
||||
|
|
Loading…
Reference in a new issue