Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b8f580a7 authored by Enrique Melendez's avatar Enrique Melendez Committed by Jan Grulich

Allow the use of One-Time Password

Summary:
NetworkManager-fortisslvpn allows the user to use a One-Time Password challenge, but this option has not been included in the plasma applet. This change makes allowance for that setting, changing the "Advanced" config dialog to include a checkBox to that effect.

The layout has been taken from the NetworkManager "Advanced" config dialog.

The change has been tested for writing to and reading from the config file, but should still be fully tested

Reviewers: jgrulich

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D17834
parent 7c6ccc74
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>410</width>
<height>110</height>
<width>400</width>
<height>175</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -24,6 +24,28 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Autentication</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="otp">
<property name="text">
<string>Use a One-Time Password</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
......@@ -58,7 +80,7 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
......@@ -37,9 +37,15 @@ FortisslvpnAuthDialog::FortisslvpnAuthDialog(const NetworkManager::VpnSetting::P
, 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<NetworkManager::Setting::SecretFlags>(data.value(NM_FORTISSLVPN_KEY_OTP"-flags").toInt());
d->ui.otpFrame->setVisible(otpFlag == NetworkManager::Setting::NotSaved);
KAcceleratorManager::manage(this);
}
......@@ -52,6 +58,7 @@ QVariantMap FortisslvpnAuthDialog::setting() const
{
Q_D(const FortisslvpnAuthDialog);
const NMStringMap data = d->setting->data();
NMStringMap secrets;
QVariantMap secretData;
......@@ -59,6 +66,13 @@ QVariantMap FortisslvpnAuthDialog::setting() const
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<NetworkManager::Setting::SecretFlags>(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<NMStringMap>(secrets));
return secretData;
}
......@@ -34,6 +34,38 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QFrame" name="otpFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout_1">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>One Time Password</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="otpLabel">
<property name="text">
<string>Token:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="PasswordField" name="otp"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
......@@ -128,6 +128,12 @@ void FortisslvpnWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
d->advUi.trustedCert->setText(trustedCert);
}
if (!data.value(NM_FORTISSLVPN_KEY_OTP"-flags").isEmpty()) {
const NetworkManager::Setting::SecretFlags otpFlag = static_cast<NetworkManager::Setting::SecretFlags>(data.value(NM_FORTISSLVPN_KEY_OTP"-flags").toInt());
if (otpFlag & NetworkManager::Setting::NotSaved) {
d->advUi.otp->setChecked(true);
}
}
loadSecrets(setting);
}
......@@ -191,6 +197,10 @@ QVariantMap FortisslvpnWidget::setting() const
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);
......
......@@ -32,6 +32,7 @@
#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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment