changeset 968:c500bc862215

svnwrap: Implement handling of ssl_client_cert_prompt_provider
author Mitsuhiro Koga <shiena.jp@gmail.com>
date Tue, 23 Oct 2012 19:33:15 +0900
parents 0b6a6a7c26f3
children 145611306f8a
files hgsubversion/svnrepo.py hgsubversion/svnwrap/subvertpy_wrapper.py hgsubversion/svnwrap/svn_swig_wrapper.py
diffstat 3 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnrepo.py
+++ b/hgsubversion/svnrepo.py
@@ -221,6 +221,11 @@ class SubversionPrompt(object):
         password = self.ui.getpass('Password for \'%s\': ' % (username,), default='')
         return (username, password, bool(may_save))
 
+    def ssl_client_cert(self, realm, may_save, pool=None):
+        self.maybe_print_realm(realm)
+        cert_file = self.ui.prompt('Client certificate filename: ', default='')
+        return (cert_file, bool(may_save))
+
     def ssl_server_trust(self, realm, failures, cert_info, may_save, pool=None):
         msg = 'Error validating server certificate for \'%s\':\n' % (realm,)
         if failures & svnwrap.SSL_UNKNOWNCA:
--- a/hgsubversion/svnwrap/subvertpy_wrapper.py
+++ b/hgsubversion/svnwrap/subvertpy_wrapper.py
@@ -213,6 +213,9 @@ class SubversionRepo(object):
         def username(realm, may_save):
             return _prompt.username(realm, may_save)
 
+        def ssl_client_cert(realm, may_save):
+            return _prompt.ssl_client_cert(realm, may_save)
+
         def ssl_server_trust(realm, failures, cert_info, may_save):
             creds = _prompt.ssl_server_trust(realm, failures, cert_info, may_save)
             if creds is None:
@@ -235,6 +238,7 @@ class SubversionRepo(object):
             providers += [
                 ra.get_simple_prompt_provider(simple, 2),
                 ra.get_username_prompt_provider(username, 2),
+                ra.get_ssl_client_cert_prompt_provider(ssl_client_cert, 2),
                 ra.get_ssl_server_trust_prompt_provider(ssl_server_trust),
             ]
 
--- a/hgsubversion/svnwrap/svn_swig_wrapper.py
+++ b/hgsubversion/svnwrap/svn_swig_wrapper.py
@@ -109,6 +109,12 @@ def _username(realm, ms, pool):
     (creds.username, creds.may_save) = ret
     return creds
 
+def _ssl_client_cert(realm, may_save, pool):
+    ret = _prompt.ssl_client_cert(realm, may_save, pool)
+    creds = core.svn_auth_cred_ssl_client_cert_t()
+    (creds.cert_file, creds.may_save) = ret
+    return creds
+
 def _ssl_server_trust(realm, failures, cert_info, may_save, pool):
     cert = [
             cert_info.hostname,
@@ -173,6 +179,7 @@ def _create_auth_baton(pool, password_st
         providers += [
             client.get_simple_prompt_provider(_simple, 2),
             client.get_username_prompt_provider(_username, 2),
+            client.get_ssl_client_cert_prompt_provider(_ssl_client_cert, 2),
             client.get_ssl_server_trust_prompt_provider(_ssl_server_trust),
             ]