Commit 60f7c2e9 authored by Enrique Melendez's avatar Enrique Melendez Committed by Jan Grulich
Browse files

Accept hints, display the input fields and set the label accordingly, update...

Accept hints, display the input fields and set the label accordingly, update secrets so that the 2fa secret can be used
parent a4f32094
......@@ -36,11 +36,22 @@
</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>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="otp">
<property name="text">
<string>Use a One-Time Password</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="tfa">
<property name="text">
<string>2FA</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
......@@ -46,6 +46,17 @@ FortisslvpnAuthDialog::FortisslvpnAuthDialog(const NetworkManager::VpnSetting::P
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);
const NetworkManager::Setting::SecretFlags passwordFlag = static_cast<NetworkManager::Setting::SecretFlags>(data.value(NM_FORTISSLVPN_KEY_PASSWORD"-flags").toInt());
d->ui.passwordFrame->setVisible(passwordFlag == NetworkManager::Setting::NotSaved);
const QString hint = data.value("hint");
if (!hint.isEmpty()){
const QString hintMsg = data.value("hint-msg");
d->ui.otpLabel->setText(hint);
d->ui.labelOtp->setText(hintMsg.section(":", -2));
d->ui.otpFrame->setVisible(true);
}
KAcceleratorManager::manage(this);
}
......@@ -73,6 +84,10 @@ QVariantMap FortisslvpnAuthDialog::setting() const
}
}
if (!data.value(NM_FORTISSLVPN_KEY_2FA"-flags").isEmpty()) {
secrets.insert(QLatin1String(NM_FORTISSLVPN_KEY_2FA), d->ui.otp->text());
}
secretData.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
return secretData;
}
......@@ -10,31 +10,40 @@
<height>136</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>password</cstring>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="passwordFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="PasswordField" name="password">
<property name="passwordModeEnabled" stdset="0">
<bool>true</bool>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>password</cstring>
</property>
</widget>
</item>
<item>
<widget class="PasswordField" name="password">
<property name="passwordModeEnabled" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item>
<widget class="QFrame" name="otpFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
......@@ -42,12 +51,12 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout_1">
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelOtp">
<property name="text">
<string>One Time Password</string>
</property>
......
......@@ -144,6 +144,13 @@ void FortisslvpnWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
}
}
if (!data.value(NM_FORTISSLVPN_KEY_2FA"-flags").isEmpty()) {
const NetworkManager::Setting::SecretFlags tfaFlag = static_cast<NetworkManager::Setting::SecretFlags>(data.value(NM_FORTISSLVPN_KEY_2FA"-flags").toInt());
if (tfaFlag & NetworkManager::Setting::AgentOwned) {
d->advUi.tfa->setChecked(true);
}
}
const QString realm = data.value(NM_FORTISSLVPN_KEY_REALM);
if (!realm.isEmpty()) {
d->advUi.realm->setText(realm);
......@@ -220,6 +227,13 @@ QVariantMap FortisslvpnWidget::setting() const
data.insert(QLatin1String(NM_FORTISSLVPN_KEY_OTP"-flags"), QString::number(NetworkManager::Setting::None));
}
if (d->advUi.tfa->isChecked()) {
data.insert(QLatin1String(NM_FORTISSLVPN_KEY_2FA"-flags"), QString::number(NetworkManager::Setting::AgentOwned));
data.insert(QLatin1String(NM_FORTISSLVPN_KEY_OTP"-flags"), QString::number(NetworkManager::Setting::None));
} else {
data.insert(QLatin1String(NM_FORTISSLVPN_KEY_2FA"-flags"), QString::number(NetworkManager::Setting::None));
}
if (!d->advUi.realm->text().isEmpty()) {
data.insert(NM_FORTISSLVPN_KEY_REALM, d->advUi.realm->text());
}
......
......@@ -33,6 +33,7 @@
#define NM_FORTISSLVPN_KEY_USER "user"
#define NM_FORTISSLVPN_KEY_PASSWORD "password"
#define NM_FORTISSLVPN_KEY_OTP "otp"
#define NM_FORTISSLVPN_KEY_2FA "2fa"
#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