Commit 78b78cf3 authored by Jan Grulich's avatar Jan Grulich

Add support for fortisslvpn

Summary:
This adds support for Fortigate SSL VPN which has been added recently to NM [1]. There is also a
bug 355079 opened for missing support.

[1] - https://blogs.gnome.org/lkundrak/2015/09/24/fortigate-ssl-vpn-support-added-to-networkmanager/

Reviewers: lvsouza, mbriza

Reviewed By: mbriza

Subscribers: mbriza, christiangonzalez, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6189
parent efd47367
include_directories(${CMAKE_SOURCE_DIR}/libs/editor/widgets)
add_subdirectory(fortisslvpn)
add_subdirectory(iodine)
add_subdirectory(l2tp)
add_subdirectory(openconnect)
......
add_definitions(-DTRANSLATION_DOMAIN=\"plasmanetworkmanagement_fortisslvpnui\")
set(fortisslvpn_SRCS
fortisslvpn.cpp
fortisslvpnwidget.cpp
fortisslvpnauth.cpp
)
ki18n_wrap_ui(fortisslvpn_SRCS fortisslvpn.ui fortisslvpnadvanced.ui fortisslvpnauth.ui)
add_library(plasmanetworkmanagement_fortisslvpnui ${fortisslvpn_SRCS})
kcoreaddons_desktop_to_json(plasmanetworkmanagement_fortisslvpnui plasmanetworkmanagement_fortisslvpnui.desktop)
target_link_libraries(plasmanetworkmanagement_fortisslvpnui
plasmanm_internal
plasmanm_editor
Qt5::Widgets
Qt5::Network
Qt5::DBus
KF5::NetworkManagerQt
KF5::Service
KF5::Completion
KF5::I18n
KF5::WidgetsAddons
KF5::KIOWidgets
KF5::CoreAddons
)
install(TARGETS plasmanetworkmanagement_fortisslvpnui DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasmanetworkmanagement_fortisslvpnui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
#! /usr/bin/env bash
$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_fortisslvpnui.pot
rm -f rc.cpp
/*
Copyright 2016 Jan Grulich <jgrulich@redhat.com>
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 <http://www.gnu.org/licenses/>.
*/
#include "fortisslvpn.h"
#include "fortisslvpnauth.h"
#include "fortisslvpnwidget.h"
#include <KPluginFactory>
K_PLUGIN_FACTORY_WITH_JSON(FortisslvpnUiPluginFactory, "plasmanetworkmanagement_fortisslvpnui.json", registerPlugin<FortisslvpnUiPlugin>(); )
FortisslvpnUiPlugin::FortisslvpnUiPlugin(QObject *parent, const QVariantList &)
: VpnUiPlugin(parent)
{
}
FortisslvpnUiPlugin::~FortisslvpnUiPlugin()
{
}
SettingWidget * FortisslvpnUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent)
{
return new FortisslvpnWidget(setting, parent);
}
SettingWidget * FortisslvpnUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent)
{
return new FortisslvpnAuthDialog(setting, parent);
}
QString FortisslvpnUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
{
Q_UNUSED(connection);
return QString();
}
QString FortisslvpnUiPlugin::supportedFileExtensions() const
{
return QString();
}
NMVariantMapMap FortisslvpnUiPlugin::importConnectionSettings(const QString &fileName)
{
Q_UNUSED(fileName);
// TODO : import the Fortisslvpn connection from file and return settings
mError = VpnUiPlugin::NotImplemented;
return NMVariantMapMap();
}
bool FortisslvpnUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
{
Q_UNUSED(connection);
Q_UNUSED(fileName);
// TODO : export Fortisslvpn connection to file
mError = VpnUiPlugin::NotImplemented;
return false;
}
#include "fortisslvpn.moc"
/*
Copyright 2017 Jan Grulich <jgrulich@redhat.com>
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 <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_NM_FORTISSLVPN_H
#define PLASMA_NM_FORTISSLVPN_H
#include "vpnuiplugin.h"
#include <QVariant>
class Q_DECL_EXPORT FortisslvpnUiPlugin : public VpnUiPlugin
{
Q_OBJECT
public:
explicit FortisslvpnUiPlugin(QObject *parent = nullptr, const QVariantList& = QVariantList());
virtual ~FortisslvpnUiPlugin();
SettingWidget *widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = 0) Q_DECL_OVERRIDE;
SettingWidget *askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = 0) Q_DECL_OVERRIDE;
QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const Q_DECL_OVERRIDE;
QString supportedFileExtensions() const Q_DECL_OVERRIDE;
NMVariantMapMap importConnectionSettings(const QString &fileName) Q_DECL_OVERRIDE;
bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName) Q_DECL_OVERRIDE;
};
#endif // PLASMA_NM_FORTISSLVPN_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FortisslvpnWidget</class>
<widget class="QWidget" name="FortisslvpnWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>390</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="3">
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="gatewayLabel">
<property name="text">
<string>Gateway:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="gateway">
<property name="toolTip">
<string>SSLVPN server IP or name.</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QGroupBox" name="authenticationGroupBox">
<property name="title">
<string>Authentication</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="usernameLabel">
<property name="text">
<string>User name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="username">
<property name="toolTip">
<string>Set the name used for authenticating the local system to the peer to &lt;name&gt;.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="PasswordField" name="password">
<property name="toolTip">
<string>Password passed to SSLVPN when prompted for it.</string>
</property>
<property name="passwordModeEnabled" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="caCertLabel">
<property name="text">
<string>CA Certificate:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KUrlRequester" name="caCert"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="userCertLabel">
<property name="text">
<string>User Certificate:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KUrlRequester" name="userCert"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="userKeyLabel">
<property name="text">
<string>User Key:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="KUrlRequester" name="userKey"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>314</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="advancedButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Advanced</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QWidget</extends>
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>PasswordField</class>
<extends>QLineEdit</extends>
<header>passwordfield.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FortisslvpnAdvancedWidget</class>
<widget class="QWidget" name="FortisslvpnAdvancedWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>410</width>
<height>110</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>100</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Security</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="trustedCertLabel">
<property name="text">
<string>Trusted certificate:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="trustedCert">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>0123456789abcdef0123456789abcdef0123456789abcdef0123456789</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*
Copyright 2016 Jan Grulich <jgrulich@redhat.com>
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 <http://www.gnu.org/licenses/>.
*/
#include "fortisslvpnauth.h"
#include "ui_fortisslvpnauth.h"
#include "nm-fortisslvpn-service.h"
#include <QString>
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);
d->ui.setupUi(this);
d->setting = setting;
KAcceleratorManager::manage(this);
}
FortisslvpnAuthDialog::~FortisslvpnAuthDialog()
{
delete d_ptr;
}
QVariantMap FortisslvpnAuthDialog::setting() const
{
Q_D(const FortisslvpnAuthDialog);
NMStringMap secrets;
QVariantMap secretData;
if (!d->ui.password->text().isEmpty()) {
secrets.insert(QLatin1String(NM_FORTISSLVPN_KEY_PASSWORD), d->ui.password->text());
}
secretData.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
return secretData;
}
/*
Copyright 2016 Jan Grulich <jgrulich@redhat.com>
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 <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_NM_FORTISSLVPN_AUTH_H
#define PLASMA_NM_FORTISSLVPN_AUTH_H
#include <NetworkManagerQt/VpnSetting>
#include "settingwidget.h"
class FortisslvpnAuthDialogPrivate;
class FortisslvpnAuthDialog : public SettingWidget
{
Q_OBJECT
Q_DECLARE_PRIVATE(FortisslvpnAuthDialog)
public:
explicit FortisslvpnAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = nullptr);
~FortisslvpnAuthDialog();
QVariantMap setting() const Q_DECL_OVERRIDE;
private:
FortisslvpnAuthDialogPrivate *const d_ptr;
};
#endif // PLASMA_NM_FORTISSLVPN_AUTH_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FortisslvpnAuth</class>
<widget class="QWidget" name="FortisslvpnAuth">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>408</width>
<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>le_password</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="PasswordField" name="password">
<property name="passwordModeEnabled" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PasswordField</class>
<extends>QLineEdit</extends>
<header>passwordfield.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
/*
Copyright 2017 Jan Grulich <jgrulich@redhat.com>
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 <http://www.gnu.org/licenses/>.
*/
#include "fortisslvpnwidget.h"
#include "ui_fortisslvpn.h"
#include "ui_fortisslvpnadvanced.h"
#include "nm-fortisslvpn-service.h"
#include <NetworkManagerQt/Setting>
#include <QDialog>
#include <QDialogButtonBox>
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);