mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Support "KPH: " extra fields.
This commit is contained in:
parent
b9e58c77af
commit
f82725139a
@ -33,7 +33,8 @@ static const char * const STR_SET_LOGIN = "set-login";
|
|||||||
static const char * const STR_ASSOCIATE = "associate";
|
static const char * const STR_ASSOCIATE = "associate";
|
||||||
static const char * const STR_TEST_ASSOCIATE = "test-associate";
|
static const char * const STR_TEST_ASSOCIATE = "test-associate";
|
||||||
static const char * const STR_GENERATE_PASSWORD = "generate-password";
|
static const char * const STR_GENERATE_PASSWORD = "generate-password";
|
||||||
static const char * const STR_VERSION = "1.5.0.0";
|
static const char * const STR_VERSION = "1.6.0.0";
|
||||||
|
|
||||||
}/*namespace KeepassHttpProtocol*/
|
}/*namespace KeepassHttpProtocol*/
|
||||||
|
|
||||||
using namespace KeepassHttpProtocol;
|
using namespace KeepassHttpProtocol;
|
||||||
@ -354,10 +355,14 @@ void Response::setEntries(const QList<Entry> &entries)
|
|||||||
QList<Entry> encryptedEntries;
|
QList<Entry> encryptedEntries;
|
||||||
encryptedEntries.reserve(m_count);
|
encryptedEntries.reserve(m_count);
|
||||||
Q_FOREACH (const Entry &entry, entries) {
|
Q_FOREACH (const Entry &entry, entries) {
|
||||||
encryptedEntries << Entry(encrypt(entry.name(), m_cipher),
|
Entry encryptedEntry(encrypt(entry.name(), m_cipher),
|
||||||
encrypt(entry.login(), m_cipher),
|
encrypt(entry.login(), m_cipher),
|
||||||
entry.password().isNull() ? QString() : encrypt(entry.password(), m_cipher),
|
entry.password().isNull() ? QString() : encrypt(entry.password(), m_cipher),
|
||||||
encrypt(entry.uuid(), m_cipher));
|
encrypt(entry.uuid(), m_cipher));
|
||||||
|
Q_FOREACH (const StringField & field, entry.stringFields())
|
||||||
|
encryptedEntry.addStringField(encrypt(field.key(), m_cipher),
|
||||||
|
encrypt(field.value(), m_cipher));
|
||||||
|
encryptedEntries << encryptedEntry;
|
||||||
}
|
}
|
||||||
m_entries = encryptedEntries;
|
m_entries = encryptedEntries;
|
||||||
}
|
}
|
||||||
@ -405,7 +410,7 @@ void Response::setError(const QString &error)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// ResponseEntry
|
/// Entry
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Entry::Entry()
|
Entry::Entry()
|
||||||
@ -423,7 +428,8 @@ Entry::Entry(const Entry & other):
|
|||||||
m_login(other.m_login),
|
m_login(other.m_login),
|
||||||
m_password(other.m_password),
|
m_password(other.m_password),
|
||||||
m_uuid(other.m_uuid),
|
m_uuid(other.m_uuid),
|
||||||
m_name(other.m_name)
|
m_name(other.m_name),
|
||||||
|
m_stringFields(other.m_stringFields)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Entry & Entry::operator=(const Entry & other)
|
Entry & Entry::operator=(const Entry & other)
|
||||||
@ -432,6 +438,7 @@ Entry & Entry::operator=(const Entry & other)
|
|||||||
m_password = other.m_password;
|
m_password = other.m_password;
|
||||||
m_uuid = other.m_uuid;
|
m_uuid = other.m_uuid;
|
||||||
m_name = other.m_name;
|
m_name = other.m_name;
|
||||||
|
m_stringFields = other.m_stringFields;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,3 +461,58 @@ QString Entry::password() const
|
|||||||
{
|
{
|
||||||
return m_password;
|
return m_password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<StringField> Entry::stringFields() const
|
||||||
|
{
|
||||||
|
return m_stringFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Entry::addStringField(const QString &key, const QString &value)
|
||||||
|
{
|
||||||
|
m_stringFields.append(StringField(key, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant Entry::getStringFields() const
|
||||||
|
{
|
||||||
|
if (m_stringFields.isEmpty())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
QList<QVariant> res;
|
||||||
|
res.reserve(m_stringFields.size());
|
||||||
|
Q_FOREACH (const StringField &stringfield, m_stringFields)
|
||||||
|
res.append(QJson::QObjectHelper::qobject2qvariant(&stringfield, QJson::QObjectHelper::Flag_None));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// StringField
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
StringField::StringField()
|
||||||
|
{}
|
||||||
|
|
||||||
|
StringField::StringField(const QString &key, const QString &value):
|
||||||
|
m_key(key), m_value(value)
|
||||||
|
{}
|
||||||
|
|
||||||
|
StringField::StringField(const StringField &other):
|
||||||
|
m_key(other.m_key), m_value(other.m_value)
|
||||||
|
{}
|
||||||
|
|
||||||
|
StringField &StringField::operator =(const StringField &other)
|
||||||
|
{
|
||||||
|
m_key = m_key;
|
||||||
|
m_value = m_value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StringField::key() const
|
||||||
|
{
|
||||||
|
return m_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StringField::value() const
|
||||||
|
{
|
||||||
|
return m_value;
|
||||||
|
}
|
||||||
|
@ -99,6 +99,26 @@ private:
|
|||||||
mutable SymmetricCipher m_cipher;
|
mutable SymmetricCipher m_cipher;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class StringField : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString Key READ key )
|
||||||
|
Q_PROPERTY(QString Value READ value)
|
||||||
|
|
||||||
|
public:
|
||||||
|
StringField();
|
||||||
|
StringField(const QString& key, const QString& value);
|
||||||
|
StringField(const StringField & other);
|
||||||
|
StringField &operator =(const StringField &other);
|
||||||
|
|
||||||
|
QString key() const;
|
||||||
|
QString value() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_key;
|
||||||
|
QString m_value;
|
||||||
|
};
|
||||||
|
|
||||||
class Entry : public QObject
|
class Entry : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -106,6 +126,7 @@ class Entry : public QObject
|
|||||||
Q_PROPERTY(QString Password READ password )
|
Q_PROPERTY(QString Password READ password )
|
||||||
Q_PROPERTY(QString Uuid READ uuid )
|
Q_PROPERTY(QString Uuid READ uuid )
|
||||||
Q_PROPERTY(QString Name READ name )
|
Q_PROPERTY(QString Name READ name )
|
||||||
|
Q_PROPERTY(QVariant StringFields READ getStringFields)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Entry();
|
Entry();
|
||||||
@ -117,12 +138,17 @@ public:
|
|||||||
QString password() const;
|
QString password() const;
|
||||||
QString uuid() const;
|
QString uuid() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
QList<StringField> stringFields() const;
|
||||||
|
void addStringField(const QString& key, const QString& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QVariant getStringFields() const;
|
||||||
|
|
||||||
QString m_login;
|
QString m_login;
|
||||||
QString m_password;
|
QString m_password;
|
||||||
QString m_uuid;
|
QString m_uuid;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
QList<StringField> m_stringFields;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Response : public QObject
|
class Response : public QObject
|
||||||
|
@ -34,11 +34,11 @@ Service::Service(DatabaseTabWidget *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char KEEPASSHTTP_UUID_DATA[] = {
|
static const unsigned char KEEPASSHTTP_UUID_DATA[] = {
|
||||||
0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0,
|
0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0,
|
||||||
0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31
|
0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31
|
||||||
};
|
};
|
||||||
static const Uuid KEEPASSHTTP_UUID = Uuid(QByteArray::fromRawData(KEEPASSHTTP_UUID_DATA, sizeof(KEEPASSHTTP_UUID_DATA)));
|
static const Uuid KEEPASSHTTP_UUID = Uuid(QByteArray::fromRawData(reinterpret_cast<const char *>(KEEPASSHTTP_UUID_DATA), sizeof(KEEPASSHTTP_UUID_DATA)));
|
||||||
static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings";
|
static const char KEEPASSHTTP_NAME[] = "KeePassHttp Settings";
|
||||||
static const char ASSOCIATE_KEY_PREFIX[] = "AES Key: ";
|
static const char ASSOCIATE_KEY_PREFIX[] = "AES Key: ";
|
||||||
static const char KEEPASSHTTP_GROUP_NAME[] = "KeePassHttp Passwords"; //Group where new KeePassHttp password are stored
|
static const char KEEPASSHTTP_GROUP_NAME[] = "KeePassHttp Passwords"; //Group where new KeePassHttp password are stored
|
||||||
@ -201,6 +201,20 @@ Service::Access Service::checkAccess(const Entry *entry, const QString & host, c
|
|||||||
return Unknown; //not configured for this host
|
return Unknown; //not configured for this host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeepassHttpProtocol::Entry Service::prepareEntry(const Entry* entry)
|
||||||
|
{
|
||||||
|
bool returnStringFields = true; //TODO: setting!
|
||||||
|
KeepassHttpProtocol::Entry res(entry->title(), entry->username(), entry->password(), entry->uuid().toHex());
|
||||||
|
if (returnStringFields)
|
||||||
|
{
|
||||||
|
const EntryAttributes * attr = entry->attributes();
|
||||||
|
Q_FOREACH (const QString& key, attr->keys())
|
||||||
|
if (key.startsWith(QLatin1String("KPH: ")))
|
||||||
|
res.addStringField(key, attr->value(key));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
QList<KeepassHttpProtocol::Entry> Service::findMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm)
|
QList<KeepassHttpProtocol::Entry> Service::findMatchingEntries(const QString &id, const QString &url, const QString &submitUrl, const QString &realm)
|
||||||
{
|
{
|
||||||
QList<KeepassHttpProtocol::Entry> result;
|
QList<KeepassHttpProtocol::Entry> result;
|
||||||
@ -224,7 +238,7 @@ QList<KeepassHttpProtocol::Entry> Service::findMatchingEntries(const QString &id
|
|||||||
}
|
}
|
||||||
//fall through
|
//fall through
|
||||||
case Allowed:
|
case Allowed:
|
||||||
result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex());
|
result << prepareEntry(entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +273,7 @@ QList<KeepassHttpProtocol::Entry> Service::findMatchingEntries(const QString &id
|
|||||||
}
|
}
|
||||||
if (res == QDialog::Accepted) {
|
if (res == QDialog::Accepted) {
|
||||||
Q_FOREACH (Entry * entry, pwEntries)
|
Q_FOREACH (Entry * entry, pwEntries)
|
||||||
result << KeepassHttpProtocol::Entry(entry->title(), entry->username(), entry->password(), entry->uuid().toHex());
|
result << prepareEntry(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ private:
|
|||||||
Access checkAccess(const Entry *entry, const QString & host, const QString & submitHost, const QString & realm);
|
Access checkAccess(const Entry *entry, const QString & host, const QString & submitHost, const QString & realm);
|
||||||
bool removeFirstDomain(QString &hostname);
|
bool removeFirstDomain(QString &hostname);
|
||||||
Group *findCreateAddEntryGroup();
|
Group *findCreateAddEntryGroup();
|
||||||
|
KeepassHttpProtocol::Entry prepareEntry(const Entry *entry);
|
||||||
QList<Entry *> searchEntries(const QString &text);
|
QList<Entry *> searchEntries(const QString &text);
|
||||||
|
|
||||||
DatabaseTabWidget * const m_dbTabWidget;
|
DatabaseTabWidget * const m_dbTabWidget;
|
||||||
|
Loading…
Reference in New Issue
Block a user