You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/07/18 21:16:21 UTC

svn commit: r1363056 - in /subversion/branches/master-passphrase/subversion/libsvn_subr: auth_store.c auth_store.h

Author: cmpilato
Date: Wed Jul 18 19:16:20 2012
New Revision: 1363056

URL: http://svn.apache.org/viewvc?rev=1363056&view=rev
Log:
On the 'master-passphrase' branch: Add interfaces for iterating over
credentials in an auth store, and provide an explicit way to delete
credentials, too.

* subversion/libsvn_subr/auth_store.c
  (svn_auth__store_t): Add 'iterate_creds_func' member;
  (svn_auth__store_set_iterate_creds, svn_auth__store_iterate_creds):
    New functions.

* subversion/libsvn_subr/auth_store.h
  (svn_auth__store_iterate_creds_func_t, svn_auth__store_cb_iterate_creds_t):
    New callback types.
  (svn_auth__store_cb_set_cred_hash_t, svn_auth__store_set_cred_hash):
    Allow 'cred_hash' to be NULL (meaning, "delete the cached creds").
  (svn_auth__store_set_iterate_creds, svn_auth__store_iterate_creds):
    New functions.

Modified:
    subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c
    subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c?rev=1363056&r1=1363055&r2=1363056&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.c Wed Jul 18 19:16:20 2012
@@ -32,7 +32,7 @@ struct svn_auth__store_t
   svn_auth__store_cb_delete_t delete_func;
   svn_auth__store_cb_get_cred_hash_t get_cred_hash_func;
   svn_auth__store_cb_set_cred_hash_t set_cred_hash_func;
-
+  svn_auth__store_cb_iterate_creds_t iterate_creds_func;
 };
 
 
@@ -100,6 +100,16 @@ svn_auth__store_set_set_cred_hash(svn_au
 
 
 svn_error_t *
+svn_auth__store_set_iterate_creds(svn_auth__store_t *auth_store,
+                                  svn_auth__store_cb_iterate_creds_t func)
+{
+  auth_store->iterate_creds_func = func;
+  return SVN_NO_ERROR;
+}
+
+
+
+svn_error_t *
 svn_auth__store_open(svn_auth__store_t *auth_store,
                      svn_boolean_t create,
                      apr_pool_t *scratch_pool)
@@ -180,6 +190,31 @@ svn_auth__store_set_cred_hash(svn_boolea
 
 
 svn_error_t *
+svn_auth__store_iterate_creds(svn_auth__store_t *auth_store,
+                              svn_auth__store_iterate_creds_func_t iterate_creds_func,
+                              void *iterate_creds_baton,
+                              apr_pool_t *scratch_pool)
+{
+  SVN_ERR_ASSERT(auth_store->is_open);
+  if (auth_store->iterate_creds_func)
+    {
+      svn_error_t *err;
+      err = auth_store->iterate_creds_func(auth_store->store_baton,
+                                           iterate_creds_func,
+                                           iterate_creds_baton,
+                                           scratch_pool);
+      if (err && err->apr_err == SVN_ERR_CEASE_INVOCATION)
+        {
+          svn_error_clear(err);
+          err = SVN_NO_ERROR;
+        }
+      SVN_ERR(err);
+    }
+  return SVN_NO_ERROR;
+}
+
+
+svn_error_t *
 svn_auth__store_get_username_creds(svn_auth_cred_username_t **creds_p,
                                    svn_auth__store_t *auth_store,
                                    const char *realmstring,

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h?rev=1363056&r1=1363055&r2=1363056&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h Wed Jul 18 19:16:20 2012
@@ -33,6 +33,23 @@
 extern "C" {
 #endif /* __cplusplus */
 
+
+
+/* Callback type used by an auth store's iterate_creds() function to
+   iterate over stored credentials.  Implementations may return
+   SVN_ERR_CEASE_INVOCATION to halt iteration of credentials without
+   causing an error return from the iterate_creds() function.  */
+typedef svn_error_t *(*svn_auth__store_iterate_creds_func_t)(
+  void *iterate_creds_baton,
+  const char *cred_kind,
+  const char *realmstring,
+  apr_hash_t *cred_hash,
+  apr_pool_t *scratch_pool);
+
+
+
+/*** Authentication credential store objects. ***/
+
 /* Authentication credential store object. */
 typedef struct svn_auth__store_t svn_auth__store_t;
 
@@ -67,7 +84,8 @@ typedef svn_error_t *(*svn_auth__store_c
 /* Callback type: Store in AUTH_STORE a hash of authentication
    credential bits (CRED_HASH) for the credentials of kind CRED_KIND
    and identified by REALMSTRING, setting *STORED to TRUE iff the
-   storage occurs successfully. */
+   storage occurs successfully.  CRED_HASH may be NULL to indicate a
+   desire to remove the relevant credentials from the store. */
 typedef svn_error_t *(*svn_auth__store_cb_set_cred_hash_t)(
   svn_boolean_t *stored, 
   void *baton,
@@ -76,6 +94,16 @@ typedef svn_error_t *(*svn_auth__store_c
   apr_hash_t *cred_hash,
   apr_pool_t *scratch_pool);
 
+/* Callback type: Call ITERATE_CREDS_FUNC with ITERATE_CREDS_BATON for
+   each set of credentials stored in the auth store. */
+typedef svn_error_t *(*svn_auth__store_cb_iterate_creds_t)(
+  void *baton,
+  svn_auth__store_iterate_creds_func_t iterate_creds_func,
+  void *iterate_creds_baton,
+  apr_pool_t *scratch_pool);
+
+
+/*** Auth Store Factory Stuff and Functionality. ***/
 
 /* Create a generic authentication store object. */
 svn_error_t *
@@ -112,6 +140,11 @@ svn_error_t *
 svn_auth__store_set_set_cred_hash(svn_auth__store_t *auth_store,
                                   svn_auth__store_cb_set_cred_hash_t func);
 
+/* Set the `iterate_creds' callback function for AUTH_STORE to FUNC. */
+svn_error_t *
+svn_auth__store_set_iterate_creds(svn_auth__store_t *auth_store,
+                                  svn_auth__store_cb_iterate_creds_t func);
+
 
 /* Open (creating if necessary and if CREATE is set) the
    authentication credential store identified by AUTH_STORE. */
@@ -145,7 +178,8 @@ svn_auth__store_get_cred_hash(apr_hash_t
 /* Store in AUTH_STORE a hash of authentication credential bits
    (CRED_HASH) for the credentials of kind CRED_KIND and identified by
    REALMSTRING, setting *STORED to TRUE iff the storage occurs
-   successfully. */
+   successfully.  CRED_HASH may be NULL to indicate a desire to remove
+   the relevant credentials from the store.*/
 svn_error_t *
 svn_auth__store_set_cred_hash(svn_boolean_t *stored,
                               svn_auth__store_t *auth_store,
@@ -154,6 +188,15 @@ svn_auth__store_set_cred_hash(svn_boolea
                               apr_hash_t *cred_hash,
                               apr_pool_t *scratch_pool);
 
+/* Iterate over the credentials stored in AUTH_STORE, calling
+   ITERATE_CREDS_FUNC with ITERATE_CREDS_BATON for each set. */
+svn_error_t *
+svn_auth__store_iterate_creds(svn_auth__store_t *auth_store,
+                              svn_auth__store_iterate_creds_func_t iterate_creds_func,
+                              void *iterate_creds_baton,
+                              apr_pool_t *scratch_pool);
+
+
 
 /* Set *AUTH_STORE_P to an object which describes the encrypted
    authentication credential store located at AUTH_STORE_PATH.