changeset 969:145611306f8a

svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
author Mitsuhiro Koga <shiena.jp@gmail.com>
date Tue, 23 Oct 2012 03:50:00 +0900
parents c500bc862215
children 3e59f9af15b0
files hgsubversion/svnrepo.py hgsubversion/svnwrap/subvertpy_wrapper.py hgsubversion/svnwrap/svn_swig_wrapper.py
diffstat 3 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnrepo.py
+++ b/hgsubversion/svnrepo.py
@@ -226,6 +226,10 @@ class SubversionPrompt(object):
         cert_file = self.ui.prompt('Client certificate filename: ', default='')
         return (cert_file, bool(may_save))
 
+    def ssl_client_cert_pw(self, realm, may_save, pool=None):
+        password = self.ui.getpass('Passphrase for \'%s\': ' % (realm,), default='')
+        return (password, 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
@@ -216,6 +216,9 @@ class SubversionRepo(object):
         def ssl_client_cert(realm, may_save):
             return _prompt.ssl_client_cert(realm, may_save)
 
+        def ssl_client_cert_pw(realm, may_save):
+            return _prompt.ssl_client_cert_pw(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:
@@ -239,6 +242,7 @@ class SubversionRepo(object):
                 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_client_cert_pw_prompt_provider(ssl_client_cert_pw, 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
@@ -115,6 +115,12 @@ def _ssl_client_cert(realm, may_save, po
     (creds.cert_file, creds.may_save) = ret
     return creds
 
+def _ssl_client_cert_pw(realm, may_save, pool):
+    ret = _prompt.ssl_client_cert_pw(realm, may_save, pool)
+    creds = core.svn_auth_cred_ssl_client_cert_pw_t()
+    (creds.password, creds.may_save) = ret
+    return creds
+
 def _ssl_server_trust(realm, failures, cert_info, may_save, pool):
     cert = [
             cert_info.hostname,
@@ -180,6 +186,7 @@ def _create_auth_baton(pool, password_st
             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_client_cert_pw_prompt_provider(_ssl_client_cert_pw, 2),
             client.get_ssl_server_trust_prompt_provider(_ssl_server_trust),
             ]