diff options
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r-- | src/gui/dialogs/identity.c | 111 | ||||
-rw-r--r-- | src/gui/dialogs/identity.ui | 119 |
2 files changed, 163 insertions, 67 deletions
diff --git a/src/gui/dialogs/identity.c b/src/gui/dialogs/identity.c index 625c556..eae1069 100644 --- a/src/gui/dialogs/identity.c +++ b/src/gui/dialogs/identity.c @@ -24,19 +24,22 @@ #include "identity.h" +#include <malloc.h> #include <string.h> #include <i18n.h> +#include "../../analysis/db/auth.h" #include "../../analysis/db/certs.h" +#include "../../common/extstr.h" #include "../../core/logs.h" /* Applique la nouvelle définition d'identité. */ -static void update_identity(GtkButton *button, GtkBuilder *); +static void update_identity(GtkButton *, GtkBuilder *); @@ -57,8 +60,11 @@ GtkWidget *create_identity_dialog(GtkWindow *parent, GtkBuilder **outb) { GtkWidget *result; /* Fenêtre à renvoyer */ GtkBuilder *builder; /* Constructeur utilisé */ - x509_entries entries; /* Eléments identitaires */ + char *username; /* Nom par défaut */ GtkEntry *entry; /* Zone de saisie à initialiser*/ + char *filename; /* Fichier devant être présent */ + x509_entries identity; /* Eléments identitaires */ + bool status; /* Bilan d'un chargement */ builder = gtk_builder_new_from_resource("/org/chrysalide/gui/dialogs/identity.ui"); *outb = builder; @@ -67,47 +73,64 @@ GtkWidget *create_identity_dialog(GtkWindow *parent, GtkBuilder **outb) gtk_window_set_transient_for(GTK_WINDOW(result), parent); - /* Mise à jour de l'interface */ + username = get_default_username(); - memset(&entries, 0, sizeof(entries)); - //load_identity(true, &entries); + entry = GTK_ENTRY(gtk_builder_get_object(builder, "cn")); + gtk_entry_set_placeholder_text(entry, username); - if (entries.country != NULL) - { - entry = GTK_ENTRY(gtk_builder_get_object(builder, "c")); - gtk_entry_set_text(entry, entries.country); - } + free(username); - if (entries.state != NULL) - { - entry = GTK_ENTRY(gtk_builder_get_object(builder, "st")); - gtk_entry_set_text(entry, entries.state); - } + /* Mise à jour de l'interface */ - if (entries.locality != NULL) - { - entry = GTK_ENTRY(gtk_builder_get_object(builder, "l")); - gtk_entry_set_text(entry, entries.locality); - } + filename = get_db_working_directory("clients", NULL, NULL, NULL); + filename = stradd(filename, "client-csr.pem"); - if (entries.organisation != NULL) - { - entry = GTK_ENTRY(gtk_builder_get_object(builder, "o")); - gtk_entry_set_text(entry, entries.organisation); - } + status = load_identity_from_request(filename, &identity); - if (entries.organisational_unit != NULL) - { - entry = GTK_ENTRY(gtk_builder_get_object(builder, "ou")); - gtk_entry_set_text(entry, entries.organisational_unit); - } + free(filename); - if (entries.country != NULL) + if (status) { - entry = GTK_ENTRY(gtk_builder_get_object(builder, "cn")); - gtk_entry_set_text(entry, entries.common_name); - - gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1); + if (identity.country != NULL) + { + entry = GTK_ENTRY(gtk_builder_get_object(builder, "c")); + gtk_entry_set_text(entry, identity.country); + } + + if (identity.state != NULL) + { + entry = GTK_ENTRY(gtk_builder_get_object(builder, "st")); + gtk_entry_set_text(entry, identity.state); + } + + if (identity.locality != NULL) + { + entry = GTK_ENTRY(gtk_builder_get_object(builder, "l")); + gtk_entry_set_text(entry, identity.locality); + } + + if (identity.organisation != NULL) + { + entry = GTK_ENTRY(gtk_builder_get_object(builder, "o")); + gtk_entry_set_text(entry, identity.organisation); + } + + if (identity.organisational_unit != NULL) + { + entry = GTK_ENTRY(gtk_builder_get_object(builder, "ou")); + gtk_entry_set_text(entry, identity.organisational_unit); + } + + if (identity.common_name != NULL) + { + entry = GTK_ENTRY(gtk_builder_get_object(builder, "cn")); + gtk_entry_set_text(entry, identity.common_name); + + gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1); + + } + + free_x509_entries(&identity); } @@ -141,7 +164,7 @@ static void update_identity(GtkButton *button, GtkBuilder *builder) { GtkEntry *entry; /* Zone de saisie à consulter */ const gchar *data; /* Données internes à GTK */ - x509_entries entries; /* Nouvelle identité à pousser */ + x509_entries identity; /* Nouvelle identité à pousser */ bool status; /* Bilan de la mise à jour */ /* Récupération des éléments */ @@ -149,42 +172,42 @@ static void update_identity(GtkButton *button, GtkBuilder *builder) entry = GTK_ENTRY(gtk_builder_get_object(builder, "c")); data = gtk_entry_get_text(entry); - entries.country = (strlen(data) > 0 ? strdup(data) : NULL); + identity.country = (strlen(data) > 0 ? strdup(data) : NULL); entry = GTK_ENTRY(gtk_builder_get_object(builder, "st")); data = gtk_entry_get_text(entry); - entries.state = (strlen(data) > 0 ? strdup(data) : NULL); + identity.state = (strlen(data) > 0 ? strdup(data) : NULL); entry = GTK_ENTRY(gtk_builder_get_object(builder, "l")); data = gtk_entry_get_text(entry); - entries.locality = (strlen(data) > 0 ? strdup(data) : NULL); + identity.locality = (strlen(data) > 0 ? strdup(data) : NULL); entry = GTK_ENTRY(gtk_builder_get_object(builder, "o")); data = gtk_entry_get_text(entry); - entries.organisation = (strlen(data) > 0 ? strdup(data) : NULL); + identity.organisation = (strlen(data) > 0 ? strdup(data) : NULL); entry = GTK_ENTRY(gtk_builder_get_object(builder, "ou")); data = gtk_entry_get_text(entry); - entries.organisational_unit = (strlen(data) > 0 ? strdup(data) : NULL); + identity.organisational_unit = (strlen(data) > 0 ? strdup(data) : NULL); entry = GTK_ENTRY(gtk_builder_get_object(builder, "cn")); data = gtk_entry_get_text(entry); - entries.common_name = (strlen(data) > 0 ? strdup(data) : NULL); + identity.common_name = (strlen(data) > 0 ? strdup(data) : NULL); /* Application de la nouvelle définition */ status = false;//register_standalone_certs(&entries); - free_x509_entries(&entries); + free_x509_entries(&identity); if (status) log_simple_message(LMT_INFO, _("New identity has been loaded with success!")); else - log_simple_message(LMT_ERROR, _("Failure while loading the new identity...")); + log_simple_message(LMT_ERROR, _("Failure while reloading the new identity...")); } diff --git a/src/gui/dialogs/identity.ui b/src/gui/dialogs/identity.ui index 25d398f..413d7f6 100644 --- a/src/gui/dialogs/identity.ui +++ b/src/gui/dialogs/identity.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.21.0 --> +<!-- Generated with glade 3.22.1 --> <interface> <requires lib="gtk+" version="3.12"/> <object class="GtkDialog" id="window"> @@ -8,8 +8,12 @@ <property name="title" translatable="yes">Identity</property> <property name="modal">True</property> <property name="window_position">center-on-parent</property> - <property name="default_width">515</property> + <property name="default_width">520</property> + <property name="default_height">550</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -78,7 +82,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">1</property> + <property name="top_attach">2</property> <property name="width">2</property> </packing> </child> @@ -87,9 +91,7 @@ <property name="width_request">500</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">All the following information is used to create your authentication certifcate. This certificate grants you access to database servers and identifies each analysis change. - -<b>Warning: </b> updating this information drives to new signing requests for remote servers!</property> + <property name="label" translatable="yes">All the following information is used to create your authentication certifcates. These certificates grant you access to database servers and identify each analysis change.</property> <property name="use_markup">True</property> <property name="wrap">True</property> <property name="xalign">0</property> @@ -109,7 +111,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> </packing> </child> <child> @@ -122,7 +124,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> </packing> </child> <child> @@ -134,7 +136,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> <property name="width">2</property> </packing> </child> @@ -147,7 +149,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -157,7 +159,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -167,7 +169,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> </packing> </child> <child> @@ -179,7 +181,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> </packing> </child> <child> @@ -191,7 +193,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">6</property> + <property name="top_attach">7</property> <property name="width">2</property> </packing> </child> @@ -204,7 +206,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">7</property> + <property name="top_attach">8</property> </packing> </child> <child> @@ -214,7 +216,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">7</property> + <property name="top_attach">8</property> </packing> </child> <child> @@ -224,7 +226,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">8</property> + <property name="top_attach">9</property> </packing> </child> <child> @@ -236,7 +238,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">8</property> + <property name="top_attach">9</property> </packing> </child> <child> @@ -248,7 +250,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">9</property> + <property name="top_attach">10</property> </packing> </child> <child> @@ -258,7 +260,81 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">9</property> + <property name="top_attach">10</property> + </packing> + </child> + <child> + <object class="GtkFrame"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="left_padding">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Updating this information drives to new signing requests! Please contact the administrators of all the remote servers to update your accesses. + +The authorization for the internal server is updated automatically.</property> + <property name="wrap">True</property> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Warning</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkSeparator" id="separator2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">11</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Certificate validity period (in seconds):</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">12</property> + </packing> + </child> + <child> + <object class="GtkEntry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="placeholder_text" translatable="yes">94608000</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">12</property> </packing> </child> </object> @@ -274,8 +350,5 @@ <action-widget response="-6">button1</action-widget> <action-widget response="-10">button2</action-widget> </action-widgets> - <child> - <placeholder/> - </child> </object> </interface> |