[gcr/main: 19/30] gck: Remove authenticate_slot/object from GckModule




commit 513819ebdebaf51c8d955476ad1e925276ac8fa4
Author: Corentin Noël <corentin noel collabora com>
Date:   Tue Oct 5 10:50:28 2021 +0200

    gck: Remove authenticate_slot/object from GckModule
    
    Also remove the compatibility test and objects.

 gck/gck-attributes.c      |   4 +-
 gck/gck-enumerator.c      |  14 +---
 gck/gck-interaction.c     | 176 ----------------------------------------------
 gck/gck-module.c          |  55 ---------------
 gck/gck-private.h         |  14 ----
 gck/gck-session.c         |  46 ++----------
 gck/gck-slot.c            |  14 +++-
 gck/gck.h                 |   6 +-
 gck/meson.build           |   1 -
 gck/test-gck-crypto.c     |  28 +++-----
 gck/test-gck-enumerator.c |  55 +--------------
 gck/test-gck-object.c     |   4 +-
 gck/test-gck-session.c    |  29 +++-----
 gcr/gcr-trust.c           |   2 +-
 14 files changed, 52 insertions(+), 396 deletions(-)
---
diff --git a/gck/gck-attributes.c b/gck/gck-attributes.c
index 25e794d8..6a0b4fb0 100644
--- a/gck/gck-attributes.c
+++ b/gck/gck-attributes.c
@@ -238,7 +238,7 @@ gck_builder_ref (GckBuilder *builder)
 
 /**
  * gck_builder_unref:
- * @builder: the builder
+ * @builder: (transfer full): the builder
  *
  * Unreferences a builder. If this was the last reference then the builder
  * is freed.
@@ -247,7 +247,7 @@ gck_builder_ref (GckBuilder *builder)
  * stack.
  */
 void
-gck_builder_unref (gpointer builder)
+gck_builder_unref (GckBuilder *builder)
 {
        GckRealBuilder *real = (GckRealBuilder *)builder;
 
diff --git a/gck/gck-enumerator.c b/gck/gck-enumerator.c
index 957e2a76..220c3d46 100644
--- a/gck/gck-enumerator.c
+++ b/gck/gck-enumerator.c
@@ -357,7 +357,6 @@ state_slot (GckEnumeratorState *args, gboolean forward)
 static gpointer
 state_session (GckEnumeratorState *args, gboolean forward)
 {
-       GTlsInteraction *interaction;
        CK_RV rv;
 
        g_assert (args->funcs);
@@ -373,17 +372,9 @@ state_session (GckEnumeratorState *args, gboolean forward)
                        return state_find;
                }
 
-               /* Compatibility, hook into GckModule signals if no interaction set */
-               if (args->interaction)
-                       interaction = g_object_ref (args->interaction);
-               else
-                       interaction = _gck_interaction_new (args->slot);
-
                rv = _gck_session_authenticate_token (args->funcs,
                                                      gck_session_get_handle (args->session),
-                                                     args->slot, interaction, NULL);
-
-               g_object_unref (interaction);
+                                                     args->slot, args->interaction, NULL);
 
                if (rv != CKR_OK)
                        g_message ("couldn't authenticate when enumerating: %s", gck_message_from_rv (rv));
@@ -393,8 +384,7 @@ state_session (GckEnumeratorState *args, gboolean forward)
 
        /* Session to slot state */
        } else {
-               g_object_unref (args->session);
-               args->session = NULL;
+               g_clear_object (&args->session);
                return state_slot;
        }
 }
diff --git a/gck/gck-module.c b/gck/gck-module.c
index 935bbeb1..f7ba7db5 100644
--- a/gck/gck-module.c
+++ b/gck/gck-module.c
@@ -77,12 +77,6 @@ enum {
        PROP_FUNCTIONS
 };
 
-enum {
-       AUTHENTICATE_SLOT,
-       AUTHENTICATE_OBJECT,
-       LAST_SIGNAL
-};
-
 struct _GckModulePrivate {
        gchar *path;
        gboolean initialized;
@@ -95,24 +89,10 @@ struct _GckModulePrivate {
 
 G_DEFINE_TYPE_WITH_PRIVATE (GckModule, gck_module, G_TYPE_OBJECT);
 
-static guint signals[LAST_SIGNAL] = { 0 };
-
 /* ----------------------------------------------------------------------------
  * OBJECT
  */
 
-static gboolean
-gck_module_real_authenticate_slot (GckModule *module, GckSlot *self, gchar *label, gchar **password)
-{
-       return FALSE;
-}
-
-static gboolean
-gck_module_real_authenticate_object (GckModule *module, GckObject *object, gchar *label, gchar **password)
-{
-       return FALSE;
-}
-
 static void
 gck_module_init (GckModule *self)
 {
@@ -205,9 +185,6 @@ gck_module_class_init (GckModuleClass *klass)
        gobject_class->dispose = gck_module_dispose;
        gobject_class->finalize = gck_module_finalize;
 
-       klass->authenticate_object = gck_module_real_authenticate_object;
-       klass->authenticate_slot = gck_module_real_authenticate_slot;
-
        /**
         * GckModule:path:
         *
@@ -231,38 +208,6 @@ gck_module_class_init (GckModuleClass *klass)
        g_object_class_install_property (gobject_class, PROP_FUNCTIONS,
                g_param_spec_pointer ("functions", "Function List", "PKCS11 Function List",
                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
-
-       /**
-        * GckModule::authenticate-slot:
-        * @module: The module
-        * @slot: The slot to be authenticated.
-        * @string: A displayable label which describes the object.
-        * @password: A gchar** where a password should be returned.
-        *
-        * Use gck_session_set_interaction() instead of connecting to this signal.
-        *
-        * Deprecated: Since 3.4
-        */
-       signals[AUTHENTICATE_SLOT] = g_signal_new ("authenticate-slot", GCK_TYPE_MODULE,
-                       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GckModuleClass, authenticate_slot),
-                       g_signal_accumulator_true_handled, NULL, _gck_marshal_BOOLEAN__OBJECT_STRING_POINTER,
-                       G_TYPE_BOOLEAN, 3, GCK_TYPE_SLOT, G_TYPE_STRING, G_TYPE_POINTER);
-
-       /**
-        * GckModule::authenticate-object:
-        * @module: The module.
-        * @object: The object to be authenticated.
-        * @label: A displayable label which describes the object.
-        * @password: A gchar** where a password should be returned.
-        *
-        * Use gck_session_set_interaction() instead of connecting to this signal.
-        *
-        * Deprecated: Since 3.4
-        */
-       signals[AUTHENTICATE_OBJECT] = g_signal_new ("authenticate-object", GCK_TYPE_MODULE,
-                       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GckModuleClass, authenticate_object),
-                       g_signal_accumulator_true_handled, NULL, _gck_marshal_BOOLEAN__OBJECT_STRING_POINTER,
-                       G_TYPE_BOOLEAN, 3, GCK_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER);
 }
 
 G_DEFINE_BOXED_TYPE (GckModuleInfo, gck_module_info,
diff --git a/gck/gck-private.h b/gck/gck-private.h
index 6c4117c7..93731d6e 100644
--- a/gck/gck-private.h
+++ b/gck/gck-private.h
@@ -121,20 +121,6 @@ CK_RV              _gck_session_authenticate_key            (CK_FUNCTION_LIST_PT
 void               _gck_password_update                     (GckPassword *self,
                                                              gboolean request_retry);
 
-/* ----------------------------------------------------------------------------
- * INTERACTION
- */
-
-#define GCK_TYPE_INTERACTION    (_gck_interaction_get_type ())
-#define GCK_INTERACTION(obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCK_TYPE_INTERACTION, GckInteraction))
-#define GCK_IS_INTERACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCK_TYPE_INTERACTION))
-
-typedef struct _GckInteraction GckInteraction;
-
-GType               _gck_interaction_get_type               (void) G_GNUC_CONST;
-
-GTlsInteraction *   _gck_interaction_new                    (gpointer token_or_key);
-
 /* ----------------------------------------------------------------------------
  * CALL
  */
diff --git a/gck/gck-session.c b/gck/gck-session.c
index 4c5fe084..578aaeae 100644
--- a/gck/gck-session.c
+++ b/gck/gck-session.c
@@ -384,7 +384,6 @@ free_open_session (OpenSession *args)
 static CK_RV
 perform_open_session (OpenSession *args)
 {
-       GTlsInteraction *interaction;
        CK_RV rv = CKR_OK;
 
        /* First step, open session */
@@ -396,16 +395,8 @@ perform_open_session (OpenSession *args)
        if (rv != CKR_OK || !args->auto_login)
                return rv;
 
-       /* Compatibility, hook into GckModule signals if no interaction set */
-       if (args->interaction)
-               interaction = g_object_ref (args->interaction);
-       else
-               interaction = _gck_interaction_new (args->slot);
-
        rv = _gck_session_authenticate_token (args->base.pkcs11, args->session,
-                                             args->slot, interaction, NULL);
-
-       g_object_unref (interaction);
+                                             args->slot, args->interaction, NULL);
 
        return rv;
 }
@@ -782,22 +773,12 @@ void
 gck_session_set_interaction (GckSession *self,
                              GTlsInteraction *interaction)
 {
-       GTlsInteraction *previous;
        g_return_if_fail (GCK_IS_SESSION (self));
        g_return_if_fail (interaction == NULL || G_IS_TLS_INTERACTION (interaction));
 
-       if (interaction)
-               g_object_ref (interaction);
-
        g_mutex_lock (self->pv->mutex);
-
-               previous = self->pv->interaction;
-               self->pv->interaction = interaction;
-
+       g_set_object (&self->pv->interaction, interaction);
        g_mutex_unlock (self->pv->mutex);
-
-       if (previous)
-               g_object_unref (previous);
 }
 
 /**
@@ -2611,7 +2592,6 @@ typedef struct _Crypt {
 static CK_RV
 perform_crypt (Crypt *args)
 {
-       GTlsInteraction *interaction;
        CK_RV rv;
 
        g_assert (args);
@@ -2625,16 +2605,8 @@ perform_crypt (Crypt *args)
        if (rv != CKR_OK)
                return rv;
 
-       /* Compatibility, hook into GckModule signals if no interaction set */
-       if (args->interaction)
-               interaction = g_object_ref (args->interaction);
-       else
-               interaction = _gck_interaction_new (args->key_object);
-
        rv = _gck_session_authenticate_key (args->base.pkcs11, args->base.handle,
-                                           args->key_object, interaction, NULL);
-
-       g_object_unref (interaction);
+                                           args->key_object, args->interaction, NULL);
 
        if (rv != CKR_OK)
                return rv;
@@ -3135,7 +3107,6 @@ typedef struct _Verify {
 static CK_RV
 perform_verify (Verify *args)
 {
-       GTlsInteraction *interaction;
        CK_RV rv;
 
        /* Initialize the crypt operation */
@@ -3143,17 +3114,8 @@ perform_verify (Verify *args)
        if (rv != CKR_OK)
                return rv;
 
-       /* Compatibility, hook into GckModule signals if no interaction set */
-       if (args->interaction)
-               interaction = g_object_ref (args->interaction);
-       else
-               interaction = _gck_interaction_new (args->key_object);
-
-
        rv = _gck_session_authenticate_key (args->base.pkcs11, args->base.handle,
-                                           args->key_object, interaction, NULL);
-
-       g_object_unref (interaction);
+                                           args->key_object, args->interaction, NULL);
 
        if (rv != CKR_OK)
                return rv;
diff --git a/gck/gck-slot.c b/gck/gck-slot.c
index 8ec121e3..cfa86a26 100644
--- a/gck/gck-slot.c
+++ b/gck/gck-slot.c
@@ -951,6 +951,7 @@ gck_slots_enumerate_objects (GList *slots,
  * gck_slot_open_session:
  * @self: The slot ot open a session on.
  * @options: The #GckSessionOptions to open a session with.
+ * @interaction: (nullable): The #GTlsInteraction to use, or %NULL.
  * @cancellable: An optional cancellation object, or %NULL.
  * @error: A location to return an error, or %NULL.
  *
@@ -964,16 +965,18 @@ gck_slots_enumerate_objects (GList *slots,
 GckSession *
 gck_slot_open_session (GckSlot *self,
                        GckSessionOptions options,
+                       GTlsInteraction *interaction,
                        GCancellable *cancellable,
                        GError **error)
 {
-       return gck_slot_open_session_full (self, options, 0, NULL, NULL, cancellable, error);
+       return gck_slot_open_session_full (self, options, interaction, 0, NULL, NULL, cancellable, error);
 }
 
 /**
  * gck_slot_open_session_full: (skip)
  * @self: The slot to open a session on.
  * @options: The options to open the new session with.
+ * @interaction: (nullable): The #GTlsInteraction to use, or %NULL.
  * @pkcs11_flags: Additional raw PKCS#11 flags.
  * @app_data: Application data for notification callback.
  * @notify: PKCS#11 notification callback.
@@ -990,6 +993,7 @@ gck_slot_open_session (GckSlot *self,
 GckSession *
 gck_slot_open_session_full (GckSlot *self,
                             GckSessionOptions options,
+                            GTlsInteraction *interaction,
                             gulong pkcs11_flags,
                             gpointer app_data,
                             CK_NOTIFY notify,
@@ -998,6 +1002,7 @@ gck_slot_open_session_full (GckSlot *self,
 {
        return g_initable_new (GCK_TYPE_SESSION, cancellable, error,
                               "options", options,
+                              "interaction", interaction,
                               "slot", self,
                               "opening-flags", pkcs11_flags,
                               "app-data", app_data,
@@ -1008,6 +1013,7 @@ gck_slot_open_session_full (GckSlot *self,
  * gck_slot_open_session_async:
  * @self: The slot to open a session on.
  * @options: The options to open the new session with.
+ * @interaction: (nullable): The #GTlsInteraction to use, or %NULL.
  * @cancellable: Optional cancellation object, or %NULL.
  * @callback: Called when the operation completes.
  * @user_data: Data to pass to the callback.
@@ -1020,11 +1026,12 @@ gck_slot_open_session_full (GckSlot *self,
 void
 gck_slot_open_session_async (GckSlot *self,
                              GckSessionOptions options,
+                             GTlsInteraction *interaction,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer user_data)
 {
-       gck_slot_open_session_full_async (self, options, 0UL, NULL, NULL, cancellable, callback, user_data);
+       gck_slot_open_session_full_async (self, options, interaction, 0UL, NULL, NULL, cancellable, callback, 
user_data);
 }
 
 static void
@@ -1049,6 +1056,7 @@ on_open_session_complete (GObject *source,
  * gck_slot_open_session_full_async: (skip)
  * @self: The slot to open a session on.
  * @options: Options to open the new session with.
+ * @interaction: (nullable): The #GTlsInteraction to use, or %NULL.
  * @pkcs11_flags: Additional raw PKCS#11 flags.
  * @app_data: Application data for notification callback.
  * @notify: PKCS#11 notification callback.
@@ -1064,6 +1072,7 @@ on_open_session_complete (GObject *source,
 void
 gck_slot_open_session_full_async (GckSlot *self,
                                   GckSessionOptions options,
+                                  GTlsInteraction *interaction,
                                   gulong pkcs11_flags,
                                   gpointer app_data,
                                   CK_NOTIFY notify,
@@ -1083,6 +1092,7 @@ gck_slot_open_session_full_async (GckSlot *self,
                                    cancellable, on_open_session_complete,
                                    g_steal_pointer (&task),
                                    "options", options,
+                                   "interaction", interaction,
                                    "slot", self,
                                    "opening-flags", pkcs11_flags,
                                    "app-data", app_data,
diff --git a/gck/gck.h b/gck/gck.h
index 67fd18e9..bb85aba2 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -213,7 +213,7 @@ GckBuilder *         gck_builder_new                        (GckBuilderFlags fla
 
 GckBuilder *         gck_builder_ref                        (GckBuilder *builder);
 
-void                 gck_builder_unref                      (gpointer builder);
+void                 gck_builder_unref                      (GckBuilder *builder);
 
 void                 gck_builder_init                       (GckBuilder *builder);
 
@@ -747,11 +747,13 @@ gboolean            gck_slot_has_flags                      (GckSlot *self,
 
 GckSession*         gck_slot_open_session                   (GckSlot *self,
                                                              GckSessionOptions options,
+                                                             GTlsInteraction *interaction,
                                                              GCancellable *cancellable,
                                                              GError **error);
 
 GckSession*         gck_slot_open_session_full              (GckSlot *self,
                                                              GckSessionOptions options,
+                                                             GTlsInteraction *interaction,
                                                              gulong pkcs11_flags,
                                                              gpointer app_data,
                                                              CK_NOTIFY notify,
@@ -760,12 +762,14 @@ GckSession*         gck_slot_open_session_full              (GckSlot *self,
 
 void                gck_slot_open_session_async             (GckSlot *self,
                                                              GckSessionOptions options,
+                                                             GTlsInteraction *interaction,
                                                              GCancellable *cancellable,
                                                              GAsyncReadyCallback callback,
                                                              gpointer user_data);
 
 void                gck_slot_open_session_full_async        (GckSlot *self,
                                                              GckSessionOptions options,
+                                                             GTlsInteraction *interaction,
                                                              gulong pkcs11_flags,
                                                              gpointer app_data,
                                                              CK_NOTIFY notify,
diff --git a/gck/meson.build b/gck/meson.build
index ee217a9c..78a2ff8b 100644
--- a/gck/meson.build
+++ b/gck/meson.build
@@ -17,7 +17,6 @@ gck_sources_public = files(
 
 gck_sources_private = files(
   'gck-call.c',
-  'gck-interaction.c',
 )
 
 gck_headers = files(
diff --git a/gck/test-gck-crypto.c b/gck/test-gck-crypto.c
index b7e21188..e6286ff9 100644
--- a/gck/test-gck-crypto.c
+++ b/gck/test-gck-crypto.c
@@ -27,6 +27,7 @@
 #include "gck/gck-test.h"
 
 #include "egg/egg-testing.h"
+#include "egg/mock-interaction.h"
 
 #include <glib.h>
 
@@ -54,6 +55,7 @@ setup (Test *test, gconstpointer unused)
        GError *err = NULL;
        GList *slots;
        GckSlot *slot;
+       GTlsInteraction *interaction;
 
        /* Successful load */
        test->module = gck_module_initialize (_GCK_TEST_MODULE_PATH, NULL, &err);
@@ -64,7 +66,7 @@ setup (Test *test, gconstpointer unused)
        slots = gck_module_get_slots (test->module, TRUE);
        g_assert_nonnull (slots);
 
-       test->session = gck_slot_open_session (slots->data, 0, NULL, &err);
+       test->session = gck_slot_open_session (slots->data, 0, NULL, NULL, &err);
        g_assert_no_error (err);
        g_assert_true (GCK_IS_SESSION (test->session));
        g_object_add_weak_pointer (G_OBJECT (test->session), (gpointer *)&test->session);
@@ -74,6 +76,10 @@ setup (Test *test, gconstpointer unused)
 
        test->session_with_auth = gck_session_from_handle (slot, gck_session_get_handle (test->session), 
GCK_SESSION_AUTHENTICATE);
        g_signal_connect (test->session_with_auth, "discard-handle", G_CALLBACK (on_discard_handle_ignore), 
NULL);
+       interaction = mock_interaction_new ("booo");
+       gck_session_set_interaction (test->session_with_auth, interaction);
+       g_object_unref (interaction);
+
        g_assert_nonnull (test->session_with_auth);
        g_object_add_weak_pointer (G_OBJECT (test->session_with_auth), (gpointer *)&test->session_with_auth);
 
@@ -178,18 +184,6 @@ check_key_with_value (GckSession *session, GckObject *key, CK_OBJECT_CLASS klass
        gck_attributes_unref (attrs);
 }
 
-static gboolean
-authenticate_object (GckSlot *module, GckObject *object, gchar *label, gchar **password)
-{
-       g_assert_true (GCK_IS_MODULE (module));
-       g_assert_true (GCK_IS_OBJECT (object));
-       g_assert_nonnull (password);
-       g_assert_null (*password);
-
-       *password = g_strdup ("booo");
-       return TRUE;
-}
-
 static void
 test_encrypt (Test *test, gconstpointer unused)
 {
@@ -306,9 +300,6 @@ test_sign (Test *test, gconstpointer unused)
        guchar *output;
        gsize n_output;
 
-       /* Enable auto-login on this test->session, see previous test */
-       g_signal_connect (test->module, "authenticate-object", G_CALLBACK (authenticate_object), NULL);
-
        /* Find the right key */
        key = find_key (test->session_with_auth, CKA_SIGN, CKM_MOCK_PREFIX);
        g_assert_nonnull (key);
@@ -345,11 +336,14 @@ test_verify (Test *test, gconstpointer unused)
        GckMechanism mech = { CKM_MOCK_PREFIX, (guchar *)"my-prefix:", 10 };
        GError *error = NULL;
        GAsyncResult *result = NULL;
+       GTlsInteraction *interaction;
        GckObject *key;
        gboolean ret;
 
        /* Enable auto-login on this session, shouldn't be needed */
-       g_signal_connect (test->module, "authenticate-object", G_CALLBACK (authenticate_object), NULL);
+       interaction = mock_interaction_new ("booo");
+       gck_session_set_interaction (test->session, interaction);
+       g_object_unref (interaction);
 
        /* Find the right key */
        key = find_key (test->session, CKA_VERIFY, CKM_MOCK_PREFIX);
diff --git a/gck/test-gck-enumerator.c b/gck/test-gck-enumerator.c
index 6881af36..addfe337 100644
--- a/gck/test-gck-enumerator.c
+++ b/gck/test-gck-enumerator.c
@@ -280,8 +280,8 @@ test_attribute_match (Test *test, gconstpointer unused)
 }
 
 static void
-test_authenticate_interaction (Test *test,
-                               gconstpointer unused)
+test_authenticate (Test *test,
+                   gconstpointer unused)
 {
        GTlsInteraction *interaction;
        GTlsInteraction *check;
@@ -317,54 +317,6 @@ test_authenticate_interaction (Test *test,
        g_assert_null (interaction);
 }
 
-static gboolean
-on_authenticate_token (GckModule *module,
-                       GckSlot *slot,
-                       gchar *label,
-                       gchar **password,
-                       gpointer unused)
-{
-       g_assert_true (unused == GUINT_TO_POINTER (35));
-       g_assert_nonnull (password);
-       g_assert_null (*password);
-       g_assert_true (GCK_IS_MODULE (module));
-       g_assert_true (GCK_IS_SLOT (slot));
-
-       *password = g_strdup ("booo");
-       return TRUE;
-}
-
-static void
-test_authenticate_compat (Test *test,
-                          gconstpointer unused)
-{
-       GckUriData *uri_data;
-       GError *error = NULL;
-       GckEnumerator *en;
-       GckObject *obj;
-       gulong sig;
-
-       sig = g_signal_connect (test->modules->data, "authenticate-slot",
-                               G_CALLBACK (on_authenticate_token), GUINT_TO_POINTER (35));
-
-       uri_data = gck_uri_data_new ();
-       en = _gck_enumerator_new_for_modules (test->modules, GCK_SESSION_LOGIN_USER, uri_data);
-       g_assert_true (GCK_IS_ENUMERATOR (en));
-       g_object_add_weak_pointer (G_OBJECT (en), (gpointer *)&en);
-
-       obj = gck_enumerator_next (en, NULL, &error);
-       g_assert_true (GCK_IS_OBJECT (obj));
-       g_object_add_weak_pointer (G_OBJECT (obj), (gpointer *)&obj);
-
-       g_object_unref (obj);
-       g_object_unref (en);
-
-       g_signal_handler_disconnect (test->modules->data, sig);
-
-       g_assert_null (obj);
-       g_assert_null (en);
-}
-
 static void
 test_token_match (Test *test, gconstpointer unused)
 {
@@ -617,8 +569,7 @@ main (int argc, char **argv)
        g_test_add ("/gck/enumerator/next_n", Test, NULL, setup, test_next_n, teardown);
        g_test_add ("/gck/enumerator/next_async", Test, NULL, setup, test_next_async, teardown);
        g_test_add ("/gck/enumerator/session", Test, NULL, setup, test_enumerate_session, teardown);
-       g_test_add ("/gck/enumerator/authenticate-interaction", Test, NULL, setup, 
test_authenticate_interaction, teardown);
-       g_test_add ("/gck/enumerator/authenticate-compat", Test, NULL, setup, test_authenticate_compat, 
teardown);
+       g_test_add ("/gck/enumerator/authenticate", Test, NULL, setup, test_authenticate, teardown);
        g_test_add ("/gck/enumerator/attribute_match", Test, NULL, setup, test_attribute_match, teardown);
        g_test_add ("/gck/enumerator/token_match", Test, NULL, setup, test_token_match, teardown);
        g_test_add ("/gck/enumerator/attribute_get", Test, NULL, setup, test_attribute_get, teardown);
diff --git a/gck/test-gck-object.c b/gck/test-gck-object.c
index 4741898e..438ce76a 100644
--- a/gck/test-gck-object.c
+++ b/gck/test-gck-object.c
@@ -60,7 +60,7 @@ setup (Test *test, gconstpointer unused)
        g_object_ref (test->slot);
        gck_list_unref_free (slots);
 
-       test->session = gck_slot_open_session (test->slot, 0, NULL, &err);
+       test->session = gck_slot_open_session (test->slot, 0, NULL, NULL, &err);
        g_assert_no_error (err);
        g_assert_true (GCK_IS_SESSION (test->session));
 
@@ -108,7 +108,7 @@ test_object_equals_hash (Test *test, gconstpointer unused)
        g_assert_true (gck_object_equal (test->object, test->object));
 
        other_slot = g_object_new (GCK_TYPE_SLOT, "module", test->module, "handle", GCK_MOCK_SLOT_TWO_ID, 
NULL);
-       other_session = gck_slot_open_session (other_slot, 0, NULL, &err);
+       other_session = gck_slot_open_session (other_slot, 0, NULL, NULL, &err);
        g_assert_no_error (err);
        g_assert_true (GCK_IS_SESSION (other_session));
        other_object = gck_object_from_handle (other_session, gck_object_get_handle (test->object));
diff --git a/gck/test-gck-session.c b/gck/test-gck-session.c
index 0a296df4..4a8ab488 100644
--- a/gck/test-gck-session.c
+++ b/gck/test-gck-session.c
@@ -61,7 +61,7 @@ setup (Test *test, gconstpointer unused)
        gck_list_unref_free (slots);
        g_object_add_weak_pointer (G_OBJECT (test->slot), (gpointer *)&test->slot);
 
-       test->session = gck_slot_open_session (test->slot, 0, NULL, &err);
+       test->session = gck_slot_open_session (test->slot, 0, NULL, NULL, &err);
        g_assert_no_error (err);
        g_assert_true (GCK_IS_SESSION (test->session));
        g_object_add_weak_pointer (G_OBJECT (test->session), (gpointer *)&test->session);
@@ -127,14 +127,14 @@ test_open_close_session (Test *test, gconstpointer unused)
        GAsyncResult *result = NULL;
        GError *err = NULL;
 
-       sess = gck_slot_open_session (test->slot, 0, NULL, &err);
+       sess = gck_slot_open_session (test->slot, 0, NULL, NULL, &err);
        g_assert_no_error (err);
        g_assert_true (GCK_IS_SESSION (sess));
 
        g_object_unref (sess);
 
        /* Test opening async */
-       gck_slot_open_session_async (test->slot, 0, NULL, fetch_async_result, &result);
+       gck_slot_open_session_async (test->slot, 0, NULL, NULL, fetch_async_result, &result);
 
        egg_test_wait_until (500);
        g_assert_nonnull (result);
@@ -418,19 +418,6 @@ test_login_interactive (Test *test,
        g_object_unref (interaction);
 }
 
-static gboolean
-authenticate_token (GckModule *module, GckSlot *slot, gchar *label, gchar **password, gpointer unused)
-{
-       g_assert_true (unused == GUINT_TO_POINTER (35));
-       g_assert_nonnull (password);
-       g_assert_null (*password);
-       g_assert_true (GCK_IS_MODULE (module));
-       g_assert_true (GCK_IS_SLOT (slot));
-
-       *password = g_strdup ("booo");
-       return TRUE;
-}
-
 static void
 test_auto_login (Test *test, gconstpointer unused)
 {
@@ -440,6 +427,7 @@ test_auto_login (Test *test, gconstpointer unused)
        GAsyncResult *result = NULL;
        GError *err = NULL;
        GckAttributes *attrs;
+       GTlsInteraction *test_interaction;
        gboolean ret;
 
        gck_builder_add_ulong (&builder, CKA_CLASS, CKO_DATA);
@@ -454,8 +442,9 @@ test_auto_login (Test *test, gconstpointer unused)
        g_clear_error (&err);
 
        /* Setup for auto login */
-       g_signal_connect (test->module, "authenticate-slot", G_CALLBACK (authenticate_token), 
GUINT_TO_POINTER (35));
-       new_session = gck_slot_open_session (test->slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, 
NULL, &err);
+       test_interaction = mock_interaction_new ("booo");
+       new_session = gck_slot_open_session (test->slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, 
test_interaction, NULL, &err);
+       g_object_unref (test_interaction);
        g_assert_no_error (err);
        g_assert_true (GCK_IS_SESSION (new_session));
 
@@ -473,10 +462,12 @@ test_auto_login (Test *test, gconstpointer unused)
        g_object_unref (new_session);
 
        /* Now try the same thing, but asyncronously */
-       gck_slot_open_session_async (test->slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, NULL, 
fetch_async_result, &result);
+       test_interaction = mock_interaction_new ("booo");
+       gck_slot_open_session_async (test->slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, 
test_interaction, NULL, fetch_async_result, &result);
        egg_test_wait_until (500);
        g_assert_nonnull (result);
        new_session = gck_slot_open_session_finish (test->slot, result, &err);
+       g_object_unref (test_interaction);
        g_assert_no_error (err);
        g_assert_true (GCK_IS_SESSION (new_session));
        g_object_unref (result);
diff --git a/gcr/gcr-trust.c b/gcr/gcr-trust.c
index 786ab4f6..16e1d879 100644
--- a/gcr/gcr-trust.c
+++ b/gcr/gcr-trust.c
@@ -307,7 +307,7 @@ perform_add_pinned_certificate (GckAttributes *search,
                             _("Couldn’t find a place to store the pinned certificate"));
                ret = FALSE;
        } else {
-               session = gck_slot_open_session (slot, CKF_RW_SESSION, NULL, &lerr);
+               session = gck_slot_open_session (slot, CKF_RW_SESSION, NULL, NULL, &lerr);
                if (session != NULL) {
                        object = gck_session_create_object (session, gck_builder_end (&builder),
                                                            cancellable, &lerr);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]