[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Refactor platform-specific auth provider access

From: Jeremy Whitlock <jcscoobyrs_at_gmail.com>
Date: Tue, 4 Nov 2008 13:59:37 -0700

Hi All,
    Over the last few weeks, there have been a few discussions related
to platform-specific auth providers and how we should refactor them to
make life easier for developers, bindings maintainers and API users:

http://www.nabble.com/Configuring-encrypted-password-caching:-API-proposal-td20017581.html
http://www.nabble.com/SWIG-and-platform-specific-auth-providers-(Was:-Python-bindings-build-seems-broken)-td20003744.html

Basically, to summarize the proposal, there is a lot of
platform-specific boilerplate code through parts of Subversion that
use the auth providers. The proposal is to create a unified approach
to access platform-specific auth providers to get rid of this
boilerplate code and also the library juggling it requires. I have
attached a patch that does just this. Basically, here is a high level
of that this patch does to achieve the desired results:

* Hide platform-specific auth providers from swig (perl, python and
ruby) and ctypesgen (ctypes-python)
* Create a single function for getting a platform-specific auth
providers and put that function
* Update the consumers of platform-specific providers to use the new API

Now, you might be wondering why this wasn't done for all auth
providers. In a later refactoring, it could be done but to get this
in for 1.6, and finally fix the bindings once and for all, this made
the most sense. (There is also a problem with some auth providers
only working in certain scenarios like when you're using the command
line client which would require even more potential refactoring.)

Instead of just assuming this was the desired approach, I figured I
would post this to the list and get a few more eyes on it. What do
you think?

-- 
Take care,
Jeremy Whitlock
http://www.thoughtspark.org
[[[
Refactor the access of platform-specific auth providers.
* subversion/libsvn_subr/cmdline.c
  (get_auth_provider): Removed.
  (svn_cmdline_create_auth_baton): Use the new api for accessing
   platform-specific auth providers.
* subversion/libsvn_subr/auth.c
  (svn_auth_get_platform_specific_provider): Added.
* subversion/bindings/javahl/native/SVNClient.cpp
  (get_auth_provider): Removed.
  (getContext): Use the new api for access platform-specific auth providers.
* subversion/bindings/ctypes-python/setup.py
  (build.get_apr_config): Removed the gnome_keyring and kwallet libs.
* subversion/bindings/swig/core.i,
  subversion/bindings/swig/svn_client.i: Add explicit ignores for all
   platform-specific auth providers.
* subversion/bindings/swig/python/tests/auth.py
  (test_conditional_auth_provider_support): Removed.
* subversion/bindings/swig/include/svn_global.swg
  (PLATFORM_SPECIFIC_WRAPPER): Removed.
* subversion/include/svn_auth.h
  (svn_auth_get_platform_specific_provider): Added.
  (svn_auth_get_windows_simple_provider,
   svn_auth_get_windows_ssl_server_trust_provider,
   svn_auth_get_keychain_simple_provider,
   svn_auth_get_keychain_ssl_client_cert_pw_provider,
   svn_auth_gnome_keyring_version,
   svn_auth_get_gnome_keyring_simple_provider,
   svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider,
   svn_auth_kwallet_version,
   svn_auth_get_kwallet_simple_provider,
   svn_auth_get_kwallet_ssl_client_cert_pw_provider): Removed exposure to
    swig and ctypesgen.
]]]
Index: subversion/libsvn_subr/cmdline.c
===================================================================
--- subversion/libsvn_subr/cmdline.c	(revision 34035)
+++ subversion/libsvn_subr/cmdline.c	(working copy)
@@ -354,92 +354,6 @@
   return EXIT_FAILURE;
 }
-#if defined(SVN_HAVE_KWALLET) || defined(SVN_HAVE_GNOME_KEYRING)
-
-/* Set *PROVIDER according to PROVIDER_NAME and PROVIDER_TYPE,
- * allocating it in POOL.
- *
- * Valid PROVIDER_NAME values are: "gnome_keyring" and "kwallet"
- * (they correspond to the loadable libraries named, e.g.,
- * "libsvn_auth_gnome_keyring-1.so.0", etc.)
- *
- * Valid PROVIDER_TYPE values are: "simple" and "ssl_client_cert_pw"
- * (they correspond to function names found in the loaded library,
- * such as "svn_auth_get_gnome_keyring_simple_provider", etc).
- *
- * What actually happens is we load the library and invoke the
- * appropriate provider function to supply *PROVIDER, like so:
- *
- *    svn_auth_get_<name>_<type>_provider(PROVIDER, POOL);
- *
- * If the library load fails, return an error (with the effect on
- * *PROVIDER undefined).  But if the symbol is simply not found in the
- * library, or if the PROVIDER_TYPE is unrecognized, set *PROVIDER to
- * NULL and return success.
- */
-static svn_error_t *
-get_auth_provider(svn_auth_provider_object_t **provider,
-                  const char *provider_name,
-                  const char *provider_type,
-                  apr_pool_t *pool)
-{
-  apr_dso_handle_t *dso;
-  apr_dso_handle_sym_t provider_function_symbol, version_function_symbol;
-  const char *library_label, *library_name;
-  const char *provider_function_name, *version_function_name;
-  *provider = NULL;
-  library_name = apr_psprintf(pool,
-                              "libsvn_auth_%s-%d.so.0",
-                              provider_name,
-                              SVN_VER_MAJOR);
-  library_label = apr_psprintf(pool, "svn_%s", provider_name);
-  provider_function_name = apr_psprintf(pool,
-                                        "svn_auth_get_%s_%s_provider",
-                                        provider_name, provider_type);
-  version_function_name = apr_psprintf(pool,
-                                       "svn_auth_%s_version",
-                                       provider_name);
-  SVN_ERR(svn_dso_load(&dso, library_name));
-  if (dso)
-    {
-      if (apr_dso_sym(&version_function_symbol,
-                      dso,
-                      version_function_name) == 0)
-        {
-          svn_version_func_t version_function;
-          version_function = (svn_version_func_t) version_function_symbol;
-          const svn_version_checklist_t checklist[] =
-            {
-              { library_label, version_function },
-              { NULL, NULL }
-            };
-          SVN_ERR(svn_ver_check_list(svn_subr_version(), checklist));
-        }
-      if (apr_dso_sym(&provider_function_symbol,
-                      dso,
-                      provider_function_name) == 0)
-        {
-          if (strcmp(provider_type, "simple") == 0)
-            {
-              svn_auth_simple_provider_func_t provider_function;
-              provider_function = (svn_auth_simple_provider_func_t)
-                provider_function_symbol;
-              provider_function(provider, pool);
-            }
-          else if (strcmp(provider_type, "ssl_client_cert_pw") == 0)
-            {
-              svn_auth_ssl_client_cert_pw_provider_func_t provider_function;
-              provider_function = (svn_auth_ssl_client_cert_pw_provider_func_t)
-                provider_function_symbol;
-              provider_function(provider, pool);
-            }
-        }
-    }
-  return SVN_NO_ERROR;
-}
-#endif
-
-
 /* This implements 'svn_auth_ssl_server_trust_prompt_func_t'.
    Don't actually prompt.  Instead, set *CRED_P to valid credentials
@@ -474,7 +388,6 @@
   return SVN_NO_ERROR;
 }
-
 svn_error_t *
 svn_cmdline_create_auth_baton(svn_auth_baton_t **ab,
                               svn_boolean_t non_interactive,
@@ -528,63 +441,63 @@
                                                  const char *);
       if (apr_strnatcmp(password_store, "keychain") == 0)
         {
-#ifdef SVN_HAVE_KEYCHAIN_SERVICES
-          svn_auth_get_keychain_simple_provider(&provider, pool);
-          APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+          svn_auth_get_platform_specific_provider(&provider, "keychain",
+                                                  "simple", pool);
-          svn_auth_get_keychain_ssl_client_cert_pw_provider(&provider, pool);
-          APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-#endif
+          if (provider)
+            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+          svn_auth_get_platform_specific_provider(&provider, "keychain",
+                                                  "ssl_client_cert_pw", pool);
+
+          if (provider)
+            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
           continue;
         }
       if (apr_strnatcmp(password_store, "windows-cryptoapi") == 0)
         {
-#if defined(WIN32) && !defined(__MINGW32__)
-          svn_auth_get_windows_simple_provider(&provider, pool);
-          APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-#endif
+          svn_auth_get_platform_specific_provider(&provider, "windows",
+                                                  "simple", pool);
+
+          if (provider)
+            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
           continue;
         }
       if (apr_strnatcmp(password_store, "gnome-keyring") == 0)
         {
-#ifdef SVN_HAVE_GNOME_KEYRING
-          SVN_ERR(get_auth_provider(&provider, "gnome_keyring", "simple",
-                                    pool));
+          svn_auth_get_platform_specific_provider(&provider, "gnome_keyring",
+                                                  "simple", pool);
+
           if (provider)
-            {
-              APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *)
-                = provider;
-            }
-          SVN_ERR(get_auth_provider(&provider, "gnome_keyring",
-                                    "ssl_client_cert_pw", pool));
+            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+          svn_auth_get_platform_specific_provider(&provider, "gnome_keyring",
+                                                  "ssl_client_cert_pw", pool);
+
           if (provider)
-            {
-              APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *)
-                = provider;
-            }
-#endif
+            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
           continue;
         }
       if (apr_strnatcmp(password_store, "kwallet") == 0)
         {
-#ifdef SVN_HAVE_KWALLET
-          SVN_ERR(get_auth_provider(&provider, "kwallet", "simple",  pool));
+          svn_auth_get_platform_specific_provider(&provider, "kwallet",
+                                                  "simple", pool);
+
           if (provider)
-            {
-              APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *)
-                = provider;
-            }
-          SVN_ERR(get_auth_provider(&provider, "kwallet",
-                                    "ssl_client_cert_pw", pool));
+            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+          svn_auth_get_platform_specific_provider(&provider, "kwallet",
+                                                  "ssl_client_cert_pw", pool);
+
           if (provider)
-            {
-              APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *)
-                = provider;
-            }
-#endif
+            APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
           continue;
         }
       return svn_error_createf(SVN_ERR_BAD_CONFIG_VALUE, NULL,
@@ -610,10 +523,12 @@
   APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
   /* The server-cert, client-cert, and client-cert-password providers. */
-#if defined(WIN32) && !defined(__MINGW32__)
-  svn_auth_get_windows_ssl_server_trust_provider(&provider, pool);
-  APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-#endif
+  svn_auth_get_platform_specific_provider(&provider, "windows",
+                                          "ssl_server_trust", pool);
+
+  if (provider)
+    APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
   svn_auth_get_ssl_server_trust_file_provider(&provider, pool);
   APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
   svn_auth_get_ssl_client_cert_file_provider(&provider, pool);
Index: subversion/libsvn_subr/auth.c
===================================================================
--- subversion/libsvn_subr/auth.c	(revision 34035)
+++ subversion/libsvn_subr/auth.c	(working copy)
@@ -370,3 +370,102 @@
   return new_info;
 }
+
+svn_error_t *
+svn_auth_get_platform_specific_provider(svn_auth_provider_object_t **provider,
+                                        const char *provider_name,
+                                        const char *provider_type,
+                                        apr_pool_t *pool)
+{
+  *provider = NULL;
+
+  if (apr_strnatcmp(provider_name, "gnome_keyring") == 0 ||
+      apr_strnatcmp(provider_name, "kwallet") == 0)
+    {
+#ifdef SVN_HAVE_GNOME_KEYRING || SVN_HAVE_KWALLET
+      apr_dso_handle_t *dso;
+      apr_dso_handle_sym_t provider_function_symbol, version_function_symbol;
+      const char *library_label, *library_name;
+      const char *provider_function_name, *version_function_name;
+      library_name = apr_psprintf(pool,
+                                  "libsvn_auth_%s-%d.so.0",
+                                  provider_name,
+                                  SVN_VER_MAJOR);
+      library_label = apr_psprintf(pool, "svn_%s", provider_name);
+      provider_function_name = apr_psprintf(pool,
+                                            "svn_auth_get_%s_%s_provider",
+                                            provider_name, provider_type);
+      version_function_name = apr_psprintf(pool,
+                                           "svn_auth_%s_version",
+                                           provider_name);
+      SVN_ERR(svn_dso_load(&dso, library_name));
+      if (dso)
+        {
+          if (apr_dso_sym(&version_function_symbol,
+                          dso,
+                          version_function_name) == 0)
+            {
+              svn_version_func_t version_function;
+              version_function = (svn_version_func_t) version_function_symbol;
+              const svn_version_checklist_t checklist[] =
+                {
+                  { library_label, version_function },
+                  { NULL, NULL }
+                };
+              SVN_ERR(svn_ver_check_list(svn_subr_version(), checklist));
+            }
+          if (apr_dso_sym(&provider_function_symbol,
+                          dso,
+                          provider_function_name) == 0)
+            {
+              if (strcmp(provider_type, "simple") == 0)
+                {
+                  svn_auth_simple_provider_func_t provider_function;
+                  provider_function = (svn_auth_simple_provider_func_t)
+                    provider_function_symbol;
+                  provider_function(provider, pool);
+                }
+              else if (strcmp(provider_type, "ssl_client_cert_pw") == 0)
+                {
+                  svn_auth_ssl_client_cert_pw_provider_func_t
provider_function;
+                  provider_function =
+                    (svn_auth_ssl_client_cert_pw_provider_func_t)
+                    provider_function_symbol;
+                  provider_function(provider, pool);
+                }
+            }
+        }
+#endif
+    }
+  else
+    {
+#ifdef SVN_HAVE_KEYCHAIN_SERVICES
+      if (strcmp(provider_name, "keychain") == 0 &&
+          strcmp(provider_type, "simple") == 0)
+        {
+          svn_auth_get_keychain_simple_provider(provider, pool);
+        }
+      else if (strcmp(provider_name, "keychain") == 0 &&
+               strcmp(provider_type, "ssl_client_cert_pw") == 0)
+        {
+          svn_auth_get_keychain_ssl_client_cert_pw_provider(provider, pool);
+        }
+#endif
+
+#if defined(WIN32) && !defined(__MINGW32__)
+      if (strcmp(provider_name, "windows") == 0 &&
+          strcmp(provider_type, "simple") == 0)
+        {
+          svn_auth_get_windows_simple_provider(provider, pool);
+        }
+
+      if (strcmp(provider_name, "windows") == 0 &&
+          strcmp(provider_type, "ssl_server_trust") == 0)
+        {
+          svn_auth_get_windows_simple_provider(provider, pool);
+        }
+#endif
+    }
+
+  return SVN_NO_ERROR;
+}
Index: subversion/bindings/javahl/native/SVNClient.cpp
===================================================================
--- subversion/bindings/javahl/native/SVNClient.cpp	(revision 34035)
+++ subversion/bindings/javahl/native/SVNClient.cpp	(working copy)
@@ -1152,70 +1152,6 @@
                                                requestPool.pool()), );
 }
-#if defined(SVN_HAVE_KWALLET) || defined(SVN_HAVE_GNOME_KEYRING)
-
-/* Set *PROVIDER according to PROVIDER_NAME and PROVIDER_TYPE,
- * allocating it in POOL.
- *
- * Valid PROVIDER_NAME values are: "gnome_keyring" and "kwallet"
- * (they correspond to the loadable libraries named, e.g.,
- * "libsvn_auth_gnome_keyring-1.so.0", etc.)
- *
- * Valid PROVIDER_TYPE values are: "simple" and "ssl_client_cert_pw"
- * (they correspond to function names found in the loaded library,
- * such as "svn_auth_get_gnome_keyring_simple_provider", etc).
- *
- * What actually happens is we load the library and invoke the
- * appropriate provider function to supply *PROVIDER, like so:
- *
- *    svn_auth_get_<name>_<type>_provider(PROVIDER, POOL);
- *
- * If the library load fails, return an error (with the effect on
- * *PROVIDER undefined).  But if the symbol is simply not found in the
- * library, or if the PROVIDER_TYPE is unrecognized, set *PROVIDER to
- * NULL and return success.
- */
-static svn_error_t *
-get_auth_provider(svn_auth_provider_object_t **provider,
-                  const char *provider_name,
-                  const char *provider_type,
-                  apr_pool_t *pool)
-{
-  apr_dso_handle_t *dso;
-  apr_dso_handle_sym_t symbol;
-  const char *libname;
-  const char *funcname;
-  *provider = NULL;
-  libname = apr_psprintf(pool,
-                         "libsvn_auth_%s-%d.so.0",
-                         provider_name,
-                         SVN_VER_MAJOR);
-  funcname = apr_psprintf(pool,
-                          "svn_auth_get_%s_%s_provider",
-                          provider_name, provider_type);
-  SVN_ERR(svn_dso_load(&dso, libname));
-  if (dso)
-    {
-      if (! apr_dso_sym(&symbol, dso, funcname))
-        {
-          if (strcmp(provider_type, "simple") == 0)
-            {
-              svn_auth_simple_provider_func_t func;
-              func = (svn_auth_simple_provider_func_t) symbol;
-              func(provider, pool);
-            }
-          else if (strcmp(provider_type, "ssl_client_cert_pw") == 0)
-            {
-              svn_auth_ssl_client_cert_pw_provider_func_t func;
-              func = (svn_auth_ssl_client_cert_pw_provider_func_t) symbol;
-              func(provider, pool);
-            }
-        }
-    }
-  return SVN_NO_ERROR;
-}
-#endif
-
 svn_client_ctx_t *SVNClient::getContext(const char *message)
 {
     apr_pool_t *pool = JNIUtil::getRequestPool()->pool();
@@ -1229,55 +1165,73 @@
     /* The main disk-caching auth providers, for both
      * 'username/password' creds and 'username' creds.  */
     svn_auth_provider_object_t *provider;
-#if defined(WIN32) && !defined(__MINGW32__)
-    svn_auth_get_windows_simple_provider(&provider, pool);
-    APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-#endif
-#ifdef SVN_HAVE_KEYCHAIN_SERVICES
-    svn_auth_get_keychain_simple_provider(&provider, pool);
-    APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-    svn_auth_get_keychain_ssl_client_cert_pw_provider(&provider, pool);
-    APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-#endif
-#ifdef SVN_HAVE_GNOME_KEYRING
-    SVN_JNI_ERR(get_auth_provider(&provider, "gnome_keyring", "simple",
-                                  pool), NULL);
+    /* Windows auth providers */
+    svn_auth_get_platform_specific_provider(&provider, "windows",
+                                            "simple", pool);
+
     if (provider)
-      {
-        APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-      }
-    SVN_JNI_ERR(get_auth_provider(&provider, "gnome_keyring",
-                                  "ssl_client_cert_pw", pool), NULL);
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+    /* Keychain auth providers */
+    svn_auth_get_platform_specific_provider(&provider, "keychain",
+                                            "simple", pool);
+
     if (provider)
-      {
-        APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-      }
-#endif
-#ifdef SVN_HAVE_KWALLET
-    SVN_JNI_ERR(get_auth_provider(&provider, "kwallet", "simple",  pool),
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+    svn_auth_get_platform_specific_provider(&provider, "keychain",
+                                            "ssl_client_cert_pw", pool);
+
+    if (provider)
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+    /* Gnome Keyring auth providers */
+    SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
+                                                        "gnome_keyring",
+                                                        "simple", pool),
                 NULL);
+
     if (provider)
-      {
-        APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-      }
-    SVN_JNI_ERR(get_auth_provider(&provider, "kwallet", "ssl_client_cert_pw",
-                                  pool), NULL);
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+    SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
+                                                        "gnome_keyring",
+                                                        "ssl_client_cert_pw",
+                                                        pool), NULL);
+
     if (provider)
-      {
-        APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-      }
-#endif
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+    /* Kwallet auth providers */
+    SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
+                                                        "kwallet",
+                                                        "simple", pool),
+                NULL);
+
+    if (provider)
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
+    SVN_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
+                                                        "kwallet",
+                                                        "ssl_client_cert_pw",
+                                                        pool), NULL);
+
+    if (provider)
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
     svn_auth_get_simple_provider(&provider, pool);
     APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
     svn_auth_get_username_provider(&provider, pool);
     APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
     /* The server-cert, client-cert, and client-cert-password providers. */
-#if defined(WIN32) && !defined(__MINGW32__)
-    svn_auth_get_windows_ssl_server_trust_provider(&provider, pool);
-    APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-#endif
+    svn_auth_get_platform_specific_provider(&provider, "windows",
+                                            "ssl_server_trust", pool);
+
+    if (provider)
+      APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
+
     svn_auth_get_ssl_server_trust_file_provider(&provider, pool);
     APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
     svn_auth_get_ssl_client_cert_file_provider(&provider, pool);
Index: subversion/bindings/ctypes-python/setup.py
===================================================================
--- subversion/bindings/ctypes-python/setup.py	(revision 34035)
+++ subversion/bindings/ctypes-python/setup.py	(working copy)
@@ -163,8 +163,6 @@
         # List the libraries in the order they should be loaded
         libraries = [
           "svn_subr-1",
-          "svn_auth_kwallet-1",
-          "svn_auth_gnome_keyring-1",
           "svn_diff-1",
           "svn_delta-1",
           "svn_fs-1",
Index: subversion/bindings/swig/core.i
===================================================================
--- subversion/bindings/swig/core.i	(revision 34035)
+++ subversion/bindings/swig/core.i	(working copy)
@@ -218,19 +218,20 @@
 %ignore svn_path_cstring_from_utf8;
 %ignore svn_path_cstring_to_utf8;
-/* svn_auth.h: Subversion platform-specific auth providers */
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_keychain_simple_provider,
SVN_HAVE_KEYCHAIN_SERVICES)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_keychain_ssl_client_cert_pw_provider,
SVN_HAVE_KEYCHAIN_SERVICES)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_windows_simple_provider, SWIGWIN)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_windows_ssl_server_trust_provider,
SWIGWIN)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_gnome_keyring_version,
SVN_HAVE_GNOME_KEYRING)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_gnome_keyring_simple_provider,
SVN_HAVE_GNOME_KEYRING)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider,
SVN_HAVE_GNOME_KEYRING)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_kwallet_version, SVN_HAVE_KWALLET)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_kwallet_simple_provider,
SVN_HAVE_KWALLET)
-PLATFORM_SPECIFIC_WRAPPER(svn_auth_get_kwallet_ssl_client_cert_pw_provider,
SVN_HAVE_KWALLET)
+/* Other files */
-/* Other files */
+/* Ignore platform-specific auth functions */
+%ignore svn_auth_get_keychain_simple_provider;
+%ignore svn_auth_get_keychain_ssl_client_cert_pw_provider;
+%ignore svn_auth_get_windows_simple_provider;
+%ignore svn_auth_get_windows_ssl_server_trust_provider;
+%ignore svn_auth_gnome_keyring_version;
+%ignore svn_auth_get_gnome_keyring_simple_provider;
+%ignore svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider;
+%ignore svn_auth_kwallet_version;
+%ignore svn_auth_get_kwallet_simple_provider;
+%ignore svn_auth_get_kwallet_ssl_client_cert_pw_provider;
+
 /* bad pool convention */
 %ignore svn_opt_print_generic_help;
Index: subversion/bindings/swig/python/tests/auth.py
===================================================================
--- subversion/bindings/swig/python/tests/auth.py	(revision 34035)
+++ subversion/bindings/swig/python/tests/auth.py	(working copy)
@@ -89,34 +89,6 @@
                 core.SVN_AUTH_CRED_SSL_SERVER_TRUST, "somerealm", baton)
     self.assert_(creds is not None)
-  def test_conditional_auth_provider_support(self):
-    fail_msg = "Should not be able to obtain a %s auth provider."
-    try:
-      provider = core.svn_auth_get_keychain_simple_provider()
-      self.failUnless(sys.platform == "darwin", fail_msg % "Keychain")
-    except RuntimeError:
-      pass
-
-    try:
-      provider = core.svn_auth_get_windows_simple_provider()
-      self.failUnless(sys.platform == "win32", fail_msg % "Windows")
-    except RuntimeError:
-      pass
-
-    try:
-      provider = core.svn_auth_get_gnome_keyring_simple_provider()
-      self.failUnless(sys.platform not in ("win32", "darwin"),
-                      fail_msg % "Gnome Keyring")
-    except RuntimeError:
-      pass
-
-    try:
-      provider = core.svn_auth_get_kwallet_simple_provider()
-      self.failUnless(sys.platform not in ("win32", "darwin"),
-                      fail_msg % "Kwallet")
-    except RuntimeError:
-      pass
-
 def suite():
     return unittest.makeSuite(SubversionAuthTestCase, 'test')
Index: subversion/bindings/swig/include/svn_global.swg
===================================================================
--- subversion/bindings/swig/include/svn_global.swg	(revision 34035)
+++ subversion/bindings/swig/include/svn_global.swg	(working copy)
@@ -211,25 +211,3 @@
 /* Now, include the main Subversion typemap library. */
 %include svn_types.swg
 %include proxy.swg
-
-/* -----------------------------------------------------------------------
-   Simple macro to enable you to "pretend" to wrap platform-specific functions
-   not compiled into your version of Subversion and handle these exceptions
-   gracefully.
-*/
-
-%define PLATFORM_SPECIFIC_WRAPPER(func_name, macro)
-%exception func_name {
-%#ifdef macro
-#ifdef SWIGPYTHON
-svn_swig_py_release_py_lock();
-#endif
-$action
-#ifdef SWIGPYTHON
-svn_swig_py_acquire_py_lock();
-#endif
-%#else
-SWIG_exception(SWIG_RuntimeError, "'$symname' is not available on
this platform.");
-%#endif
-}
-%enddef
Index: subversion/bindings/swig/svn_client.i
===================================================================
--- subversion/bindings/swig/svn_client.i	(revision 34035)
+++ subversion/bindings/swig/svn_client.i	(working copy)
@@ -29,8 +29,8 @@
 %import svn_delta.i
 %import svn_wc.i
-/* svn_client.h: Subversion Windows-specific auth provider */
-PLATFORM_SPECIFIC_WRAPPER(svn_client_get_windows_simple_provider, SWIGWIN)
+/* Ignore platform-specific auth functions */
+%ignore svn_client_get_windows_simple_provider;
 /* -----------------------------------------------------------------------
    %apply-ing of typemaps defined elsewhere
Index: subversion/include/svn_auth.h
===================================================================
--- subversion/include/svn_auth.h	(revision 34035)
+++ subversion/include/svn_auth.h	(working copy)
@@ -767,8 +767,36 @@
 svn_auth_get_simple_provider(svn_auth_provider_object_t **provider,
                              apr_pool_t *pool);
+/** Create and return @a *provider, an authentication provider of type @c
+ * svn_auth_provider_object_t, or return @a NULL if the provider is not
+ * available for the requested platform or the requested provider is unknown.
+ *
+ * Valid @a provider_name values are: "gnome_keyring", "keychain", "kwallet"
+ * and "windows".
+ *
+ * Valid @a provider_type values are: "simple", "ssl_client_cert_pw" and
+ * "ssl_server_trust".
+ *
+ * Allocate @a *provider in @a pool.
+ *
+ * What actually happens is we invoke the appropriate provider function to
+ * supply the @a provider, like so:
+ *
+ *    svn_auth_get_<name>_<type>_provider(@a provider, @a pool);
+ *
+ * In the case of the "gnome_keyring" and the "kwallet" @a platform_type, an
+ * error can be thrown in the event that loading the respective shared library
+ * fails.
+ *
+ * @since New in 1.6.
+ */
+svn_error_t *
+svn_auth_get_platform_specific_provider(svn_auth_provider_object_t **provider,
+                                        const char *provider_name,
+                                        const char *provider_type,
+                                        apr_pool_t *pool);
-#if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN) ||
defined(CTYPESGEN) || defined(SWIG)
+#if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN)
 /**
  * Create and return @a *provider, an authentication provider of type @c
  * svn_auth_cred_simple_t that gets/sets information from the user's
@@ -791,11 +819,28 @@
 void
 svn_auth_get_windows_simple_provider(svn_auth_provider_object_t **provider,
                                      apr_pool_t *pool);
-#endif /* WIN32 && !__MINGW32__ || DOXYGEN || CTYPESGEN || SWIG */
-#if defined(DARWIN) || defined(DOXYGEN) || defined(CTYPESGEN) || defined(SWIG)
 /**
  * Create and return @a *provider, an authentication provider of type @c
+ * svn_auth_cred_ssl_server_trust_t, allocated in @a pool.
+ *
+ * This provider automatically validates ssl server certificates with
+ * the CryptoApi, like Internet Explorer and the Windows network API do.
+ * This allows the rollout of root certificates via Windows Domain
+ * policies, instead of Subversion specific configuration.
+ *
+ * @since New in 1.5.
+ * @note This function is only available on Windows.
+ */
+void
+svn_auth_get_windows_ssl_server_trust_provider
+  (svn_auth_provider_object_t **provider,
+   apr_pool_t *pool);
+#endif /* WIN32 && !__MINGW32__ || DOXYGEN */
+
+#if defined(DARWIN) || defined(DOXYGEN)
+/**
+ * Create and return @a *provider, an authentication provider of type @c
  * svn_auth_cred_simple_t that gets/sets information from the user's
  * ~/.subversion configuration directory.  Allocate @a *provider in
  * @a pool.
@@ -826,9 +871,9 @@
 svn_auth_get_keychain_ssl_client_cert_pw_provider
   (svn_auth_provider_object_t **provider,
    apr_pool_t *pool);
-#endif /* DARWIN || DOXYGEN || CTYPESGEN || SWIG */
+#endif /* DARWIN || DOXYGEN */
-#if (!defined(DARWIN) && !defined(WIN32)) || defined(DOXYGEN) ||
defined(CTYPESGEN) || defined(SWIG)
+#if (!defined(DARWIN) && !defined(WIN32)) || defined(DOXYGEN)
 /**
  * Get libsvn_auth_gnome_keyring version information.
  *
@@ -920,7 +965,7 @@
 svn_auth_get_kwallet_ssl_client_cert_pw_provider
   (svn_auth_provider_object_t **provider,
    apr_pool_t *pool);
-#endif /* (!DARWIN && !WIN32) || DOXYGEN || CTYPESGEN || SWIG */
+#endif /* (!DARWIN && !WIN32) || DOXYGEN */
 /** Create and return @a *provider, an authentication provider of type @c
@@ -953,26 +998,6 @@
   (svn_auth_provider_object_t **provider,
    apr_pool_t *pool);
-
-#if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN) ||
defined(CTYPESGEN) || defined(SWIG)
-/**
- * Create and return @a *provider, an authentication provider of type @c
- * svn_auth_cred_ssl_server_trust_t, allocated in @a pool.
- *
- * This provider automatically validates ssl server certificates with
- * the CryptoApi, like Internet Explorer and the Windows network API do.
- * This allows the rollout of root certificates via Windows Domain
- * policies, instead of Subversion specific configuration.
- *
- * @since New in 1.5.
- * @note This function is only available on Windows.
- */
-void
-svn_auth_get_windows_ssl_server_trust_provider
-  (svn_auth_provider_object_t **provider,
-   apr_pool_t *pool);
-#endif /* WIN32 && !__MINGW32__ || DOXYGEN || CTYPESGEN || SWIG */
-
 /** Create and return @a *provider, an authentication provider of type @c
  * svn_auth_cred_ssl_client_cert_t, allocated in @a pool.
  *


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org

Received on 2008-11-04 21:59:57 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.