[Inteproxy-commits] r281 - in trunk: . inteproxy po
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Oct 11 10:22:08 CEST 2010
Author: iweinzierl
Date: 2010-10-11 10:22:07 +0200 (Mon, 11 Oct 2010)
New Revision: 281
Added:
trunk/inteproxy/certificatedialog.py
Modified:
trunk/ChangeLog
trunk/inteproxy/app.py
trunk/inteproxy/gtkapp.py
trunk/po/de.po
Log:
Added a idalog for showing errors/warnings that occured while certificate validation.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-30 10:11:14 UTC (rev 280)
+++ trunk/ChangeLog 2010-10-11 08:22:07 UTC (rev 281)
@@ -1,3 +1,16 @@
+2010-10-11 Ingo Weinzierl <ingo.weinzierl at intevation.de>
+
+ * inteproxy/certificatedialog.py: New module to handle errors/warnings
+ that occured while certificate validation.
+
+ * inteproxy/app.py: New abstract method 'run_certificate_dialog'.
+
+ * inteproxy/gtkapp.py: Implementation of 'run_certificate_dialog' -
+ displays a popup window showing an error/warning. The user needs to
+ accept or reject the requested action in the popup.
+
+ * po/de.po: String, used in the certificate dialog.
+
2010-09-30 Bjoern Schilberg <bjoern.schilberg at intevation.de>
* create-rewrite-rules.py: Adapt delimiter in substitution_rule to be
Modified: trunk/inteproxy/app.py
===================================================================
--- trunk/inteproxy/app.py 2010-09-30 10:11:14 UTC (rev 280)
+++ trunk/inteproxy/app.py 2010-10-11 08:22:07 UTC (rev 281)
@@ -86,3 +86,15 @@
default implementation only raises NotImplementedError.
"""
raise NotImplementedError
+
+ def run_certificate_dialog(self, title, content):
+ """Callback to run the certificate dialog.
+
+ The parameters are string with the title of the dialog, content contains
+ some information about the failure the occured while certificate
+ validation.
+
+ This method has to be implementation by derived classes. The default
+ implementation only raise NotImplementedError.
+ """
+ raise NotImplementedError
Added: trunk/inteproxy/certificatedialog.py
===================================================================
--- trunk/inteproxy/certificatedialog.py 2010-09-30 10:11:14 UTC (rev 280)
+++ trunk/inteproxy/certificatedialog.py 2010-10-11 08:22:07 UTC (rev 281)
@@ -0,0 +1,37 @@
+# Copyright (C) 2010 by Intevation GmbH
+# Authors:
+# Ingo Weinzierl <ingo.weinzierl at intevation.de>
+#
+# This program is free software under the GPL (>=v2)
+# Read the file COPYING coming with the software for details.
+
+"""Certificate validation failure processing"""
+
+import inteproxy.main
+from inteproxy.resources import gettext as _
+
+
+# keep track of the URLs for which the dialog was already shown.
+dialog_shown_for = dict()
+
+def handle_certificate_validation_error(remote_url):
+ """This function might be called if an error occured while validating
+ certificates.
+
+ After calling this function, a dialog is opened to inform the user about the
+ validation failure. title and content of this dialog are currently static
+ string. The dialog gives users the choice to accept or reject the
+ connection to the remote server. remote_url is used to cache the choice for
+ the time InteProxy is running to avoid showing the dialog twice for the same
+ connection."""
+ title = _("InteProxy: This connection is untrusted.")
+ content = _("The certificate validation failed.")
+
+ if remote_url in dialog_shown_for:
+ return dialog_shown_for[remote_url]
+
+ accepted = inteproxy.main.the_application.run_certificate_dialog(title,
+ content)
+ dialog_shown_for[remote_url] = accepted
+ return accepted
+
Modified: trunk/inteproxy/gtkapp.py
===================================================================
--- trunk/inteproxy/gtkapp.py 2010-09-30 10:11:14 UTC (rev 280)
+++ trunk/inteproxy/gtkapp.py 2010-10-11 08:22:07 UTC (rev 281)
@@ -161,7 +161,56 @@
gtk.main_iteration_do()
+def run_certificate_dialog(title, content):
+ """Shows failures that occured while validating certificates in a
+ dialog.
+ title and content both should be strings. The title should inform about the
+ failure in general, content should contain more technical detail about the
+ failure. Finally, the user has the choice to accept or reject the
+ certificate."""
+
+ dialog = gtk.Dialog(title, None,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
+ gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
+ dialog.set_size_request(320, 240)
+
+ sw = gtk.ScrolledWindow()
+ dialog.vbox.pack_start(sw)
+ sw.set_shadow_type(gtk.SHADOW_NONE)
+ sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw.show()
+
+ textview = InteProxyTextView();
+ sw.add(textview)
+ textview.show()
+ textview.set_left_margin(10)
+ textview.set_right_margin(10)
+
+ buf = textview.get_buffer()
+
+ bi = buf.get_iter_at_offset(0)
+
+ buf.insert_with_tags_by_name(bi,
+ _("Technical Details:\n"),
+ "heading")
+ buf.insert(bi, "\n")
+ buf.insert(bi, content)
+ buf.insert(bi, "\n")
+ start, end = buf.get_bounds()
+ buf.apply_tag_by_name("default", start, end)
+
+ response = dialog.run()
+ dialog.destroy()
+ while gtk.events_pending():
+ gtk.main_iteration_do()
+
+ if response == gtk.RESPONSE_ACCEPT:
+ return True
+ return False
+
+
# UI definition with the menus used in the InteProxy GUI
ui_definition = """<ui>
<!-- Menubar for the main window -->
@@ -462,6 +511,14 @@
"""
return self.call_in_gtk_thread(run_fees_dialog, *args)
+ def run_certificate_dialog(self, *args):
+ """Runs the certificate dialog.
+
+ Extends the inherited method to be thread safe in GTK, so that
+ it can be called from the server's worker threads.
+ """
+ return self.call_in_gtk_thread(run_certificate_dialog, *args)
+
def is_gtk_thread(self):
"""Returns True if called from the gtk thread.
The gtk thread is the thread the application object was
Modified: trunk/po/de.po
===================================================================
--- trunk/po/de.po 2010-09-30 10:11:14 UTC (rev 280)
+++ trunk/po/de.po 2010-10-11 08:22:07 UTC (rev 281)
@@ -5,58 +5,70 @@
msgid ""
msgstr ""
"Project-Id-Version: InteProxy SVN\n"
-"POT-Creation-Date: 2009-12-02 15:16+CET\n"
+"POT-Creation-Date: 2010-09-22 16:17+CEST\n"
"PO-Revision-Date: 2007-05-08 15:44+CEST\n"
"Last-Translator: Bernhard Herzog <bh at intevation.de>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Generated-By: pygettext.py 1.5\n"
+#: ../inteproxy/certificatedialog.py:27
+msgid "InteProxy: This connection is untrusted."
+msgstr "InteProxy: Diese Verbindung ist nicht vertrauenswürdig."
+
+#: ../inteproxy/certificatedialog.py:28
+msgid "The certificate validation failed."
+msgstr "Die Echtheit des Zertifikats konnte nicht verifiziert werden."
+
#: ../inteproxy/getpassword.py:38
msgid "Username for %s:"
msgstr "Benutzername für %s:"
-#: ../inteproxy/gtkapp.py:31
+#: ../inteproxy/gtkapp.py:30
msgid "InteProxy: Login"
msgstr "InteProxy: Login"
-#: ../inteproxy/gtkapp.py:53
+#: ../inteproxy/gtkapp.py:52
msgid "Username:"
msgstr "Benutzername:"
-#: ../inteproxy/gtkapp.py:54
+#: ../inteproxy/gtkapp.py:53
msgid "Password:"
msgstr "Passwort:"
-#: ../inteproxy/gtkapp.py:119
+#: ../inteproxy/gtkapp.py:118
msgid "InteProxy: Fees and AccessConstraints"
msgstr "InteProxy: Gebühren und Zugriffsbeschränkungen"
-#: ../inteproxy/gtkapp.py:141
+#: ../inteproxy/gtkapp.py:140
msgid "Service information for '%s'\n"
msgstr "Serviceinformation für '%s'\n"
-#: ../inteproxy/gtkapp.py:144
+#: ../inteproxy/gtkapp.py:143
msgid "Fees:\n"
msgstr "Gebühren:\n"
-#: ../inteproxy/gtkapp.py:148
+#: ../inteproxy/gtkapp.py:147
msgid "Access Constraints:\n"
msgstr "Zugriffsbeschränkungen:\n"
-#: ../inteproxy/gtkapp.py:225 ../inteproxy/gtkapp.py:441
+#: ../inteproxy/gtkapp.py:196
+msgid "Technical Details:\n"
+msgstr "Technische Details:\n"
+
+#: ../inteproxy/gtkapp.py:273 ../inteproxy/gtkapp.py:489
msgid "InteProxy"
msgstr "InteProxy"
-#: ../inteproxy/gtkapp.py:268
+#: ../inteproxy/gtkapp.py:316
msgid "InteProxy %s"
msgstr "InteProxy %s"
-#: ../inteproxy/gtkapp.py:299
+#: ../inteproxy/gtkapp.py:347
msgid "InteProxy URL: "
msgstr "InteProxy URL: "
-#: ../inteproxy/gtkapp.py:304
+#: ../inteproxy/gtkapp.py:352
msgid ""
"(Configure as HTTP-Proxy in your application, or use <InteProxy-URL><regular "
"OWS URL> as explicit URLs in your application)"
@@ -64,51 +76,51 @@
"(Als HTTP-Proxy in der Anwendung konfigurieren oder <InteProxy-URL><reguläre "
"OWS URL> als explizite URL in der Anwendung verwenden)"
-#: ../inteproxy/gtkapp.py:398
+#: ../inteproxy/gtkapp.py:446
msgid "_File"
msgstr "_Datei"
-#: ../inteproxy/gtkapp.py:399
+#: ../inteproxy/gtkapp.py:447
msgid "_Close"
msgstr "_Schließen"
-#: ../inteproxy/gtkapp.py:400
+#: ../inteproxy/gtkapp.py:448
msgid "Close the InteProxy window"
msgstr "Das InteProxy-Fenster schließen"
-#: ../inteproxy/gtkapp.py:401
+#: ../inteproxy/gtkapp.py:449
msgid "_Quit"
msgstr "_Beenden"
-#: ../inteproxy/gtkapp.py:402
+#: ../inteproxy/gtkapp.py:450
msgid "Quit application"
msgstr "Beendet die Anwendung"
-#: ../inteproxy/gtkapp.py:403
+#: ../inteproxy/gtkapp.py:451
msgid "_Help"
msgstr "_Hilfe"
-#: ../inteproxy/gtkapp.py:404
+#: ../inteproxy/gtkapp.py:452
msgid "About application"
msgstr "Über InteProxy"
-#: ../inteproxy/gtkapp.py:404
+#: ../inteproxy/gtkapp.py:452
msgid "_About"
msgstr "_Über"
-#: ../inteproxy/gtkapp.py:407
+#: ../inteproxy/gtkapp.py:455
msgid "_Show Window"
msgstr "Fenster _zeigen"
-#: ../inteproxy/gtkapp.py:408
+#: ../inteproxy/gtkapp.py:456
msgid "Show the InteProxy window"
msgstr "InteProxy Fenster zeigen"
-#: ../inteproxy/gtkapp.py:444
+#: ../inteproxy/gtkapp.py:492
msgid "Copyright 2006 - 2010 by Intevation GmbH"
msgstr "Copyright 2006 - 2010 by Intevation GmbH"
-#: ../inteproxy/gtkapp.py:445
+#: ../inteproxy/gtkapp.py:493
msgid ""
"InteProxy is distributed under the GNU General Public License (GPL) version "
"2 or later"
More information about the Inteproxy-commits
mailing list