keepassxc/src/browser/BrowserAction.h

68 lines
2.7 KiB
C++
Raw Normal View History

2017-12-12 10:15:23 +02:00
/*
* Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
*
* 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
#include <QString>
2017-12-12 10:15:23 +02:00
2021-07-11 22:10:29 -04:00
class QJsonObject;
class QLocalSocket;
2021-07-11 22:10:29 -04:00
class BrowserAction
2017-12-12 10:15:23 +02:00
{
public:
explicit BrowserAction() = default;
2017-12-12 10:15:23 +02:00
~BrowserAction() = default;
QJsonObject processClientMessage(QLocalSocket* socket, const QJsonObject& json);
2017-12-12 10:15:23 +02:00
private:
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);
QJsonObject handleGetLogins(QLocalSocket* socket, const QJsonObject& json, const QString& action);
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);
QJsonObject handleGetDatabaseGroups(const QJsonObject& json, const QString& action);
QJsonObject handleCreateNewGroup(const QJsonObject& json, const QString& action);
QJsonObject handleGetTotp(const QJsonObject& json, const QString& action);
QJsonObject handleDeleteEntry(const QJsonObject& json, const QString& action);
QJsonObject handleGlobalAutoType(const QJsonObject& json, const QString& action);
2017-12-12 10:15:23 +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;
QJsonObject decryptMessage(const QString& message, const QString& nonce);
2017-12-12 10:15:23 +02:00
private:
static const int MaxUrlLength;
2018-03-31 16:01:30 -04:00
QString m_clientPublicKey;
QString m_publicKey;
QString m_secretKey;
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