Commit dffde78fabad52702978236cadb8f389d1b2c039
1 parent
d86178f1
Exists in
master
and in
1 other branch
Adding certificate information in security dialog.
Showing
7 changed files
with
235 additions
and
77 deletions
Show diff stats
@@ -0,0 +1,205 @@ | @@ -0,0 +1,205 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como - e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + */ | ||
29 | + | ||
30 | + #include <config.h> | ||
31 | + | ||
32 | + #define ENABLE_NLS | ||
33 | + #define GETTEXT_PACKAGE PACKAGE_NAME | ||
34 | + | ||
35 | + #include <gtk/gtk.h> | ||
36 | + #include <libintl.h> | ||
37 | + #include <glib/gi18n.h> | ||
38 | + | ||
39 | + #include <v3270.h> | ||
40 | + | ||
41 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
42 | + | ||
43 | + static GtkWidget * label_new(const char *text) | ||
44 | + { | ||
45 | + GtkWidget *widget = gtk_label_new(text); | ||
46 | + gtk_label_set_xalign(GTK_LABEL(widget),0); | ||
47 | + return widget; | ||
48 | + } | ||
49 | + | ||
50 | + static GtkWidget * text_view_new(const char *contents) | ||
51 | + { | ||
52 | + GtkWidget * container = gtk_scrolled_window_new(NULL,NULL); | ||
53 | + GtkWidget * view = gtk_text_view_new(); | ||
54 | + | ||
55 | + gtk_container_set_border_width(GTK_CONTAINER(container),5); | ||
56 | + gtk_container_set_border_width(GTK_CONTAINER(view),5); | ||
57 | + | ||
58 | + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(container),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | ||
59 | + | ||
60 | + gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE); | ||
61 | + | ||
62 | + GtkTextIter itr; | ||
63 | + GtkTextBuffer * text = GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view))); | ||
64 | + | ||
65 | + gtk_text_buffer_get_end_iter(text,&itr); | ||
66 | + gtk_text_buffer_insert(text,&itr,contents,strlen(contents)); | ||
67 | + | ||
68 | + gtk_container_add(GTK_CONTAINER(container),view); | ||
69 | + gtk_text_view_set_monospace(GTK_TEXT_VIEW(view),TRUE); | ||
70 | + | ||
71 | + return container; | ||
72 | + } | ||
73 | + | ||
74 | + LIB3270_EXPORT GtkWidget * v3270_security_dialog_new(GtkWidget *widget) | ||
75 | + { | ||
76 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | ||
77 | + gtk_container_set_border_width(GTK_CONTAINER(grid),10); | ||
78 | + gtk_grid_set_row_spacing(grid,5); | ||
79 | + gtk_grid_set_column_spacing(grid,5); | ||
80 | + | ||
81 | + H3270 *hSession = NULL; | ||
82 | + | ||
83 | + if(GTK_IS_V3270(widget)) | ||
84 | + hSession = v3270_get_session(widget); | ||
85 | + | ||
86 | + if(hSession) | ||
87 | + { | ||
88 | + gtk_grid_attach( | ||
89 | + grid, | ||
90 | + gtk_image_new_from_icon_name(lib3270_get_ssl_state_icon_name(hSession),GTK_ICON_SIZE_DIALOG), | ||
91 | + 0,0, | ||
92 | + 2,2 | ||
93 | + ); | ||
94 | + | ||
95 | + gtk_grid_attach( | ||
96 | + grid, | ||
97 | + label_new((lib3270_get_ssl_state_message(hSession))), | ||
98 | + 3,0, | ||
99 | + 6,1 | ||
100 | + ); | ||
101 | + | ||
102 | + gtk_grid_attach( | ||
103 | + grid, | ||
104 | + label_new(lib3270_get_ssl_state_description(hSession)), | ||
105 | + 3,1, | ||
106 | + 6,1 | ||
107 | + ); | ||
108 | + | ||
109 | + lib3270_autoptr(char) crl = lib3270_get_ssl_crl_text(hSession); | ||
110 | + lib3270_autoptr(char) peer = lib3270_get_ssl_peer_certificate_text(hSession); | ||
111 | + | ||
112 | + if(peer && crl) | ||
113 | + { | ||
114 | + GtkWidget * frame = gtk_notebook_new(); | ||
115 | + | ||
116 | + gtk_widget_set_hexpand(GTK_WIDGET(frame),TRUE); | ||
117 | + gtk_widget_set_vexpand(GTK_WIDGET(frame),TRUE); | ||
118 | + | ||
119 | + gtk_notebook_append_page( | ||
120 | + GTK_NOTEBOOK(frame), | ||
121 | + text_view_new(peer), | ||
122 | + gtk_label_new(_("Peer certificate")) | ||
123 | + ); | ||
124 | + | ||
125 | + gtk_notebook_append_page( | ||
126 | + GTK_NOTEBOOK(frame), | ||
127 | + text_view_new(crl), | ||
128 | + gtk_label_new(_("Revocation list")) | ||
129 | + ); | ||
130 | + | ||
131 | + gtk_grid_attach( | ||
132 | + grid, | ||
133 | + frame, | ||
134 | + 3,2, | ||
135 | + 6,6 | ||
136 | + ); | ||
137 | + | ||
138 | + } | ||
139 | + else if(peer) | ||
140 | + { | ||
141 | + GtkWidget * frame = gtk_frame_new(_("Peer certificate")); | ||
142 | + gtk_container_add(GTK_CONTAINER(frame),text_view_new(peer)); | ||
143 | + | ||
144 | + gtk_widget_set_hexpand(GTK_WIDGET(frame),TRUE); | ||
145 | + gtk_widget_set_vexpand(GTK_WIDGET(frame),TRUE); | ||
146 | + | ||
147 | + gtk_grid_attach( | ||
148 | + grid, | ||
149 | + frame, | ||
150 | + 3,2, | ||
151 | + 6,6 | ||
152 | + ); | ||
153 | + | ||
154 | + | ||
155 | + } | ||
156 | + | ||
157 | + } | ||
158 | + else | ||
159 | + { | ||
160 | + | ||
161 | + gtk_grid_attach( | ||
162 | + grid, | ||
163 | + gtk_image_new_from_icon_name("dialog-error",GTK_ICON_SIZE_DIALOG), | ||
164 | + 0,0, | ||
165 | + 2,2 | ||
166 | + ); | ||
167 | + | ||
168 | + gtk_grid_attach( | ||
169 | + grid, | ||
170 | + label_new(_("Invalid state")), | ||
171 | + 3,0, | ||
172 | + 6,1 | ||
173 | + ); | ||
174 | + | ||
175 | + gtk_grid_attach( | ||
176 | + grid, | ||
177 | + label_new(_("There's no security information in the session")), | ||
178 | + 3,1, | ||
179 | + 6,1 | ||
180 | + ); | ||
181 | + } | ||
182 | + | ||
183 | + return GTK_WIDGET(grid); | ||
184 | + } | ||
185 | + | ||
186 | + LIB3270_EXPORT void v3270_popup_security_dialog(GtkWidget *widget) | ||
187 | + { | ||
188 | + GtkWidget * dialog = gtk_dialog_new_with_buttons( | ||
189 | + _("About security"), | ||
190 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | ||
191 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | ||
192 | + _( "_Close" ), GTK_RESPONSE_ACCEPT, | ||
193 | + NULL | ||
194 | + ); | ||
195 | + | ||
196 | + gtk_window_set_default_size(GTK_WINDOW(dialog), 800, 500); | ||
197 | + | ||
198 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),v3270_security_dialog_new(widget),TRUE,TRUE,2); | ||
199 | + gtk_widget_show_all(dialog); | ||
200 | + | ||
201 | + gtk_dialog_run(GTK_DIALOG(dialog)); | ||
202 | + gtk_widget_destroy(GTK_WIDGET(dialog)); | ||
203 | + | ||
204 | + | ||
205 | + } |
src/include/v3270.h
@@ -252,6 +252,7 @@ | @@ -252,6 +252,7 @@ | ||
252 | LIB3270_EXPORT const gchar * v3270_get_ssl_status_icon(GtkWidget *widget); | 252 | LIB3270_EXPORT const gchar * v3270_get_ssl_status_icon(GtkWidget *widget); |
253 | LIB3270_EXPORT const gchar * v3270_get_ssl_status_text(GtkWidget *widget); | 253 | LIB3270_EXPORT const gchar * v3270_get_ssl_status_text(GtkWidget *widget); |
254 | LIB3270_EXPORT const gchar * v3270_get_ssl_status_message(GtkWidget *widget); | 254 | LIB3270_EXPORT const gchar * v3270_get_ssl_status_message(GtkWidget *widget); |
255 | + LIB3270_EXPORT GtkWidget * v3270_security_dialog_new(GtkWidget *widget); | ||
255 | LIB3270_EXPORT void v3270_popup_security_dialog(GtkWidget *widget); | 256 | LIB3270_EXPORT void v3270_popup_security_dialog(GtkWidget *widget); |
256 | 257 | ||
257 | // File transfer | 258 | // File transfer |
src/testprogram/testprogram.c
@@ -83,6 +83,24 @@ static gboolean popup_menu(GtkWidget *widget, G_GNUC_UNUSED gboolean selected, g | @@ -83,6 +83,24 @@ static gboolean popup_menu(GtkWidget *widget, G_GNUC_UNUSED gboolean selected, g | ||
83 | 83 | ||
84 | } | 84 | } |
85 | 85 | ||
86 | + static gboolean field_clicked(GtkWidget *widget, gboolean connected, V3270_OIA_FIELD field, GdkEventButton *event, GtkWidget *window) | ||
87 | + { | ||
88 | + trace("%s: %s field=%d event=%p window=%p",__FUNCTION__,connected ? "Connected" : "Disconnected", field, event, window); | ||
89 | + | ||
90 | + if(!connected) | ||
91 | + return FALSE; | ||
92 | + | ||
93 | + if(field == V3270_OIA_SSL) | ||
94 | + { | ||
95 | + v3270_popup_security_dialog(widget); | ||
96 | + trace("%s: Show SSL connection info dialog",__FUNCTION__); | ||
97 | + return TRUE; | ||
98 | + } | ||
99 | + | ||
100 | + | ||
101 | + return FALSE; | ||
102 | + } | ||
103 | + | ||
86 | static void trace_window_destroy(G_GNUC_UNUSED GtkWidget *widget, H3270 *hSession) { | 104 | static void trace_window_destroy(G_GNUC_UNUSED GtkWidget *widget, H3270 *hSession) { |
87 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_DS_TRACE,0); | 105 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_DS_TRACE,0); |
88 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0); | 106 | lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0); |
@@ -129,6 +147,8 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | @@ -129,6 +147,8 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | ||
129 | // gchar * filename = NULL; | 147 | // gchar * filename = NULL; |
130 | GValue val = G_VALUE_INIT; | 148 | GValue val = G_VALUE_INIT; |
131 | 149 | ||
150 | + g_signal_connect(terminal,"field_clicked",G_CALLBACK(field_clicked),window); | ||
151 | + | ||
132 | GtkWidget *trace = v3270_new_trace_window(terminal,NULL); | 152 | GtkWidget *trace = v3270_new_trace_window(terminal,NULL); |
133 | if(trace) { | 153 | if(trace) { |
134 | g_signal_connect(trace, "destroy", G_CALLBACK(trace_window_destroy), v3270_get_session(terminal)); | 154 | g_signal_connect(trace, "destroy", G_CALLBACK(trace_window_destroy), v3270_get_session(terminal)); |
src/trace/trace.c
@@ -459,7 +459,6 @@ static void destroy(GtkWidget *widget) | @@ -459,7 +459,6 @@ static void destroy(GtkWidget *widget) | ||
459 | static void append_text(v3270_trace *hwnd, const gchar *text) | 459 | static void append_text(v3270_trace *hwnd, const gchar *text) |
460 | { | 460 | { |
461 | GtkTextIter itr; | 461 | GtkTextIter itr; |
462 | - | ||
463 | gtk_text_buffer_get_end_iter(hwnd->text,&itr); | 462 | gtk_text_buffer_get_end_iter(hwnd->text,&itr); |
464 | 463 | ||
465 | if(g_utf8_validate(text,strlen(text),NULL)) | 464 | if(g_utf8_validate(text,strlen(text),NULL)) |
src/v3270/font.c
@@ -40,7 +40,11 @@ | @@ -40,7 +40,11 @@ | ||
40 | 40 | ||
41 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 41 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
42 | 42 | ||
43 | +#ifdef _WIN32 | ||
44 | + const gchar * v3270_default_font = "Lucida Console"; | ||
45 | +#else | ||
43 | const gchar * v3270_default_font = "monospace"; | 46 | const gchar * v3270_default_font = "monospace"; |
47 | +#endif // _WIN32 | ||
44 | 48 | ||
45 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 49 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
46 | 50 |
src/v3270/security.c
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin |
19 | * St, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | * | 20 | * |
21 | - * Este programa está nomeado como secoruty.c e possui - linhas de código. | 21 | + * Este programa está nomeado como - e possui - linhas de código. |
22 | * | 22 | * |
23 | * Contatos: | 23 | * Contatos: |
24 | * | 24 | * |
@@ -296,7 +296,7 @@ | @@ -296,7 +296,7 @@ | ||
296 | return NULL; | 296 | return NULL; |
297 | } | 297 | } |
298 | 298 | ||
299 | - const gchar * v3270_get_ssl_status_icon(GtkWidget *widget) | 299 | + const gchar * v3270_get_ssl_status_icon(GtkWidget *widget) |
300 | { | 300 | { |
301 | g_return_val_if_fail(GTK_IS_V3270(widget),""); | 301 | g_return_val_if_fail(GTK_IS_V3270(widget),""); |
302 | 302 | ||
@@ -354,77 +354,3 @@ | @@ -354,77 +354,3 @@ | ||
354 | return _( "Unexpected or unknown security status"); | 354 | return _( "Unexpected or unknown security status"); |
355 | } | 355 | } |
356 | 356 | ||
357 | - LIB3270_EXPORT void v3270_popup_security_dialog(GtkWidget *widget) | ||
358 | - { | ||
359 | - GtkWidget * dialog; | ||
360 | - | ||
361 | - g_return_if_fail(GTK_IS_V3270(widget)); | ||
362 | - | ||
363 | - gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[GTK_V3270(widget)->pointer]); | ||
364 | - | ||
365 | - | ||
366 | -#ifdef HAVE_LIBSSL | ||
367 | - if(lib3270_get_secure(GTK_V3270(widget)->host) == LIB3270_SSL_UNSECURE) | ||
368 | -#endif // HAVE_LIBSSL | ||
369 | - { | ||
370 | - // Connection is insecure, show simple dialog with host and info | ||
371 | - | ||
372 | - dialog = gtk_message_dialog_new( | ||
373 | - GTK_WINDOW(gtk_widget_get_toplevel(widget)), | ||
374 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | ||
375 | - GTK_MESSAGE_INFO, | ||
376 | - GTK_BUTTONS_CLOSE, | ||
377 | - "%s",v3270_get_hostname(widget) | ||
378 | - ); | ||
379 | - | ||
380 | - gtk_message_dialog_format_secondary_markup( | ||
381 | - GTK_MESSAGE_DIALOG(dialog), | ||
382 | - "%s", _( "<b>Identity not verified</b>\nThe connection is insecure" )); | ||
383 | - | ||
384 | - } | ||
385 | -#ifdef HAVE_LIBSSL | ||
386 | - else | ||
387 | - { | ||
388 | - long id = lib3270_get_SSL_verify_result(GTK_V3270(widget)->host); | ||
389 | - const gchar * title = N_( "Unexpected SSL error"); | ||
390 | - const gchar * text = NULL; | ||
391 | - const gchar * icon = GTK_STOCK_DIALOG_ERROR; | ||
392 | - int f; | ||
393 | - | ||
394 | - for(f=0;ssl_status_msg[f].text;f++) | ||
395 | - { | ||
396 | - if(ssl_status_msg[f].id == id) | ||
397 | - { | ||
398 | - title = ssl_status_msg[f].text; | ||
399 | - icon = ssl_status_msg[f].icon; | ||
400 | - text = ssl_status_msg[f].message; | ||
401 | - break; | ||
402 | - } | ||
403 | - } | ||
404 | - | ||
405 | - dialog = gtk_message_dialog_new( | ||
406 | - GTK_WINDOW(gtk_widget_get_toplevel(widget)), | ||
407 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | ||
408 | - GTK_MESSAGE_OTHER, | ||
409 | - GTK_BUTTONS_CLOSE, | ||
410 | - "%s",gettext(title) | ||
411 | - ); | ||
412 | - | ||
413 | - gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog),gtk_image_new_from_stock(icon,GTK_ICON_SIZE_DIALOG)); | ||
414 | - | ||
415 | - if(text) | ||
416 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), "%s", gettext(text)); | ||
417 | - else | ||
418 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),_( "Unexpected SSL error <b>%ld</b>" ),id); | ||
419 | - | ||
420 | - } | ||
421 | -#endif // HAVE_LIBSSL | ||
422 | - | ||
423 | - gtk_window_set_title(GTK_WINDOW(dialog),_("About security")); | ||
424 | - | ||
425 | - gtk_widget_show_all(GTK_WIDGET(dialog)); | ||
426 | - gtk_dialog_run(GTK_DIALOG(dialog)); | ||
427 | - gtk_widget_destroy(GTK_WIDGET(dialog)); | ||
428 | - | ||
429 | - | ||
430 | - } |
v3270.cbp
@@ -52,6 +52,9 @@ | @@ -52,6 +52,9 @@ | ||
52 | <Option compilerVar="CC" /> | 52 | <Option compilerVar="CC" /> |
53 | </Unit> | 53 | </Unit> |
54 | <Unit filename="src/dialogs/private.h" /> | 54 | <Unit filename="src/dialogs/private.h" /> |
55 | + <Unit filename="src/dialogs/security.c"> | ||
56 | + <Option compilerVar="CC" /> | ||
57 | + </Unit> | ||
55 | <Unit filename="src/include/config.h" /> | 58 | <Unit filename="src/include/config.h" /> |
56 | <Unit filename="src/include/config.h.in" /> | 59 | <Unit filename="src/include/config.h.in" /> |
57 | <Unit filename="src/include/hostselect.h" /> | 60 | <Unit filename="src/include/hostselect.h" /> |