Skip to content

Commit

Permalink
Add option to modify SiVa URL to on settings page
Browse files Browse the repository at this point in the history
IB-6839

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Oct 1, 2021
1 parent 92a5aaa commit d5bff79
Show file tree
Hide file tree
Showing 7 changed files with 525 additions and 368 deletions.
29 changes: 19 additions & 10 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ class DigidocConf: public digidoc::XmlConfCurrent
{ SettingsDialog::setValueEx(QStringLiteral("TSA-URL"), QString::fromStdString(url)); }

std::string TSLUrl() const override { return valueSystemScope(QStringLiteral("TSL-URL"), digidoc::XmlConfCurrent::TSLUrl()); }
std::vector<digidoc::X509Cert> TSLCerts() const override
{
std::vector<digidoc::X509Cert> tslcerts;
for(const QJsonValue &val: obj.value(QStringLiteral("TSL-CERTS")).toArray())
{
QByteArray cert = QByteArray::fromBase64(val.toString().toLatin1());
tslcerts.emplace_back((const unsigned char*)cert.constData(), size_t(cert.size()));
}
return tslcerts.empty() ? digidoc::XmlConfCurrent::TSLCerts() : tslcerts;
}

digidoc::X509Cert verifyServiceCert() const override
{
QByteArray cert = QByteArray::fromBase64(obj.value(QStringLiteral("SIVA-CERT")).toString().toLatin1());
Expand All @@ -205,17 +216,15 @@ class DigidocConf: public digidoc::XmlConfCurrent
}
return list;
}
std::string verifyServiceUri() const override { return valueSystemScope(QStringLiteral("SIVA-URL"), digidoc::XmlConfCurrent::verifyServiceUri()); }
std::vector<digidoc::X509Cert> TSLCerts() const override
std::string verifyServiceUri() const override
{
std::vector<digidoc::X509Cert> tslcerts;
for(const QJsonValue &val: obj.value(QStringLiteral("TSL-CERTS")).toArray())
{
QByteArray cert = QByteArray::fromBase64(val.toString().toLatin1());
tslcerts.emplace_back((const unsigned char*)cert.constData(), size_t(cert.size()));
}
return tslcerts.empty() ? digidoc::XmlConfCurrent::TSLCerts() : tslcerts;
if(s.value(QStringLiteral("SIVA-URL-CUSTOM"), s.contains(QStringLiteral("SIVA-URL"))).toBool())
return valueUserScope(QStringLiteral("SIVA-URL"), digidoc::XmlConfCurrent::verifyServiceUri());
return valueSystemScope(QStringLiteral("SIVA-URL"), digidoc::XmlConfCurrent::verifyServiceUri());
}
void setVerifyServiceUri(const std::string &url) override
{ SettingsDialog::setValueEx(QStringLiteral("SIVA-URL"), QString::fromStdString(url), QString()); }

std::string ocsp(const std::string &issuer) const override
{
QJsonObject ocspissuer = obj.value(QStringLiteral("OCSP-URL-ISSUER")).toObject();
Expand Down Expand Up @@ -990,7 +999,7 @@ void Application::setConfValue( ConfParameter parameter, const QVariant &value )
case PKCS12Disable: i->setPKCS12Disable( value.toBool() ); break;
case TSLOnlineDigest: i->setTSLOnlineDigest( value.toBool() ); break;
case TSAUrl: i->setTSUrl(v.isEmpty()? std::string() : v.constData()); break;
case SiVaUrl:
case SiVaUrl: i->setVerifyServiceUri(v.isEmpty()? std::string() : v.constData()); break;
case TSLCerts:
case TSLUrl:
case TSLCache: break;
Expand Down
42 changes: 34 additions & 8 deletions client/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ SettingsDialog::SettingsDialog(QWidget *parent)
ui->rdTimeStampDefault->setFont(regularFont);
ui->rdTimeStampCustom->setFont(regularFont);
ui->txtTimeStamp->setFont(regularFont);
ui->lblSiVa->setFont(headerFont);
ui->rdSiVaDefault->setFont(regularFont);
ui->rdSiVaCustom->setFont(regularFont);
ui->txtSiVa->setFont(regularFont);
ui->lblMID->setFont(headerFont);
ui->rdMIDUUIDDefault->setFont(regularFont);
ui->rdMIDUUIDCustom->setFont(regularFont);
ui->txtMIDUUID->setFont(regularFont);
ui->helpRevocation->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Abi.svg"), QStringLiteral(":/images/icon_Abi_hover.svg"), this));
ui->helpTimeStamp->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Abi.svg"), QStringLiteral(":/images/icon_Abi_hover.svg"), this));
ui->helpSiVa->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Abi.svg"), QStringLiteral(":/images/icon_Abi_hover.svg"), this));
ui->helpMID->installEventFilter(new ButtonHoverFilter(QStringLiteral(":/images/icon_Abi.svg"), QStringLiteral(":/images/icon_Abi_hover.svg"), this));

// pageProxy
Expand All @@ -145,7 +150,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)

// pageDiagnostics
ui->structureFunds->load(QStringLiteral(":/images/Struktuurifondid.svg"));
ui->pageInfoLayout->setAlignment(ui->structureFunds, Qt::AlignCenter);
ui->contact->setFont(regularFont);
ui->txtDiagnostics->setFont(regularFont);

Expand Down Expand Up @@ -415,7 +419,7 @@ void SettingsDialog::initFunctionality()
ui->chkProxyEnableForSSL->setDisabled((s.value(QStringLiteral("ProxyConfig"), 0).toInt() != 2));
updateProxy();

// pageServices
// pageServices - Access Cert
updateCert();
connect(ui->btShowCertificate, &QPushButton::clicked, this, [this] {
CertificateDetails::showCertificate(SslCertificate(AccessCert::cert()), this);
Expand All @@ -425,7 +429,11 @@ void SettingsDialog::initFunctionality()
connect(ui->chkIgnoreAccessCert, &QCheckBox::toggled, this, [](bool checked) {
Application::setConfValue(Application::PKCS12Disable, checked);
});
connect(ui->helpRevocation, &QToolButton::clicked, this, []{
QDesktopServices::openUrl(tr("https://www.id.ee/en/article/access-certificate-what-is-it/"));
});

// pageServices - TimeStamp
connect(ui->rdTimeStampCustom, &QRadioButton::toggled, ui->txtTimeStamp, [=](bool checked) {
ui->txtTimeStamp->setEnabled(checked);
setValueEx(QStringLiteral("TSA-URL-CUSTOM"), checked, QSettings().contains(QStringLiteral("TSA-URL")));
Expand All @@ -439,6 +447,29 @@ void SettingsDialog::initFunctionality()
connect(ui->txtTimeStamp, &QLineEdit::textChanged, this, [](const QString &url) {
qApp->setConfValue(Application::TSAUrl, url);
});
connect(ui->helpTimeStamp, &QToolButton::clicked, this, []{
QDesktopServices::openUrl(tr("https://www.id.ee/en/article/for-organisations-that-sign-large-quantities-of-documents-using-digidoc4-client/"));
});

// pageServices - SiVa
connect(ui->rdSiVaCustom, &QRadioButton::toggled, ui->txtSiVa, [=](bool checked) {
ui->txtSiVa->setEnabled(checked);
setValueEx(QStringLiteral("SIVA-URL-CUSTOM"), checked, QSettings().contains(QStringLiteral("SIVA-URL")));
});
ui->rdSiVaCustom->setChecked(s.value(QStringLiteral("SIVA-URL-CUSTOM"), s.contains(QStringLiteral("SIVA-URL"))).toBool());
#ifdef CONFIG_URL
ui->txtSiVa->setPlaceholderText(Configuration::instance().object().value(QStringLiteral("SIVA-URL")).toString());
#endif
QString SIVA_URL = s.value(QStringLiteral("SIVA-URL"), qApp->confValue(Application::SiVaUrl)).toString();
ui->txtSiVa->setText(ui->txtSiVa->placeholderText() == SIVA_URL ? QString() : SIVA_URL);
connect(ui->txtSiVa, &QLineEdit::textChanged, this, [](const QString &url) {
qApp->setConfValue(Application::SiVaUrl, url);
});
connect(ui->helpSiVa, &QToolButton::clicked, this, []{
QDesktopServices::openUrl(tr("https://www.id.ee/en/article/for-organisations-that-sign-large-quantities-of-documents-using-digidoc4-client/"));
});

// pageServices - MID
connect(ui->rdMIDUUIDCustom, &QRadioButton::toggled, ui->txtMIDUUID, [=](bool checked) {
ui->txtMIDUUID->setEnabled(checked);
setValueEx(QStringLiteral("MIDUUID-CUSTOM"), checked, QSettings().contains(QStringLiteral("MIDUUID")));
Expand All @@ -450,12 +481,6 @@ void SettingsDialog::initFunctionality()
setValueEx(QStringLiteral("MIDUUID"), text);
setValueEx(QStringLiteral("SIDUUID"), text);
});
connect(ui->helpRevocation, &QToolButton::clicked, this, []{
QDesktopServices::openUrl(tr("https://www.id.ee/en/article/access-certificate-what-is-it/"));
});
connect(ui->helpTimeStamp, &QToolButton::clicked, this, []{
QDesktopServices::openUrl(tr("https://www.id.ee/en/article/for-organisations-that-sign-large-quantities-of-documents-using-digidoc4-client/"));
});
connect(ui->helpMID, &QToolButton::clicked, this, []{
QDesktopServices::openUrl(tr("https://www.id.ee/en/article/for-organisations-that-sign-large-quantities-of-documents-using-digidoc4-client/"));
});
Expand Down Expand Up @@ -618,6 +643,7 @@ void SettingsDialog::useDefaultSettings()
AccessCert().remove();
updateCert();
ui->rdTimeStampDefault->setChecked(true);
ui->rdSiVaDefault->setChecked(true);
ui->rdMIDUUIDDefault->setChecked(true);
}

Expand Down
Loading

0 comments on commit d5bff79

Please sign in to comment.