Falkon Develop
Cross-platform Qt-based web browser
databaseencryptedpasswordbackend.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2013-2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
4* Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
5*
6* This program is free software: you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation, either version 3 of the License, or
9* (at your option) any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program. If not, see <http://www.gnu.org/licenses/>.
18* ============================================================ */
19#ifndef DATABASEENCRYPTEDPASSWORDBACKEND_H
20#define DATABASEENCRYPTEDPASSWORDBACKEND_H
21
22#include "passwordbackend.h"
23#include "qzcommon.h"
24
25#include <QDialog>
26
27class AesInterface;
29
31{
32public:
36 UnKnownState = -1
37 };
38
40
42
43 QStringList getUsernames(const QUrl &url) override;
44 QVector<PasswordEntry> getEntries(const QUrl &url) override;
45 QVector<PasswordEntry> getAllEntries() override;
46
47 void setActive(bool active) override;
48
49 void addEntry(const PasswordEntry &entry) override;
50 bool updateEntry(const PasswordEntry &entry) override;
51 void updateLastUsed(PasswordEntry &entry) override;
52
53 void removeEntry(const PasswordEntry &entry) override;
54 void removeAll() override;
55
56 QString name() const override;
57
58 bool hasSettings() const override;
59 void showSettings(QWidget* parent) override;
60
61 bool isMasterPasswordSetted();
62
63 QByteArray masterPassword() const;
64
65 bool hasPermission();
66 bool isPasswordVerified(const QByteArray &password);
67
68 bool decryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface);
69 bool encryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface);
70
71 void tryToChangeMasterPassword(const QByteArray &newPassword);
72 void removeMasterPassword();
73
74 void setAskMasterPasswordState(bool ask);
75
76 void encryptDataBaseTableOnFly(const QByteArray &decryptorPassword,
77 const QByteArray &encryptorPassword);
78
79 void updateSampleData(const QByteArray &password);
80
81 void showMasterPasswordDialog();
82
83private:
84 QByteArray someDataFromDatabase();
85
86 MasterPasswordState m_stateOfMasterPassword;
87 QByteArray m_someDataStoredOnDataBase;
88
89 bool m_askPasswordDialogVisible;
90 bool m_askMasterPassword;
91 QByteArray m_masterPassword;
92};
93
94namespace Ui
95{
97}
98
99class MasterPasswordDialog : public QDialog
100{
101 Q_OBJECT
102
103public:
104 explicit MasterPasswordDialog(DatabaseEncryptedPasswordBackend* backend, QWidget* parent = nullptr);
105 ~MasterPasswordDialog() override;
106
107 void delayedExec();
108
109public Q_SLOTS:
110 void accept() override;
111 void reject() override;
112 void showSettingPage();
114 void clearMasterPasswordAndConvert(bool forcedAskPass = true);
115 bool samePasswordEntry(const PasswordEntry &entry1, const PasswordEntry &entry2);
116
117private:
118 Ui::MasterPasswordDialog* ui;
120};
121
122class QDialogButtonBox;
123class QLineEdit;
124class QLabel;
125
126class AskMasterPassword : public QDialog
127{
128 Q_OBJECT
129
130public:
131 explicit AskMasterPassword(DatabaseEncryptedPasswordBackend* backend, QWidget* parent = nullptr);
132
133private Q_SLOTS:
134 void verifyPassword();
135
136private:
138 QDialogButtonBox* m_buttonBox;
139 QLineEdit* m_lineEdit;
140 QLabel* m_labelWarning;
141};
142#endif // DATABASEENCRYPTEDPASSWORDBACKEND_H
AskMasterPassword(DatabaseEncryptedPasswordBackend *backend, QWidget *parent=nullptr)
bool samePasswordEntry(const PasswordEntry &entry1, const PasswordEntry &entry2)
MasterPasswordDialog(DatabaseEncryptedPasswordBackend *backend, QWidget *parent=nullptr)
void clearMasterPasswordAndConvert(bool forcedAskPass=true)
virtual void showSettings(QWidget *parent)
virtual bool updateEntry(const PasswordEntry &entry)=0
virtual void addEntry(const PasswordEntry &entry)=0
virtual QVector< PasswordEntry > getAllEntries()=0
virtual QString name() const =0
virtual void removeAll()=0
virtual QStringList getUsernames(const QUrl &url)
virtual void removeEntry(const PasswordEntry &entry)=0
virtual bool hasSettings() const
virtual void updateLastUsed(PasswordEntry &entry)=0
virtual QVector< PasswordEntry > getEntries(const QUrl &url)=0
virtual void setActive(bool active)
#define FALKON_EXPORT
Definition: qzcommon.h:28