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 "creds/abstractcredentials.h"
|
||||||
#include "capabilities.h"
|
#include "capabilities.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
#include "common/asserts.h"
|
#include "common/asserts.h"
|
||||||
|
#include "clientsideencryption.h"
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
@ -39,6 +41,7 @@ Q_LOGGING_CATEGORY(lcAccount, "sync.account", QtInfoMsg)
|
||||||
Account::Account(QObject *parent)
|
Account::Account(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, _capabilities(QVariantMap())
|
, _capabilities(QVariantMap())
|
||||||
|
, _encryption(new ClientSideEncryption(this))
|
||||||
, _davPath(Theme::instance()->webDavPath())
|
, _davPath(Theme::instance()->webDavPath())
|
||||||
{
|
{
|
||||||
qRegisterMetaType<AccountPtr>("AccountPtr");
|
qRegisterMetaType<AccountPtr>("AccountPtr");
|
||||||
|
@ -482,4 +485,9 @@ void Account::setNonShib(bool nonShib)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClientSideEncryption *Account::cse() const
|
||||||
|
{
|
||||||
|
return _encryption;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OCC
|
} // namespace OCC
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "common/utility.h"
|
#include "common/utility.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "capabilities.h"
|
#include "capabilities.h"
|
||||||
|
#include "clientsideencryption.h"
|
||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
@ -225,6 +226,7 @@ public:
|
||||||
/// Called by network jobs on credential errors, emits invalidCredentials()
|
/// Called by network jobs on credential errors, emits invalidCredentials()
|
||||||
void handleInvalidCredentials();
|
void handleInvalidCredentials();
|
||||||
|
|
||||||
|
ClientSideEncryption *cse() const;
|
||||||
public slots:
|
public slots:
|
||||||
/// Used when forgetting credentials
|
/// Used when forgetting credentials
|
||||||
void clearQNAMCache();
|
void clearQNAMCache();
|
||||||
|
@ -274,6 +276,7 @@ private:
|
||||||
QuotaInfo *_quotaInfo;
|
QuotaInfo *_quotaInfo;
|
||||||
QSharedPointer<QNetworkAccessManager> _am;
|
QSharedPointer<QNetworkAccessManager> _am;
|
||||||
QScopedPointer<AbstractCredentials> _credentials;
|
QScopedPointer<AbstractCredentials> _credentials;
|
||||||
|
ClientSideEncryption *_encryption;
|
||||||
bool _http2Supported = false;
|
bool _http2Supported = false;
|
||||||
|
|
||||||
/// Certificates that were explicitly rejected by the user
|
/// Certificates that were explicitly rejected by the user
|
||||||
|
|
|
@ -1,4 +1,34 @@
|
||||||
#include "clientsideencryption.h"
|
#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
|
#define CLIENTSIDEENCRYPTION_H
|
||||||
|
|
||||||
#include <QString>
|
#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
|
#endif
|
||||||
|
|
|
@ -326,6 +326,11 @@ void ConnectionValidator::slotUserFetched(const QJsonDocument &json)
|
||||||
void ConnectionValidator::slotAvatarImage(const QImage &img)
|
void ConnectionValidator::slotAvatarImage(const QImage &img)
|
||||||
{
|
{
|
||||||
_account->setAvatar(img);
|
_account->setAvatar(img);
|
||||||
|
connect(_account->cse(), &ClientSideEncryption::initializationFinished, this, &ConnectionValidator::reportConnected);
|
||||||
|
_account->cse()->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionValidator::reportConnected() {
|
||||||
reportResult(Connected);
|
reportResult(Connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,11 @@ namespace OCC {
|
||||||
|
|
|
|
||||||
+-----------------------------------+
|
+-----------------------------------+
|
||||||
|
|
|
|
||||||
+-> fetchUser
|
+-> Client Side Encryption Checks --+
|
||||||
|
|
|
||||||
|
+---------------------------------+
|
||||||
|
|
|
||||||
|
fetchUser
|
||||||
PropfindJob
|
PropfindJob
|
||||||
|
|
|
|
||||||
+-> slotUserFetched
|
+-> slotUserFetched
|
||||||
|
@ -126,6 +130,7 @@ protected slots:
|
||||||
void slotAvatarImage(const QImage &img);
|
void slotAvatarImage(const QImage &img);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void reportConnected();
|
||||||
void reportResult(Status status);
|
void reportResult(Status status);
|
||||||
void checkServerCapabilities();
|
void checkServerCapabilities();
|
||||||
void fetchUser();
|
void fetchUser();
|
||||||
|
|
Loading…
Reference in a new issue