2017-12-12 10:15:23 +02:00
|
|
|
/*
|
2022-02-23 00:52:51 +02:00
|
|
|
* Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
|
2018-11-01 04:27:38 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-12-12 10:15:23 +02:00
|
|
|
|
|
|
|
#ifndef BROWSERACTION_H
|
|
|
|
#define BROWSERACTION_H
|
|
|
|
|
2020-05-10 21:20:00 -04:00
|
|
|
#include <QString>
|
2017-12-12 10:15:23 +02:00
|
|
|
|
2021-07-11 22:10:29 -04:00
|
|
|
class QJsonObject;
|
2022-02-23 00:52:51 +02:00
|
|
|
class QLocalSocket;
|
2021-07-11 22:10:29 -04:00
|
|
|
|
2020-05-10 21:20:00 -04:00
|
|
|
class BrowserAction
|
2017-12-12 10:15:23 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-02-23 00:52:51 +02:00
|
|
|
explicit BrowserAction() = default;
|
2017-12-12 10:15:23 +02:00
|
|
|
~BrowserAction() = default;
|
|
|
|
|
2022-02-23 00:52:51 +02:00
|
|
|
QJsonObject processClientMessage(QLocalSocket* socket, const QJsonObject& json);
|
2017-12-12 10:15:23 +02:00
|
|
|
|
|
|
|
private:
|
2022-02-23 00:52:51 +02:00
|
|
|
QJsonObject handleAction(QLocalSocket* socket, const QJsonObject& json);
|
2017-12-12 10:15:23 +02:00
|
|
|
QJsonObject handleChangePublicKeys(const QJsonObject& json, const QString& action);
|
|
|
|
QJsonObject handleGetDatabaseHash(const QJsonObject& json, const QString& action);
|
|
|
|
QJsonObject handleAssociate(const QJsonObject& json, const QString& action);
|
|
|
|
QJsonObject handleTestAssociate(const QJsonObject& json, const QString& action);
|
2022-04-24 10:39:12 +03:00
|
|
|
QJsonObject handleGetLogins(QLocalSocket* socket, const QJsonObject& json, const QString& action);
|
2022-02-23 00:52:51 +02:00
|
|
|
QJsonObject handleGeneratePassword(QLocalSocket* socket, const QJsonObject& json, const QString& action);
|
2017-12-12 10:15:23 +02:00
|
|
|
QJsonObject handleSetLogin(const QJsonObject& json, const QString& action);
|
|
|
|
QJsonObject handleLockDatabase(const QJsonObject& json, const QString& action);
|
2019-01-30 16:48:22 +02:00
|
|
|
QJsonObject handleGetDatabaseGroups(const QJsonObject& json, const QString& action);
|
2019-03-16 10:34:50 +02:00
|
|
|
QJsonObject handleCreateNewGroup(const QJsonObject& json, const QString& action);
|
2020-08-17 13:17:58 +03:00
|
|
|
QJsonObject handleGetTotp(const QJsonObject& json, const QString& action);
|
2021-09-06 18:38:25 +03:00
|
|
|
QJsonObject handleDeleteEntry(const QJsonObject& json, const QString& action);
|
2021-10-10 14:49:25 +03:00
|
|
|
QJsonObject handleGlobalAutoType(const QJsonObject& json, const QString& action);
|
2017-12-12 10:15:23 +02:00
|
|
|
|
2022-02-23 00:52:51 +02:00
|
|
|
private:
|
2017-12-12 10:15:23 +02:00
|
|
|
QJsonObject buildMessage(const QString& nonce) const;
|
|
|
|
QJsonObject buildResponse(const QString& action, const QJsonObject& message, const QString& nonce);
|
|
|
|
QJsonObject getErrorReply(const QString& action, const int errorCode) const;
|
2019-01-25 05:45:30 +02:00
|
|
|
QJsonObject decryptMessage(const QString& message, const QString& nonce);
|
2017-12-12 10:15:23 +02:00
|
|
|
|
|
|
|
private:
|
2021-10-10 14:49:25 +03:00
|
|
|
static const int MaxUrlLength;
|
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
QString m_clientPublicKey;
|
|
|
|
QString m_publicKey;
|
|
|
|
QString m_secretKey;
|
2020-05-10 21:20:00 -04:00
|
|
|
bool m_associated = false;
|
2018-12-10 14:20:58 +02:00
|
|
|
|
|
|
|
friend class TestBrowser;
|
2017-12-12 10:15:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BROWSERACTION_H
|