Skip to content

Commit

Permalink
Remove Smart-ID v1 protocol support
Browse files Browse the repository at this point in the history
IB-7958

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Feb 6, 2024
1 parent f8411a3 commit 58e9791
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 26 deletions.
3 changes: 3 additions & 0 deletions client/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ class REOpenEvent: public QEvent
enum { Type = QEvent::User + 1 };
REOpenEvent(): QEvent( QEvent::Type(Type) ) {}
};

extern template QJsonValue Application::confValue<QString>(const QString &key);
extern template QJsonValue Application::confValue<QLatin1String>(const QLatin1String &key);
6 changes: 2 additions & 4 deletions client/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ void Diagnostics::generalInfo(QTextStream &s)
#ifdef CONFIG_URL
<< "<br />CONFIG_URL: " << CONFIG_URL
#endif
<< "<br />SID-PROXY-URL: " << Application::confValue(QLatin1String("SID-PROXY-URL")).toString(QStringLiteral(SMARTID_URL))
<< "<br />SIDV2-PROXY-URL: " << Application::confValue(QLatin1String("SIDV2-PROXY-URL")).toString(QStringLiteral(SMARTID_URL))
<< "<br />SID-SK-URL: " << Application::confValue(QLatin1String("SID-SK-URL")).toString(QStringLiteral(SMARTID_URL))
<< "<br />SIDV2-SK-URL: " << Application::confValue(QLatin1String("SIDV2-SK-URL")).toString(QStringLiteral(SMARTID_URL))
<< "<br />SIDV2-PROXY-URL: " << Settings::SID_PROXY_URL
<< "<br />SIDV2-SK-URL: " << Settings::SID_SK_URL
<< "<br />MID-PROXY-URL: " << Settings::MID_PROXY_URL
<< "<br />MID-SK-URL: " << Settings::MID_SK_URL
<< "<br />RPUUID: " << (Settings::MID_UUID_CUSTOM ? tr("is set manually") : tr("is set by default"))
Expand Down
6 changes: 2 additions & 4 deletions client/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ const Option<QString> Settings::SID_UUID { QStringLiteral("SIDUUID") };
const Option<QString> Settings::SID_NAME { QStringLiteral("SIDNAME"), QStringLiteral("RIA DigiDoc") };
const Option<QString, QString (*)()> Settings::SID_PROXY_URL { QStringLiteral("SID-PROXY-URL"), []{
return Application::confValue(QLatin1String("SIDV2-PROXY-URL"))
.toString(Application::confValue(QLatin1String("SID-PROXY-URL"))
.toString(QStringLiteral(SMARTID_URL)));
.toString(QStringLiteral(SMARTID_URL));
}};
const Option<QString, QString (*)()> Settings::SID_SK_URL { QStringLiteral("SID-SK-URL"), []{
return Application::confValue(QLatin1String("SIDV2-SK-URL"))
.toString(Application::confValue(QLatin1String("SID-SK-URL"))
.toString(QStringLiteral(SMARTID_URL)));
.toString(QStringLiteral(SMARTID_URL));
}};
const Option<bool, bool (*)()> Settings::SID_UUID_CUSTOM
{ QStringLiteral("SIDUUID-CUSTOM"), [] { return Settings::SID_UUID.isSet(); } };
Expand Down
2 changes: 1 addition & 1 deletion client/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct Settings
}
const QString KEY;
const D DEFAULT {};
std::function<void (const T &value)> f;
std::function<void (const T &value)> f {};
};

static const Option<bool> CDOC2_DEFAULT;
Expand Down
22 changes: 6 additions & 16 deletions client/dialogs/SmartIDProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,7 @@ bool SmartIDProgress::init(const QString &country, const QString &idCode, const
{"certificateLevel", "QUALIFIED"},
{"nonce", QUuid::createUuid().toString().remove('-').mid(1, 30)}
}).toJson();
if (d->req.url().path().contains(QLatin1String("v1"), Qt::CaseInsensitive)) {
d->req.setUrl(QUrl(QStringLiteral("%1/certificatechoice/pno/%2/%3").arg(d->URL, country, idCode)));
} else {
d->req.setUrl(QUrl(QStringLiteral("%1/certificatechoice/etsi/PNO%2-%3").arg(d->URL, country, idCode)));
}
d->req.setUrl(QUrl(QStringLiteral("%1/certificatechoice/etsi/PNO%2-%3").arg(d->URL, country, idCode)));
qCDebug(SIDLog).noquote() << d->req.url() << data;
d->manager->post(d->req, data);
d->info->setText(tr("Open the Smart-ID application on your smart device and confirm device for signing."));
Expand Down Expand Up @@ -307,19 +303,13 @@ std::vector<unsigned char> SmartIDProgress::sign(const std::string &method, cons
{"certificateLevel", "QUALIFIED"},
{"hash", QString(QByteArray::fromRawData((const char*)digest.data(), int(digest.size())).toBase64())},
{"hashType", digestMethod},
{"allowedInteractionsOrder", QJsonArray{QJsonObject{
{"type", "confirmationMessageAndVerificationCodeChoice"},
{"displayText200", "%1"}
}}},
};
QString escape = tr("Sign document");
if (d->req.url().path().contains(QLatin1String("v1"), Qt::CaseInsensitive)) {
req[QLatin1String("requestProperties")] = QJsonObject{{"vcChoice", true}};
req[QLatin1String("displayText")] = "%1";
} else {
req[QLatin1String("allowedInteractionsOrder")] = QJsonArray{QJsonObject{
{"type", "confirmationMessageAndVerificationCodeChoice"},
{"displayText200", "%1"}
}};
escape = QStringLiteral("%1 %2").arg(tr("Sign document"), d->fileName);
}
// Workaround SID proxy issues
QString escape = QStringLiteral("%1 %2").arg(tr("Sign document"), d->fileName);
QByteArray data = QString::fromUtf8(QJsonDocument(req).toJson()).arg(escapeUnicode(escape)).toUtf8();
d->req.setUrl(QUrl(QStringLiteral("%1/signature/document/%2").arg(d->URL, d->documentNumber)));
qCDebug(SIDLog).noquote() << d->req.url() << data;
Expand Down
2 changes: 1 addition & 1 deletion cmake

0 comments on commit 58e9791

Please sign in to comment.