diff --git a/vpn/fortisslvpn/fortisslvpnadvanced.ui b/vpn/fortisslvpn/fortisslvpnadvanced.ui
index c4182b71..8505aac4 100644
--- a/vpn/fortisslvpn/fortisslvpnadvanced.ui
+++ b/vpn/fortisslvpn/fortisslvpnadvanced.ui
@@ -1,78 +1,100 @@
FortisslvpnAdvancedWidget
0
0
- 410
- 110
+ 400
+ 175
0
0
400
100
-
+
+
+
+ 0
+ 0
+
+
+
+ Autentication
+
+
+
-
+
+
+ Use a One-Time Password
+
+
+
+
+
+
+ -
0
0
Security
-
Trusted certificate:
-
0
0
0123456789abcdef0123456789abcdef0123456789abcdef0123456789
- -
+
-
Qt::Vertical
20
40
diff --git a/vpn/fortisslvpn/fortisslvpnauth.cpp b/vpn/fortisslvpn/fortisslvpnauth.cpp
index 66af9d4a..d205ee79 100644
--- a/vpn/fortisslvpn/fortisslvpnauth.cpp
+++ b/vpn/fortisslvpn/fortisslvpnauth.cpp
@@ -1,64 +1,78 @@
/*
Copyright 2016 Jan Grulich
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see .
*/
#include "fortisslvpnauth.h"
#include "ui_fortisslvpnauth.h"
#include "nm-fortisslvpn-service.h"
#include
class FortisslvpnAuthDialogPrivate
{
public:
Ui_FortisslvpnAuth ui;
NetworkManager::VpnSetting::Ptr setting;
};
FortisslvpnAuthDialog::FortisslvpnAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent)
: SettingWidget(setting, parent)
, d_ptr(new FortisslvpnAuthDialogPrivate)
{
Q_D(FortisslvpnAuthDialog);
+
+ const NMStringMap data = d->setting->data();
+
d->ui.setupUi(this);
d->setting = setting;
+ const NetworkManager::Setting::SecretFlags otpFlag = static_cast(data.value(NM_FORTISSLVPN_KEY_OTP"-flags").toInt());
+ d->ui.otpFrame->setVisible(otpFlag == NetworkManager::Setting::NotSaved);
+
KAcceleratorManager::manage(this);
}
FortisslvpnAuthDialog::~FortisslvpnAuthDialog()
{
delete d_ptr;
}
QVariantMap FortisslvpnAuthDialog::setting() const
{
Q_D(const FortisslvpnAuthDialog);
+ const NMStringMap data = d->setting->data();
NMStringMap secrets;
QVariantMap secretData;
if (!d->ui.password->text().isEmpty()) {
secrets.insert(QLatin1String(NM_FORTISSLVPN_KEY_PASSWORD), d->ui.password->text());
}
+ if (!data.value(NM_FORTISSLVPN_KEY_OTP"-flags").isEmpty()) {
+ const NetworkManager::Setting::SecretFlags otpFlag = static_cast(data.value(NM_FORTISSLVPN_KEY_OTP"-flags").toInt());
+ if (otpFlag == NetworkManager::Setting::NotSaved && !d->ui.otp->text().isEmpty()) {
+ secrets.insert(QLatin1String(NM_FORTISSLVPN_KEY_OTP), d->ui.otp->text());
+ }
+ }
+
secretData.insert("secrets", QVariant::fromValue(secrets));
return secretData;
}
diff --git a/vpn/fortisslvpn/fortisslvpnauth.ui b/vpn/fortisslvpn/fortisslvpnauth.ui
index c423c61c..302e5db1 100644
--- a/vpn/fortisslvpn/fortisslvpnauth.ui
+++ b/vpn/fortisslvpn/fortisslvpnauth.ui
@@ -1,48 +1,80 @@
FortisslvpnAuth
0
0
408
136
0
-
Password:
false
password
-
true
+ -
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+ 0
+
+
-
+
+
+ One Time Password
+
+
+
+ -
+
+
+ Token:
+
+
+
+ -
+
+
+
+
+
PasswordField
QLineEdit
diff --git a/vpn/fortisslvpn/fortisslvpnwidget.cpp b/vpn/fortisslvpn/fortisslvpnwidget.cpp
index 9425870a..d3358dee 100644
--- a/vpn/fortisslvpn/fortisslvpnwidget.cpp
+++ b/vpn/fortisslvpn/fortisslvpnwidget.cpp
@@ -1,212 +1,222 @@
/*
Copyright 2017 Jan Grulich
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see .
*/
#include "fortisslvpnwidget.h"
#include "ui_fortisslvpn.h"
#include "ui_fortisslvpnadvanced.h"
#include "nm-fortisslvpn-service.h"
#include
#include
#include
class FortisslvpnWidgetPrivate
{
public:
Ui::FortisslvpnWidget ui;
Ui::FortisslvpnAdvancedWidget advUi;
NetworkManager::VpnSetting::Ptr setting;
QDialog *advancedDlg;
QWidget *advancedWid;
};
FortisslvpnWidget::FortisslvpnWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent, Qt::WindowFlags f)
: SettingWidget(setting, parent, f)
, d_ptr(new FortisslvpnWidgetPrivate)
{
Q_D(FortisslvpnWidget);
d->setting = setting;
d->ui.setupUi(this);
d->ui.password->setPasswordOptionsEnabled(true);
// Connect for setting check
watchChangedSetting();
// Connect for validity check
connect(d->ui.gateway, &QLineEdit::textChanged, this, &FortisslvpnWidget::slotWidgetChanged);
// Advanced configuration
connect(d->ui.advancedButton, &QPushButton::clicked, this, &FortisslvpnWidget::showAdvanced);
d->advancedDlg = new QDialog(this);
d->advancedWid = new QWidget(this);
d->advUi.setupUi(d->advancedWid);
QVBoxLayout * layout = new QVBoxLayout(d->advancedDlg);
layout->addWidget(d->advancedWid);
d->advancedDlg->setLayout(layout);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, d->advancedDlg);
connect(buttons, &QDialogButtonBox::accepted, d->advancedDlg, &QDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, d->advancedDlg, &QDialog::reject);
layout->addWidget(buttons);
KAcceleratorManager::manage(this);
if (setting && !setting->isNull()) {
loadConfig(setting);
}
}
FortisslvpnWidget::~FortisslvpnWidget()
{
delete d_ptr;
}
void FortisslvpnWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
{
Q_D(FortisslvpnWidget);
const NMStringMap data = d->setting->data();
const QString gateway = data.value(NM_FORTISSLVPN_KEY_GATEWAY);
if (!gateway.isEmpty()) {
d->ui.gateway->setText(gateway);
}
const QString username = data.value(NM_FORTISSLVPN_KEY_USER);
if (!username.isEmpty()) {
d->ui.username->setText(username);
}
const NetworkManager::Setting::SecretFlags passwordFlag = static_cast(data.value(NM_FORTISSLVPN_KEY_PASSWORD"-flags").toInt());
if (passwordFlag == NetworkManager::Setting::None) {
d->ui.password->setPasswordOption(PasswordField::StoreForAllUsers);
} else if (passwordFlag == NetworkManager::Setting::AgentOwned) {
d->ui.password->setPasswordOption(PasswordField::StoreForUser);
} else {
d->ui.password->setPasswordOption(PasswordField::AlwaysAsk);
}
const QString caCert = data.value(NM_FORTISSLVPN_KEY_CA);
if (!caCert.isEmpty()) {
d->ui.caCert->setText(caCert);
}
const QString userCert = data.value(NM_FORTISSLVPN_KEY_CERT);
if (!userCert.isEmpty()) {
d->ui.userCert->setText(userCert);
}
const QString userKey = data.value(NM_FORTISSLVPN_KEY_KEY);
if (!userKey.isEmpty()) {
d->ui.userKey->setText(userKey);
}
// From advanced dialog
const QString trustedCert = data.value(NM_FORTISSLVPN_KEY_TRUSTED_CERT);
if (!trustedCert.isEmpty()) {
d->advUi.trustedCert->setText(trustedCert);
}
+ if (!data.value(NM_FORTISSLVPN_KEY_OTP"-flags").isEmpty()) {
+ const NetworkManager::Setting::SecretFlags otpFlag = static_cast(data.value(NM_FORTISSLVPN_KEY_OTP"-flags").toInt());
+ if (otpFlag & NetworkManager::Setting::NotSaved) {
+ d->advUi.otp->setChecked(true);
+ }
+ }
loadSecrets(setting);
}
void FortisslvpnWidget::loadSecrets(const NetworkManager::Setting::Ptr &setting)
{
Q_D(FortisslvpnWidget);
NetworkManager::VpnSetting::Ptr vpnSetting = setting.staticCast();
if (vpnSetting) {
const NMStringMap secrets = vpnSetting->secrets();
const QString password = secrets.value(NM_FORTISSLVPN_KEY_PASSWORD);
if (!password.isEmpty()) {
d->ui.password->setText(password);
}
}
}
QVariantMap FortisslvpnWidget::setting() const
{
Q_D(const FortisslvpnWidget);
NetworkManager::VpnSetting setting;
setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_FORTISSLVPN));
NMStringMap data;
NMStringMap secrets;
data.insert(NM_FORTISSLVPN_KEY_GATEWAY, d->ui.gateway->text());
if (!d->ui.username->text().isEmpty()) {
data.insert(NM_FORTISSLVPN_KEY_USER, d->ui.username->text());
}
if (!d->ui.password->text().isEmpty()) {
secrets.insert(NM_FORTISSLVPN_KEY_PASSWORD, d->ui.password->text());
}
if (d->ui.password->passwordOption() == PasswordField::StoreForAllUsers) {
data.insert(NM_FORTISSLVPN_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::None));
} else if (d->ui.password->passwordOption() == PasswordField::StoreForUser) {
data.insert(NM_FORTISSLVPN_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned));
} else {
data.insert(NM_FORTISSLVPN_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved));
}
if (!d->ui.caCert->url().isEmpty()) {
data.insert(NM_FORTISSLVPN_KEY_CA, d->ui.caCert->url().toLocalFile());
}
if (!d->ui.userCert->url().isEmpty()) {
data.insert(NM_FORTISSLVPN_KEY_CERT, d->ui.userCert->url().toLocalFile());
}
if (!d->ui.userKey->url().isEmpty()) {
data.insert(NM_FORTISSLVPN_KEY_KEY, d->ui.userKey->url().toLocalFile());
}
// From advanced
if (!d->advUi.trustedCert->text().isEmpty()) {
data.insert(NM_FORTISSLVPN_KEY_TRUSTED_CERT, d->advUi.trustedCert->text());
}
+ if (d->advUi.otp->isChecked()) {
+ data.insert(QLatin1String(NM_FORTISSLVPN_KEY_OTP"-flags"), QString::number(NetworkManager::Setting::NotSaved));
+ }
+
setting.setData(data);
setting.setSecrets(secrets);
return setting.toMap();
}
void FortisslvpnWidget::showAdvanced()
{
Q_D(FortisslvpnWidget);
d->advancedDlg->show();
}
bool FortisslvpnWidget::isValid() const
{
Q_D(const FortisslvpnWidget);
return !d->ui.gateway->text().isEmpty();
}
diff --git a/vpn/fortisslvpn/nm-fortisslvpn-service.h b/vpn/fortisslvpn/nm-fortisslvpn-service.h
index 15930794..a5d05fe8 100644
--- a/vpn/fortisslvpn/nm-fortisslvpn-service.h
+++ b/vpn/fortisslvpn/nm-fortisslvpn-service.h
@@ -1,40 +1,41 @@
/* nm-fortisslvpn-service - SSLVPN integration with NetworkManager
*
* Lubomir Rintel
* Dan Williams
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 Red Hat, Inc.
* (C) Copyright 2015 Lubomir Rintel
*/
#ifndef __NM_FORTISSLVPN_SERVICE_H__
#define __NM_FORTISSLVPN_SERVICE_H__
/* For the NM <-> VPN plugin service */
#define NM_DBUS_SERVICE_FORTISSLVPN "org.freedesktop.NetworkManager.fortisslvpn"
#define NM_DBUS_INTERFACE_FORTISSLVPN "org.freedesktop.NetworkManager.fortisslvpn"
#define NM_DBUS_PATH_FORTISSLVPN "/org/freedesktop/NetworkManager/fortisslvpn"
#define NM_FORTISSLVPN_KEY_GATEWAY "gateway"
#define NM_FORTISSLVPN_KEY_USER "user"
#define NM_FORTISSLVPN_KEY_PASSWORD "password"
+#define NM_FORTISSLVPN_KEY_OTP "otp"
#define NM_FORTISSLVPN_KEY_CA "ca"
#define NM_FORTISSLVPN_KEY_CERT "cert"
#define NM_FORTISSLVPN_KEY_KEY "key"
#define NM_FORTISSLVPN_KEY_TRUSTED_CERT "trusted-cert"
#endif /* __NM_FORTISSLVPN_SERVICE_H__ */