mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
Feature #313: Support JWK sets
When multiple keys are selected, put them all into one file as a JWK set, which is "keys" array of JWK objects.
This commit is contained in:
parent
778e5c2e3a
commit
2e70aa6329
@ -678,8 +678,31 @@ void db_base::writeVcalendar(XFile &file, QStringList vcal) const
|
||||
void db_base::exportItems(const QModelIndexList &indexes,
|
||||
const pki_export *xport, XFile &file) const
|
||||
{
|
||||
foreach(QModelIndex idx, indexes)
|
||||
exportItem(idx, xport, file);
|
||||
if (xport->match_all(F_JWK) && indexes.size() > 1) {
|
||||
QJsonArray arr;
|
||||
QSet<QString> names;
|
||||
|
||||
foreach(QModelIndex idx, indexes) {
|
||||
QJsonObject jwk;
|
||||
pki_base *pki = fromIndex<pki_base>(idx);
|
||||
if (pki) {
|
||||
pki->fillJWK(jwk, xport);
|
||||
QString name = jwk["kid"].toString();
|
||||
for (int i = 1; names.contains(name); i++)
|
||||
name = QString("%1 (%2)").arg(jwk["kid"].toString()).arg(i);
|
||||
|
||||
jwk["kid"] = name;
|
||||
names.insert(name);
|
||||
arr.append(jwk);
|
||||
}
|
||||
}
|
||||
QJsonObject obj { { "keys", arr } };
|
||||
QJsonDocument doc(obj);
|
||||
file.write(doc.toJson());
|
||||
} else {
|
||||
foreach(QModelIndex idx, indexes)
|
||||
exportItem(idx, xport, file);
|
||||
}
|
||||
}
|
||||
|
||||
void db_base::exportItem(const QModelIndex &index,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user