[network-manager-openconnect] properties: Add new "Software Token" section to UI dialog
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openconnect] properties: Add new "Software Token" section to UI dialog
- Date: Mon, 15 Oct 2012 05:31:38 +0000 (UTC)
commit 135403cdbe99067ddab16ecf1e8d1f66f12d9623
Author: Kevin Cernekee <cernekee gmail com>
Date: Sat Oct 13 10:26:43 2012 -0700
properties: Add new "Software Token" section to UI dialog
This will save/restore two new parameters:
stoken_source: disabled, use ~/.stokenrc, or manual entry
stoken_string: the string used for manual token entry
properties/nm-openconnect-dialog.ui | 194 +++++++++++++++++++++++++++++++++++
properties/nm-openconnect.c | 122 +++++++++++++++++++++-
src/nm-openconnect-service.c | 2 +
src/nm-openconnect-service.h | 2 +
4 files changed, 318 insertions(+), 2 deletions(-)
---
diff --git a/properties/nm-openconnect-dialog.ui b/properties/nm-openconnect-dialog.ui
index fd12c17..26db4af 100644
--- a/properties/nm-openconnect-dialog.ui
+++ b/properties/nm-openconnect-dialog.ui
@@ -553,4 +553,198 @@
</packing>
</child>
</object>
+ <object class="GtkVBox" id="stoken_vbox">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label26">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Software Token Authentication</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment16">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+ <child>
+ <object class="GtkTable" id="table4">
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkAlignment" id="alignment7">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+ <child>
+ <object class="GtkComboBox" id="stoken_source">
+ <property name="visible">True</property>
+ <property name="model">stoken_source_list</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Token _Source:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">stoken_source</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="stoken_string_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Token St_ring:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">stoken_string</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ <property name="sensitive">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment9">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+ <child>
+ <object class="GtkTextView" id="stoken_string">
+ <property name="height-request">60</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="wrap_mode">char</property>
+ <property name="border_width">2</property>
+ <property name="accepts_tab">False</property>
+ <property name="sensitive">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <object class="GtkListStore" id="stoken_source_list">
+ <columns>
+ <!-- column-name legible -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Disabled</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Read from ~/.stokenrc</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Manually entered</col>
+ </row>
+ </data>
+ </object>
</interface>
diff --git a/properties/nm-openconnect.c b/properties/nm-openconnect.c
index 818ed98..32ccce3 100644
--- a/properties/nm-openconnect.c
+++ b/properties/nm-openconnect.c
@@ -165,6 +165,16 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
if (bval)
nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID, "yes");
+ /* Soft token source */
+ buf = g_key_file_get_string (keyfile, "openconnect", "StokenSource", NULL);
+ if (buf)
+ nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE, buf);
+
+ /* Soft token string */
+ buf = g_key_file_get_string (keyfile, "openconnect", "StokenString", NULL);
+ if (buf)
+ nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING, buf);
+
return connection;
}
@@ -185,6 +195,8 @@ export (NMVpnPluginUiInterface *iface,
const char *usercert = NULL;
const char *privkey = NULL;
gboolean pem_passphrase_fsid = FALSE;
+ const char *stoken_source = NULL;
+ const char *stoken_string = NULL;
gboolean success = FALSE;
FILE *f;
@@ -234,6 +246,14 @@ export (NMVpnPluginUiInterface *iface,
if (value && !strcmp (value, "yes"))
pem_passphrase_fsid = TRUE;
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE);
+ if (value && strlen (value))
+ stoken_source = value;
+
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING);
+ if (value && strlen (value))
+ stoken_string = value;
+
fprintf (f,
"[openconnect]\n"
"Description=%s\n"
@@ -244,7 +264,9 @@ export (NMVpnPluginUiInterface *iface,
"CSDWrapper=%s\n"
"UserCertificate=%s\n"
"PrivateKey=%s\n"
- "FSID=%s\n",
+ "FSID=%s\n"
+ "StokenSource=%s\n"
+ "StokenString=%s\n",
/* Description */ nm_setting_connection_get_id (s_con),
/* Host */ gateway,
/* CA Certificate */ cacert,
@@ -253,7 +275,9 @@ export (NMVpnPluginUiInterface *iface,
/* CSD Wrapper Script */ csd_wrapper ? csd_wrapper : "",
/* User Certificate */ usercert,
/* Private Key */ privkey,
- /* FSID */ pem_passphrase_fsid ? "1" : "0");
+ /* FSID */ pem_passphrase_fsid ? "1" : "0",
+ /* Soft token source */ stoken_source ? stoken_source : "",
+ /* Soft token string */ stoken_string ? stoken_string : "");
success = TRUE;
@@ -338,6 +362,52 @@ stuff_changed_cb (GtkWidget *widget, gpointer user_data)
}
static gboolean
+init_stoken_ui (OpenconnectPluginUiWidget *self,
+ OpenconnectPluginUiWidgetPrivate *priv,
+ NMSettingVPN *s_vpn)
+{
+ GtkWidget *widget;
+ GtkTextBuffer *buffer;
+ const char *value;
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_vbox"));
+ if (!widget)
+ return FALSE;
+ gtk_box_pack_start (GTK_BOX (priv->widget), widget, FALSE, FALSE, 0);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_source"));
+ if (!widget)
+ return FALSE;
+ if (s_vpn) {
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE);
+ if (value) {
+ if (!strcmp (value, "stokenrc"))
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
+ else if (!strcmp (value, "manual"))
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
+ else
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ }
+ }
+ g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_string"));
+ if (!widget)
+ return FALSE;
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
+ if (!buffer)
+ return FALSE;
+ if (s_vpn) {
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING);
+ if (value)
+ gtk_text_buffer_set_text (buffer, value, -1);
+ }
+ g_signal_connect (G_OBJECT (buffer), "changed", G_CALLBACK (stuff_changed_cb), self);
+
+ return TRUE;
+}
+
+static gboolean
init_plugin_ui (OpenconnectPluginUiWidget *self, NMConnection *connection, GError **error)
{
OpenconnectPluginUiWidgetPrivate *priv = OPENCONNECT_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
@@ -401,6 +471,9 @@ init_plugin_ui (OpenconnectPluginUiWidget *self, NMConnection *connection, GErro
}
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
+ if (init_stoken_ui (self, priv, s_vpn) == FALSE)
+ return FALSE;
+
tls_pw_init_auth_widget (priv->builder, priv->group, s_vpn, stuff_changed_cb, self);
return TRUE;
@@ -425,6 +498,10 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
NMSettingVPN *s_vpn;
GtkWidget *widget;
char *str;
+ gint idx;
+ gboolean stoken_string_editable = FALSE;
+ GtkTextIter iter_start, iter_end;
+ GtkTextBuffer *buffer;
const char *auth_type = NULL;
if (!check_validity (self, error))
@@ -456,6 +533,47 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
if (str && strlen (str))
nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_CSD_WRAPPER, str);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_source"));
+ idx = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+ str = NULL;
+ switch (idx) {
+ case 0:
+ str = "disabled";
+ break;
+ case 1:
+ str = "stokenrc";
+ break;
+ case 2:
+ str = "manual";
+ stoken_string_editable = TRUE;
+ break;
+ }
+ if (str)
+ nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_SOURCE, str);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_string_label"));
+ gtk_widget_set_sensitive (widget, stoken_string_editable);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stoken_string"));
+ gtk_widget_set_sensitive (widget, stoken_string_editable);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
+ gtk_text_buffer_get_start_iter (buffer, &iter_start);
+ gtk_text_buffer_get_end_iter (buffer, &iter_end);
+ str = (char *) gtk_text_buffer_get_text (buffer, &iter_start, &iter_end, TRUE);
+ if (str) {
+ char *src = str, *dst = str;
+
+ /* zap invalid characters */
+ for (; *src; src++)
+ if ((*src >= '0' && *src <= '9') || *src == '-')
+ *(dst++) = *src;
+ *dst = 0;
+
+ if (strlen (str))
+ nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_STOKEN_STRING, str);
+ }
+
/* These are different for every login session, and should not be stored */
nm_setting_set_secret_flags (NM_SETTING (s_vpn), "gwcert",
NM_SETTING_SECRET_FLAG_NOT_SAVED, NULL);
diff --git a/src/nm-openconnect-service.c b/src/nm-openconnect-service.c
index 90e6b92..ef60754 100644
--- a/src/nm-openconnect-service.c
+++ b/src/nm-openconnect-service.c
@@ -86,6 +86,8 @@ static ValidProperty valid_properties[] = {
{ NM_OPENCONNECT_KEY_PROXY, G_TYPE_STRING, 0, 0 },
{ NM_OPENCONNECT_KEY_CSD_ENABLE, G_TYPE_BOOLEAN, 0, 0 },
{ NM_OPENCONNECT_KEY_CSD_WRAPPER, G_TYPE_STRING, 0, 0 },
+ { NM_OPENCONNECT_KEY_STOKEN_SOURCE, G_TYPE_STRING, 0, 0 },
+ { NM_OPENCONNECT_KEY_STOKEN_STRING, G_TYPE_STRING, 0, 0 },
{ NULL, G_TYPE_NONE, 0, 0 }
};
diff --git a/src/nm-openconnect-service.h b/src/nm-openconnect-service.h
index cde3bd6..f54c829 100644
--- a/src/nm-openconnect-service.h
+++ b/src/nm-openconnect-service.h
@@ -51,6 +51,8 @@
#define NM_OPENCONNECT_KEY_PROXY "proxy"
#define NM_OPENCONNECT_KEY_CSD_ENABLE "enable_csd_trojan"
#define NM_OPENCONNECT_KEY_CSD_WRAPPER "csd_wrapper"
+#define NM_OPENCONNECT_KEY_STOKEN_SOURCE "stoken_source"
+#define NM_OPENCONNECT_KEY_STOKEN_STRING "stoken_string"
typedef struct {
NMVPNPlugin parent;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]