[gnome-keyring/dbus-api] [pkcs11, gck] Each GckObject now has manager for life.



commit f742ab53fdf67ab17024be36395af0095aab86f7
Author: Stef Walter <stef memberwebs com>
Date:   Fri Aug 21 03:28:59 2009 +0000

    [pkcs11, gck] Each GckObject now has manager for life.
    
    Rearchitect how things work with regard to managers. Each object
    has a manager for life (or null). The gck_object_expose() method
    is used to show and hide the object on the determined manager.

 pkcs11/gck/gck-authenticator.c                     |   15 +++--
 pkcs11/gck/gck-authenticator.h                     |    1 +
 pkcs11/gck/gck-certificate-key.c                   |    5 +-
 pkcs11/gck/gck-certificate-key.h                   |    1 +
 pkcs11/gck/gck-certificate-trust.c                 |    5 +-
 pkcs11/gck/gck-certificate-trust.h                 |    1 +
 pkcs11/gck/gck-certificate.c                       |    9 ++-
 pkcs11/gck/gck-manager.c                           |   32 +++++++---
 pkcs11/gck/gck-manager.h                           |   10 +--
 pkcs11/gck/gck-module.c                            |    6 +-
 pkcs11/gck/gck-object.c                            |   66 +++++++++++++++-----
 pkcs11/gck/gck-object.h                            |    7 ++-
 pkcs11/gck/gck-private-key.c                       |    4 +-
 pkcs11/gck/gck-public-key.c                        |    6 +-
 pkcs11/gck/gck-session.c                           |    9 ++-
 pkcs11/gck/tests/mock-locked-object.c              |    7 ++-
 pkcs11/gck/tests/mock-locked-object.h              |    2 +-
 pkcs11/gck/tests/unit-test-authenticator.c         |   10 ++--
 pkcs11/roots-store/gck-roots-certificate.c         |   14 ++++-
 pkcs11/roots-store/gck-roots-module.c              |    5 +-
 pkcs11/secret-store/gck-secret-collection.c        |   15 +++++
 pkcs11/secret-store/gck-secret-module.c            |    3 +-
 .../tests/unit-test-secret-collection.c            |   31 ++++++---
 pkcs11/secret-store/tests/unit-test-secret-item.c  |    5 +-
 pkcs11/ssh-store/gck-ssh-module.c                  |   14 +---
 pkcs11/ssh-store/gck-ssh-private-key.c             |   11 +++-
 pkcs11/ssh-store/gck-ssh-public-key.c              |    3 +-
 pkcs11/ssh-store/tests/unit-test-private-key.c     |    2 +-
 pkcs11/user-store/gck-user-private-key.c           |    6 +-
 pkcs11/user-store/gck-user-public-key.c            |    6 +-
 pkcs11/user-store/gck-user-storage.c               |    5 +-
 31 files changed, 220 insertions(+), 96 deletions(-)
---
diff --git a/pkcs11/gck/gck-authenticator.c b/pkcs11/gck/gck-authenticator.c
index 6818a86..ef8dcb6 100644
--- a/pkcs11/gck/gck-authenticator.c
+++ b/pkcs11/gck/gck-authenticator.c
@@ -62,6 +62,7 @@ factory_create_authenticator (GckSession *session, GckTransaction *transaction,
 	CK_OBJECT_HANDLE handle;
 	GckAuthenticator *auth;
 	CK_ATTRIBUTE *attr;
+	GckManager *manager;
 	GckObject *object;
 	CK_RV rv;
 	
@@ -87,7 +88,9 @@ factory_create_authenticator (GckSession *session, GckTransaction *transaction,
 
  	gck_attributes_consume (attrs, n_attrs, CKA_VALUE, CKA_GNOME_OBJECT, G_MAXULONG);
 	
-	rv = gck_authenticator_create (object, attr ? attr->pValue : NULL, 
+	manager = gck_manager_for_template (attrs, n_attrs, session);
+	rv = gck_authenticator_create (object, manager,
+	                               attr ? attr->pValue : NULL,
 	                               attr ? attr->ulValueLen : 0, &auth);
 	if (rv == CKR_OK)
 		*result = GCK_OBJECT (auth);
@@ -301,8 +304,9 @@ gck_authenticator_get_factory (void)
 }
 
 CK_RV
-gck_authenticator_create (GckObject *object, CK_UTF8CHAR_PTR pin,
-                          CK_ULONG n_pin, GckAuthenticator **result)
+gck_authenticator_create (GckObject *object, GckManager *manager,
+                          CK_UTF8CHAR_PTR pin, CK_ULONG n_pin,
+                          GckAuthenticator **result)
 {
 	GckAuthenticator *auth;
 	GckSecret *login = NULL;
@@ -313,8 +317,9 @@ gck_authenticator_create (GckObject *object, CK_UTF8CHAR_PTR pin,
 	
 	login = gck_secret_new_from_login (pin, n_pin);
 	auth = g_object_new (GCK_TYPE_AUTHENTICATOR, 
-	                     "module", gck_object_get_module (object), 
-	                     "login", login, "object", object, NULL);
+	                     "module", gck_object_get_module (object),
+	                     "manager", manager, "login", login,
+	                     "object", object, NULL);
 	g_object_unref (login);
 	
 	/* Now the unlock must work */
diff --git a/pkcs11/gck/gck-authenticator.h b/pkcs11/gck/gck-authenticator.h
index de63d93..a3c8a6a 100644
--- a/pkcs11/gck/gck-authenticator.h
+++ b/pkcs11/gck/gck-authenticator.h
@@ -53,6 +53,7 @@ GType                      gck_authenticator_get_type               (void);
 GckFactoryInfo*            gck_authenticator_get_factory            (void);
 
 CK_RV                      gck_authenticator_create                 (GckObject *object,
+                                                                     GckManager *manager,
                                                                      CK_UTF8CHAR_PTR pin,
                                                                      CK_ULONG n_pin,
                                                                      GckAuthenticator **result);
diff --git a/pkcs11/gck/gck-certificate-key.c b/pkcs11/gck/gck-certificate-key.c
index d0e05a3..4874e98 100644
--- a/pkcs11/gck/gck-certificate-key.c
+++ b/pkcs11/gck/gck-certificate-key.c
@@ -137,9 +137,10 @@ gck_certificate_key_class_init (GckCertificateKeyClass *klass)
  */
 
 GckCertificateKey*
-gck_certificate_key_new (GckModule *module, GckCertificate *cert)
+gck_certificate_key_new (GckModule *module, GckManager *manager, GckCertificate *cert)
 {
-	return g_object_new (GCK_TYPE_CERTIFICATE_KEY, "module", module, "certificate", cert, NULL);
+	return g_object_new (GCK_TYPE_CERTIFICATE_KEY, "module", module,
+	                     "manager", manager, "certificate", cert, NULL);
 }
 
 GckCertificate*
diff --git a/pkcs11/gck/gck-certificate-key.h b/pkcs11/gck/gck-certificate-key.h
index 1535e7b..7bac89c 100644
--- a/pkcs11/gck/gck-certificate-key.h
+++ b/pkcs11/gck/gck-certificate-key.h
@@ -49,6 +49,7 @@ struct _GckCertificateKeyClass {
 GType               gck_certificate_key_get_type               (void);
 
 GckCertificateKey*  gck_certificate_key_new                    (GckModule *module,
+                                                                GckManager *manager,
                                                                 GckCertificate *cert);
 
 GckCertificate*     gck_certificate_key_get_certificate        (GckCertificateKey *self);
diff --git a/pkcs11/gck/gck-certificate-trust.c b/pkcs11/gck/gck-certificate-trust.c
index bda4a9e..41db470 100644
--- a/pkcs11/gck/gck-certificate-trust.c
+++ b/pkcs11/gck/gck-certificate-trust.c
@@ -362,9 +362,10 @@ gck_certificate_trust_class_init (GckCertificateTrustClass *klass)
  */
 
 GckCertificateTrust*
-gck_certificate_trust_new (GckModule *module, GckCertificate *cert)
+gck_certificate_trust_new (GckModule *module, GckManager *manager, GckCertificate *cert)
 {
-	return g_object_new (GCK_TYPE_CERTIFICATE_TRUST, "module", module, "certificate", cert, NULL);
+	return g_object_new (GCK_TYPE_CERTIFICATE_TRUST, "module", module,
+	                     "manager", manager, "certificate", cert, NULL);
 }
 
 GckCertificate*
diff --git a/pkcs11/gck/gck-certificate-trust.h b/pkcs11/gck/gck-certificate-trust.h
index 518ad16..6811a77 100644
--- a/pkcs11/gck/gck-certificate-trust.h
+++ b/pkcs11/gck/gck-certificate-trust.h
@@ -49,6 +49,7 @@ struct _GckCertificateTrustClass {
 GType                 gck_certificate_trust_get_type               (void);
 
 GckCertificateTrust*  gck_certificate_trust_new                    (GckModule *module,
+                                                                    GckManager *manager,
                                                                     GckCertificate *cert);
 
 GckCertificate*       gck_certificate_trust_get_certificate        (GckCertificateTrust *self);
diff --git a/pkcs11/gck/gck-certificate.c b/pkcs11/gck/gck-certificate.c
index e029dd1..a830fe3 100644
--- a/pkcs11/gck/gck-certificate.c
+++ b/pkcs11/gck/gck-certificate.c
@@ -261,7 +261,10 @@ factory_create_certificate (GckSession *session, GckTransaction *transaction,
 		return;
 	}
 	
-	cert = g_object_new (GCK_TYPE_CERTIFICATE, "module", gck_session_get_module (session), NULL);
+	cert = g_object_new (GCK_TYPE_CERTIFICATE,
+	                     "module", gck_session_get_module (session),
+	                     "manager", gck_manager_for_template (attrs, n_attrs, session),
+	                     NULL);
 	
 	/* Load the certificate from the data specified */
 	if (!gck_serializable_load (GCK_SERIALIZABLE (cert), NULL, attr->pValue, attr->ulValueLen)) {
@@ -558,7 +561,9 @@ gck_certificate_real_load (GckSerializable *base, GckSecret *login, const guchar
 	/* Create ourselves a public key with that */
 	wrapper = gck_sexp_new (sexp);
 	if (!self->pv->key)
-		self->pv->key = gck_certificate_key_new (gck_object_get_module (GCK_OBJECT (self)), self);
+		self->pv->key = gck_certificate_key_new (gck_object_get_module (GCK_OBJECT (self)), 
+		                                         gck_object_get_manager (GCK_OBJECT (self)),
+		                                         self);
 	gck_key_set_base_sexp (GCK_KEY (self->pv->key), wrapper);
 	gck_sexp_unref (wrapper);
 		
diff --git a/pkcs11/gck/gck-manager.c b/pkcs11/gck/gck-manager.c
index 9fbe867..382c4f8 100644
--- a/pkcs11/gck/gck-manager.c
+++ b/pkcs11/gck/gck-manager.c
@@ -24,6 +24,8 @@
 #include "gck-attributes.h"
 #include "gck-manager.h"
 #include "gck-marshal.h"
+#include "gck-module.h"
+#include "gck-session.h"
 #include "gck-util.h"
 
 #include <glib.h>
@@ -70,6 +72,10 @@ typedef struct _Finder {
 
 G_DEFINE_TYPE(GckManager, gck_manager, G_TYPE_OBJECT);
 
+/* Friend functions for GckObject */
+void  _gck_manager_register_object    (GckManager *self, GckObject *object);
+void  _gck_manager_unregister_object  (GckManager *self, GckObject *object);
+
 /* -----------------------------------------------------------------------------
  * HELPERS
  */
@@ -411,7 +417,7 @@ add_object (GckManager *self, GckObject *object)
 	
 	g_assert (GCK_IS_MANAGER (self));
 	g_assert (GCK_IS_OBJECT (object));
-	g_assert (gck_object_get_manager (object) == NULL);
+	g_assert (gck_object_get_manager (object) == self);
 	
 	handle = gck_object_get_handle (object);
 	if (!handle) {
@@ -427,7 +433,6 @@ add_object (GckManager *self, GckObject *object)
 	
 	/* Note objects is being managed */
 	self->pv->objects = g_list_prepend (self->pv->objects, object);
-	g_object_set (object, "manager", self, NULL);
 	
 	/* Now index the object properly */
 	g_hash_table_foreach (self->pv->index_by_attribute, index_object_each, object);
@@ -459,7 +464,6 @@ remove_object (GckManager *self, GckObject *object)
 	
 	/* Release object management */		
 	self->pv->objects = g_list_remove (self->pv->objects, object);
-	g_object_set (object, "manager", NULL, NULL);
 
 	/* Tell everyone this object is gone */
 	g_signal_emit (self, signals[OBJECT_REMOVED], 0, object);
@@ -693,8 +697,8 @@ gck_manager_dispose (GObject *obj)
 
 	/* Unregister all objects */
 	objects = g_list_copy (self->pv->objects);
-	for (l = objects; l; l = g_list_next (l)) 
-		gck_manager_unregister_object (self, GCK_OBJECT (l->data));
+	for (l = objects; l; l = g_list_next (l))
+		remove_object (self, GCK_OBJECT (l->data));
 	g_list_free (objects);
 	
 	g_return_if_fail (self->pv->objects == NULL);
@@ -795,17 +799,17 @@ gck_manager_add_property_index (GckManager *self, const gchar *property, gboolea
 }
 
 void
-gck_manager_register_object (GckManager *self, GckObject *object)
+_gck_manager_register_object (GckManager *self, GckObject *object)
 {
 	g_return_if_fail (GCK_IS_MANAGER (self));
 	g_return_if_fail (GCK_IS_OBJECT (object));
-	g_return_if_fail (gck_object_get_manager (object) == NULL);
+	g_return_if_fail (gck_object_get_manager (object) == self);
 
 	add_object (self, object);
 }
 
 void
-gck_manager_unregister_object (GckManager *self, GckObject *object)
+_gck_manager_unregister_object (GckManager *self, GckObject *object)
 {
 	g_return_if_fail (GCK_IS_MANAGER (self));
 	g_return_if_fail (GCK_IS_OBJECT (object));
@@ -974,3 +978,15 @@ gck_manager_find_handles (GckManager *self, gboolean also_private,
 
 	return CKR_OK;
 }
+
+/* Odd place for this function */
+
+GckManager*
+gck_manager_for_template (CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs, GckSession *session)
+{
+	gboolean is_token;
+	if (!gck_attributes_find_boolean (attrs, n_attrs, CKA_TOKEN, &is_token) || !is_token)
+		return gck_session_get_manager (session);
+	else
+		return gck_module_get_manager (gck_session_get_module (session));
+}
diff --git a/pkcs11/gck/gck-manager.h b/pkcs11/gck/gck-manager.h
index 54d2a6c..0b7c954 100644
--- a/pkcs11/gck/gck-manager.h
+++ b/pkcs11/gck/gck-manager.h
@@ -83,6 +83,10 @@ struct _GckManagerClass {
 
 GType                   gck_manager_get_type                    (void) G_GNUC_CONST;
 
+GckManager*             gck_manager_for_template                (CK_ATTRIBUTE_PTR attrs,
+                                                                 CK_ULONG n_attrs,
+                                                                 GckSession *session);
+
 gboolean                gck_manager_get_for_token               (GckManager *self);
 
 void                    gck_manager_add_attribute_index         (GckManager *self,
@@ -93,12 +97,6 @@ void                    gck_manager_add_property_index          (GckManager *sel
                                                                  const gchar *property,
                                                                  gboolean unique);
 
-void                    gck_manager_register_object             (GckManager *self, 
-                                                                 GckObject *object);
-
-void                    gck_manager_unregister_object           (GckManager *self, 
-                                                                 GckObject *object);
-
 GckObject*              gck_manager_find_by_handle              (GckManager *self,
                                                                  CK_OBJECT_HANDLE obj);
 
diff --git a/pkcs11/gck/gck-module.c b/pkcs11/gck/gck-module.c
index 077af6b..aaa521e 100644
--- a/pkcs11/gck/gck-module.c
+++ b/pkcs11/gck/gck-module.c
@@ -391,7 +391,7 @@ remove_transient_object (GckModule *self, GckTransaction *transaction, GckObject
 
 	g_object_ref (object);
 
-	gck_manager_unregister_object (self->pv->token_manager, object);
+	gck_object_expose (object, FALSE);
 	if (!g_hash_table_remove (self->pv->transient_objects, object))
 		g_return_if_reached ();
 	g_object_set (object, "store", NULL, NULL);
@@ -421,12 +421,12 @@ add_transient_object (GckModule *self, GckTransaction *transaction, GckObject *o
 	g_assert (GCK_IS_OBJECT (object));
 
 	/* Must not already be associated with a session or manager */
-	g_return_if_fail (gck_object_get_manager (object) == NULL);
+	g_return_if_fail (gck_object_get_manager (object) == self->pv->token_manager);
 	g_return_if_fail (g_hash_table_lookup (self->pv->transient_objects, object) == NULL);
 
 	g_hash_table_insert (self->pv->transient_objects, object, g_object_ref (object));
-	gck_manager_register_object (self->pv->token_manager, object);
 	g_object_set (object, "store", self->pv->transient_store, NULL);
+	gck_object_expose (object, TRUE);
 
 	if (transaction) {
 		gck_transaction_add (transaction, self,
diff --git a/pkcs11/gck/gck-object.c b/pkcs11/gck/gck-object.c
index cf0b25a..3f7d64f 100644
--- a/pkcs11/gck/gck-object.c
+++ b/pkcs11/gck/gck-object.c
@@ -43,6 +43,7 @@ enum {
 };
 
 enum {
+	EXPOSE_OBJECT,
 	NOTIFY_ATTRIBUTE,
 	LAST_SIGNAL
 };
@@ -60,11 +61,16 @@ struct _GckObjectPrivate {
 	GckManager *manager;
 	GckStore *store;
 	gchar *unique;
+	gboolean exposed;
 	GckObjectTransient *transient;
 };
 
 G_DEFINE_TYPE (GckObject, gck_object, G_TYPE_OBJECT);
 
+/* Private friend functions from the manager */
+void  _gck_manager_register_object   (GckManager *self, GckObject *object);
+void  _gck_manager_unregister_object (GckManager *self, GckObject *object);
+
 /* -----------------------------------------------------------------------------
  * INTERNAL 
  */
@@ -275,6 +281,19 @@ gck_object_real_unlock (GckObject *self, GckAuthenticator *auth)
 	return CKR_FUNCTION_FAILED;
 }
 
+static void
+gck_object_real_expose_object (GckObject *self, gboolean expose)
+{
+	g_return_if_fail (expose != self->pv->exposed);
+	g_return_if_fail (self->pv->manager);
+
+	self->pv->exposed = expose;
+	if (expose)
+		_gck_manager_register_object (self->pv->manager, self);
+	else
+		_gck_manager_unregister_object (self->pv->manager, self);
+}
+
 static GObject* 
 gck_object_constructor (GType type, guint n_props, GObjectConstructParam *props) 
 {
@@ -299,10 +318,15 @@ gck_object_dispose (GObject *obj)
 	GckObject *self = GCK_OBJECT (obj);
 	GckObjectTransient *transient;
 	
-	if (self->pv->manager)
-		gck_manager_unregister_object (self->pv->manager, self);
-	g_assert (self->pv->manager == NULL);
-	
+	if (self->pv->manager) {
+		if (self->pv->exposed)
+			gck_object_expose (self, FALSE);
+		g_return_if_fail (!self->pv->exposed);
+		g_object_remove_weak_pointer (G_OBJECT (self->pv->manager),
+		                              (gpointer*)&(self->pv->manager));
+		self->pv->manager = NULL;
+	}
+
 	g_object_set (self, "store", NULL, NULL);
 	g_assert (self->pv->store == NULL);
 
@@ -341,7 +365,6 @@ gck_object_set_property (GObject *obj, guint prop_id, const GValue *value,
                            GParamSpec *pspec)
 {
 	GckObject *self = GCK_OBJECT (obj);
-	GckManager *manager;
 	GckStore *store;
 	
 	switch (prop_id) {
@@ -355,18 +378,12 @@ gck_object_set_property (GObject *obj, guint prop_id, const GValue *value,
 		g_object_weak_ref (G_OBJECT (self->pv->module), module_went_away, self);
 		break;
 	case PROP_MANAGER:
-		manager = g_value_get_object (value);
+		g_return_if_fail (!self->pv->manager);
+		self->pv->manager = g_value_get_object (value);
 		if (self->pv->manager) {
-			g_return_if_fail (!manager);
-			g_object_remove_weak_pointer (G_OBJECT (self->pv->manager), 
-			                              (gpointer*)&(self->pv->manager));
-		}
-		self->pv->manager = manager;
-		if (self->pv->manager)
 			g_object_add_weak_pointer (G_OBJECT (self->pv->manager), 
 			                           (gpointer*)&(self->pv->manager));
-		
-		g_object_notify (G_OBJECT (self), "manager");
+		}
 		break;
 	case PROP_STORE:
 		store = g_value_get_object (value);
@@ -440,6 +457,8 @@ gck_object_class_init (GckObjectClass *klass)
 	klass->set_attribute = gck_object_real_set_attribute;
 	klass->create_attributes = gck_object_real_create_attributes;
 	
+	klass->expose_object = gck_object_real_expose_object;
+
 	g_object_class_install_property (gobject_class, PROP_HANDLE,
 	           g_param_spec_ulong ("handle", "Handle", "Object handle",
 	                               0, G_MAXULONG, 0, G_PARAM_READWRITE));
@@ -450,7 +469,7 @@ gck_object_class_init (GckObjectClass *klass)
 	
 	g_object_class_install_property (gobject_class, PROP_MANAGER,
 	           g_param_spec_object ("manager", "Manager", "Object manager", 
-	                                GCK_TYPE_MANAGER, G_PARAM_READWRITE));
+	                                GCK_TYPE_MANAGER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 	
 	g_object_class_install_property (gobject_class, PROP_STORE,
 	           g_param_spec_object ("store", "Store", "Object store", 
@@ -460,6 +479,11 @@ gck_object_class_init (GckObjectClass *klass)
 	           g_param_spec_string ("unique", "Unique Identifer", "Machine unique identifier", 
 	                                NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 	
+	signals[EXPOSE_OBJECT] = g_signal_new ("expose-object", GCK_TYPE_OBJECT,
+	                                       G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GckObjectClass, expose_object),
+		                               NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, 
+		                               G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
 	signals[NOTIFY_ATTRIBUTE] = g_signal_new ("notify-attribute", GCK_TYPE_OBJECT, 
 	                                G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GckObjectClass, notify_attribute),
 	                                NULL, NULL, g_cclosure_marshal_VOID__ULONG, 
@@ -732,3 +756,15 @@ gck_object_destroy (GckObject *self, GckTransaction *transaction)
 
 	g_object_unref (self);
 }
+
+void
+gck_object_expose (GckObject *self, gboolean expose)
+{
+	if (!expose && !self)
+		return;
+
+	g_return_if_fail (GCK_IS_OBJECT (self));
+
+	if (self->pv->exposed != expose)
+		g_signal_emit (self, signals[EXPOSE_OBJECT], 0, expose);
+}
diff --git a/pkcs11/gck/gck-object.h b/pkcs11/gck/gck-object.h
index 814500b..53c9b64 100644
--- a/pkcs11/gck/gck-object.h
+++ b/pkcs11/gck/gck-object.h
@@ -47,7 +47,9 @@ struct _GckObjectClass {
 	GObjectClass parent_class;
 	
 	/* signals ------------------------------------------------------------------ */
-	
+
+	void (*expose_object) (GckObject *object, gboolean exposed);
+
 	void (*notify_attribute) (GckObject *object, CK_ATTRIBUTE_TYPE attr_type);
 	
 	/* virtual methods  --------------------------------------------------------- */
@@ -85,6 +87,9 @@ CK_RV                  gck_object_unlock                 (GckObject *self,
 void                   gck_object_destroy                (GckObject *self,
                                                           GckTransaction *transaction);
 
+void                   gck_object_expose                 (GckObject *self,
+                                                          gboolean expose);
+
 gboolean               gck_object_match                  (GckObject *self,
                                                           GckSession *session,
                                                           CK_ATTRIBUTE_PTR attr);
diff --git a/pkcs11/gck/gck-private-key.c b/pkcs11/gck/gck-private-key.c
index 1d851d7..22e128b 100644
--- a/pkcs11/gck/gck-private-key.c
+++ b/pkcs11/gck/gck-private-key.c
@@ -159,7 +159,9 @@ factory_create_private_key (GckSession *session, GckTransaction *transaction,
 		return;
 	
 	key = g_object_new (GCK_TYPE_PRIVATE_KEY, "base-sexp", sexp,
-	                    "module", gck_session_get_module (session), NULL);
+	                    "module", gck_session_get_module (session),
+	                    "manager", gck_manager_for_template (attrs, n_attrs, session),
+	                    NULL);
 	key->pv->sexp = sexp;
 	*object = GCK_OBJECT (key);
 }
diff --git a/pkcs11/gck/gck-public-key.c b/pkcs11/gck/gck-public-key.c
index 1848956..68b410f 100644
--- a/pkcs11/gck/gck-public-key.c
+++ b/pkcs11/gck/gck-public-key.c
@@ -150,8 +150,10 @@ factory_create_public_key (GckSession *session, GckTransaction *transaction,
 
 	sexp = gck_public_key_create_sexp (session, transaction, attrs, n_attrs);
 	if (sexp != NULL) {
-		*object = g_object_new (GCK_TYPE_PUBLIC_KEY, "base-sexp", sexp, 
-		                        "module", gck_session_get_module (session), NULL);
+		*object = g_object_new (GCK_TYPE_PUBLIC_KEY, "base-sexp", sexp,
+		                        "module", gck_session_get_module (session),
+		                        "manager", gck_manager_for_template (attrs, n_attrs, session),
+		                        NULL);
 		gck_sexp_unref (sexp);
 	}
 }
diff --git a/pkcs11/gck/gck-session.c b/pkcs11/gck/gck-session.c
index c56c515..8d76789 100644
--- a/pkcs11/gck/gck-session.c
+++ b/pkcs11/gck/gck-session.c
@@ -316,7 +316,7 @@ remove_object (GckSession *self, GckTransaction *transaction, GckObject *object)
 	
 	g_object_ref (object);
 	
-	gck_manager_unregister_object (self->pv->manager, object);
+	gck_object_expose (object, FALSE);
 	if (!g_hash_table_remove (self->pv->objects, object))
 		g_return_if_reached ();
 	g_object_set (object, "store", NULL, NULL);
@@ -344,14 +344,14 @@ add_object (GckSession *self, GckTransaction *transaction, GckObject *object)
 	g_assert (GCK_IS_OBJECT (object));
 	
 	/* Must not already be associated with a session or manager */
-	g_return_if_fail (gck_object_get_manager (object) == NULL);
+	g_return_if_fail (gck_object_get_manager (object) == self->pv->manager);
 	g_return_if_fail (g_object_get_data (G_OBJECT (object), "owned-by-session") == NULL);
 	g_return_if_fail (g_hash_table_lookup (self->pv->objects, object) == NULL);
 	
 	g_hash_table_insert (self->pv->objects, object, g_object_ref (object));
 	g_object_set_data (G_OBJECT (object), "owned-by-session", self);
-	gck_manager_register_object (self->pv->manager, object);
 	g_object_set (object, "store", self->pv->store, NULL);
+	gck_object_expose (object, TRUE);
 
 	if (transaction)
 		gck_transaction_add (transaction, self, (GckTransactionFunc)complete_add, 
@@ -690,7 +690,8 @@ gck_session_login_context_specific (GckSession *self, CK_UTF8CHAR_PTR pin, CK_UL
 	g_return_val_if_fail (is_private == TRUE, CKR_GENERAL_ERROR);
 
 	/* Now create the strange object */
-	rv = gck_authenticator_create (self->pv->current_object, pin, n_pin, &authenticator);
+	rv = gck_authenticator_create (self->pv->current_object, self->pv->manager, 
+	                               pin, n_pin, &authenticator);
 	if (rv != CKR_OK)
 		return rv;
 
diff --git a/pkcs11/gck/tests/mock-locked-object.c b/pkcs11/gck/tests/mock-locked-object.c
index 96a37b1..059b742 100644
--- a/pkcs11/gck/tests/mock-locked-object.c
+++ b/pkcs11/gck/tests/mock-locked-object.c
@@ -82,7 +82,10 @@ mock_locked_object_class_init (MockLockedObjectClass *klass)
  */
 
 GckObject*
-mock_locked_object_new (GckModule *module)
+mock_locked_object_new (GckModule *module, GckManager *manager)
 {
-	return g_object_new (MOCK_TYPE_LOCKED_OBJECT, "module", module, NULL);
+	return g_object_new (MOCK_TYPE_LOCKED_OBJECT,
+	                     "module", module,
+	                     "manager", manager,
+	                     NULL);
 }
diff --git a/pkcs11/gck/tests/mock-locked-object.h b/pkcs11/gck/tests/mock-locked-object.h
index 0ed6080..3c8101b 100644
--- a/pkcs11/gck/tests/mock-locked-object.h
+++ b/pkcs11/gck/tests/mock-locked-object.h
@@ -47,6 +47,6 @@ struct _MockLockedObjectClass {
 
 GType                      mock_locked_object_get_type               (void);
 
-GckObject*                 mock_locked_object_new                    (GckModule *module);
+GckObject*                 mock_locked_object_new                    (GckModule *module, GckManager *manager);
 
 #endif /* __MOCK_LOCKED_OBJECT_H__ */
diff --git a/pkcs11/gck/tests/unit-test-authenticator.c b/pkcs11/gck/tests/unit-test-authenticator.c
index ae68c47..099dea1 100644
--- a/pkcs11/gck/tests/unit-test-authenticator.c
+++ b/pkcs11/gck/tests/unit-test-authenticator.c
@@ -47,8 +47,8 @@ DEFINE_SETUP(authenticator_setup)
 	rv = gck_module_C_Login (module, gck_session_get_handle (session), CKU_USER, NULL, 0);
 	g_assert (rv == CKR_OK);
 	
-	object = mock_locked_object_new (module);
-	gck_manager_register_object (gck_module_get_manager (module), object);
+	object = mock_locked_object_new (module, gck_module_get_manager (module));
+	gck_object_expose (object, TRUE);
 }
 
 DEFINE_TEARDOWN(authenticator_teardown)
@@ -181,7 +181,7 @@ DEFINE_TEST(authenticator_uses_property)
 	gint uses;
 	CK_RV rv;
 	
-	rv = gck_authenticator_create (object, (guchar*)"mock", 4, &auth);
+	rv = gck_authenticator_create (object, NULL, (guchar*)"mock", 4, &auth);
 	g_assert (rv == CKR_OK);
 	g_assert (auth);
 	
@@ -206,7 +206,7 @@ DEFINE_TEST(authenticator_object_property)
 	GckObject *check;
 	CK_RV rv;
 	
-	rv = gck_authenticator_create (object, (guchar*)"mock", 4, &auth);
+	rv = gck_authenticator_create (object, NULL, (guchar*)"mock", 4, &auth);
 	g_assert (rv == CKR_OK);
 	g_assert (auth);
 	
@@ -228,7 +228,7 @@ DEFINE_TEST(authenticator_login_property)
 	gsize n_password;
 	CK_RV rv;
 	
-	rv = gck_authenticator_create (object, (guchar*)"mock", 4, &auth);
+	rv = gck_authenticator_create (object, NULL, (guchar*)"mock", 4, &auth);
 	g_assert (rv == CKR_OK);
 	g_assert (auth);
 	
diff --git a/pkcs11/roots-store/gck-roots-certificate.c b/pkcs11/roots-store/gck-roots-certificate.c
index 14c6b53..3c9fdb0 100644
--- a/pkcs11/roots-store/gck-roots-certificate.c
+++ b/pkcs11/roots-store/gck-roots-certificate.c
@@ -26,6 +26,7 @@
 #include "gck/gck-attributes.h"
 #include "gck/gck-certificate-trust.h"
 #include "gck/gck-manager.h"
+#include "gck/gck-module.h"
 #include "gck/gck-object.h"
 #include "gck/gck-sexp.h"
 #include "gck/gck-util.h"
@@ -78,6 +79,13 @@ gck_roots_certificate_get_attribute (GckObject *base, GckSession *session, CK_AT
 }
 
 static void
+gck_roots_certificate_expose_object (GckObject *obj, gboolean expose)
+{
+	GCK_OBJECT_CLASS (gck_roots_certificate_parent_class)->expose_object (obj, expose);
+	gck_object_expose (GCK_OBJECT (GCK_ROOTS_CERTIFICATE (obj)->trust), expose);
+}
+
+static void
 gck_roots_certificate_init (GckRootsCertificate *self)
 {
 	
@@ -89,7 +97,8 @@ gck_roots_certificate_constructor (GType type, guint n_props, GObjectConstructPa
 	GckRootsCertificate *self = GCK_ROOTS_CERTIFICATE (G_OBJECT_CLASS (gck_roots_certificate_parent_class)->constructor(type, n_props, props));
 	g_return_val_if_fail (self, NULL);	
 
-	self->trust = gck_certificate_trust_new (gck_object_get_module (GCK_OBJECT (self)), 
+	self->trust = gck_certificate_trust_new (gck_object_get_module (GCK_OBJECT (self)),
+	                                         gck_object_get_manager (GCK_OBJECT (self)),
 	                                         GCK_CERTIFICATE (self));
 	
 	return G_OBJECT (self);
@@ -169,6 +178,7 @@ gck_roots_certificate_class_init (GckRootsCertificateClass *klass)
 	gobject_class->get_property = gck_roots_certificate_get_property;
 
 	gck_class->get_attribute = gck_roots_certificate_get_attribute;
+	gck_class->expose_object = gck_roots_certificate_expose_object;
 	
 	g_object_class_install_property (gobject_class, PROP_PATH,
 	           g_param_spec_string ("path", "Path", "Certificate origin path", 
@@ -187,7 +197,7 @@ GckRootsCertificate*
 gck_roots_certificate_new (GckModule *module, const gchar *unique, const gchar *path)
 {
 	return g_object_new (GCK_TYPE_ROOTS_CERTIFICATE, "unique", unique, "path", path, 
-	                     "module", module, NULL);
+	                     "module", module, "manager", gck_module_get_manager (module), NULL);
 }
 
 const gchar*
diff --git a/pkcs11/roots-store/gck-roots-module.c b/pkcs11/roots-store/gck-roots-module.c
index cbeef94..5d391de 100644
--- a/pkcs11/roots-store/gck-roots-module.c
+++ b/pkcs11/roots-store/gck-roots-module.c
@@ -125,9 +125,8 @@ add_certificate_for_data (GckRootsModule *self, const guchar *data,
 		return NULL;
 	}
 	
-	/* Setup the right manager on the certificates */
-	gck_manager_register_object (manager, GCK_OBJECT (cert));
-	gck_manager_register_object (manager, GCK_OBJECT (gck_roots_certificate_get_netscape_trust (GCK_ROOTS_CERTIFICATE (cert))));
+	/* Make the certificate show up */
+	gck_object_expose (GCK_OBJECT (cert), TRUE);
 	
 	/* And add to our wonderful table */
 	g_hash_table_insert (self->certificates, cert, cert);
diff --git a/pkcs11/secret-store/gck-secret-collection.c b/pkcs11/secret-store/gck-secret-collection.c
index b4ab958..49e80bd 100644
--- a/pkcs11/secret-store/gck-secret-collection.c
+++ b/pkcs11/secret-store/gck-secret-collection.c
@@ -118,6 +118,13 @@ each_value_to_list (gpointer key, gpointer value, gpointer user_data)
 	*list = g_list_prepend (*list, value);
 }
 
+static void
+expose_each_item (gpointer key, gpointer value, gpointer user_data)
+{
+	gboolean expose = GPOINTER_TO_INT (user_data);
+	gck_object_expose (value, expose);
+}
+
 /* -----------------------------------------------------------------------------
  * OBJECT
  */
@@ -180,6 +187,13 @@ gck_secret_collection_real_unlock (GckObject *obj, GckAuthenticator *auth)
 	}
 }
 
+static void
+gck_secret_collection_expose (GckObject *base, gboolean expose)
+{
+	GCK_OBJECT_CLASS (gck_secret_collection_parent_class)->expose_object (base, expose);
+	g_hash_table_foreach (GCK_SECRET_COLLECTION (base)->items, expose_each_item, GINT_TO_POINTER (expose));
+}
+
 static gboolean
 gck_secret_collection_real_is_locked (GckSecretObject *obj, GckSession *session)
 {
@@ -268,6 +282,7 @@ gck_secret_collection_class_init (GckSecretCollectionClass *klass)
 	gobject_class->finalize = gck_secret_collection_finalize;
 
 	gck_class->unlock = gck_secret_collection_real_unlock;
+	gck_class->expose_object = gck_secret_collection_expose;
 
 	secret_class->is_locked = gck_secret_collection_real_is_locked;
 
diff --git a/pkcs11/secret-store/gck-secret-module.c b/pkcs11/secret-store/gck-secret-module.c
index 40cafae..2124e55 100644
--- a/pkcs11/secret-store/gck-secret-module.c
+++ b/pkcs11/secret-store/gck-secret-module.c
@@ -104,6 +104,7 @@ on_file_load (GckFileTracker *tracker, const gchar *path, GckSecretModule *self)
 		                           "module", self,
 		                           "identifier", basename,
 		                           "filename", path,
+		                           "manager", manager,
 		                           NULL);
 	}
 
@@ -113,7 +114,7 @@ on_file_load (GckFileTracker *tracker, const gchar *path, GckSecretModule *self)
 	case GCK_DATA_SUCCESS:
 		if (created) {
 			g_hash_table_replace (self->collections, basename, collection);
-			gck_manager_register_object (manager, GCK_OBJECT (collection));
+			gck_object_expose (GCK_OBJECT (collection), TRUE);
 			basename = NULL;
 		}
 		break;
diff --git a/pkcs11/secret-store/tests/unit-test-secret-collection.c b/pkcs11/secret-store/tests/unit-test-secret-collection.c
index 747aedd..ba6a5a1 100644
--- a/pkcs11/secret-store/tests/unit-test-secret-collection.c
+++ b/pkcs11/secret-store/tests/unit-test-secret-collection.c
@@ -83,7 +83,7 @@ DEFINE_TEST(secret_collection_unlocked_data)
 	CK_RV rv;
 
 	/* Create authenticator, which unlocks collection */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), NULL, 0, &auth); 
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session), NULL, 0, &auth); 
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
@@ -138,7 +138,7 @@ DEFINE_TEST(secret_collection_load_unlock_plain)
 	g_assert (res == GCK_DATA_SUCCESS);
 
 	/* Unlock the keyring, which should load again */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), NULL, 0, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session), NULL, 0, &auth);
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
@@ -165,7 +165,8 @@ DEFINE_TEST(secret_collection_load_unlock_encrypted)
 	g_assert (res == GCK_DATA_SUCCESS);
 
 	/* Unlock the keyring, which should load again */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"my-keyring-password", 19, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session), 
+	                               (guchar*)"my-keyring-password", 19, &auth);
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
@@ -191,7 +192,8 @@ DEFINE_TEST(secret_collection_load_unlock_bad_password)
 	g_assert (res == GCK_DATA_SUCCESS);
 
 	/* Unlock the keyring, which should load again */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"wrong", 5, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session), 
+	                               (guchar*)"wrong", 5, &auth);
 	g_assert (rv == CKR_PIN_INCORRECT);
 }
 
@@ -207,7 +209,8 @@ DEFINE_TEST(secret_collection_unlock_without_load)
 	g_free (filename);
 
 	/* Unlock the keyring, which should load it */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"my-keyring-password", 19, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session), 
+	                               (guchar*)"my-keyring-password", 19, &auth);
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
@@ -229,13 +232,15 @@ DEFINE_TEST(secret_collection_twice_unlock)
 	g_free (filename);
 
 	/* Unlock the keyring, which should load */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"my-keyring-password", 19, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session), 
+	                               (guchar*)"my-keyring-password", 19, &auth);
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
 
 	/* Unlock the keyring again, which should not reload */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"my-keyring-password", 19, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session), 
+	                               (guchar*)"my-keyring-password", 19, &auth);
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
@@ -257,13 +262,15 @@ DEFINE_TEST(secret_collection_twice_unlock_bad_password)
 	g_free (filename);
 
 	/* Unlock the keyring, which should load */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"my-keyring-password", 19, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session),
+	                               (guchar*)"my-keyring-password", 19, &auth);
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
 
 	/* Unlock the keyring again, wrong password */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"wrong", 5, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session),
+	                               (guchar*)"wrong", 5, &auth);
 	g_assert (rv == CKR_PIN_INCORRECT);
 
 	sdata = gck_secret_collection_unlocked_data (collection, session);
@@ -282,7 +289,8 @@ DEFINE_TEST(secret_collection_memory_unlock)
 	g_assert (res == GCK_DATA_SUCCESS);
 
 	/* Unlock the keyring, which should load again */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), NULL, 0, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session),
+	                               NULL, 0, &auth);
 	g_assert (rv == CKR_OK);
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
@@ -299,6 +307,7 @@ DEFINE_TEST(secret_collection_memory_unlock_bad_password)
 	g_assert (res == GCK_DATA_SUCCESS);
 
 	/* Unlock the keyring, which should load again */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), (guchar*)"wrong", 5, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (collection), gck_session_get_manager (session),
+	                               (guchar*)"wrong", 5, &auth);
 	g_assert (rv == CKR_PIN_INCORRECT);
 }
diff --git a/pkcs11/secret-store/tests/unit-test-secret-item.c b/pkcs11/secret-store/tests/unit-test-secret-item.c
index 1cad7fe..c77a75d 100644
--- a/pkcs11/secret-store/tests/unit-test-secret-item.c
+++ b/pkcs11/secret-store/tests/unit-test-secret-item.c
@@ -76,8 +76,11 @@ unlock_collection(void)
 	CK_RV rv;
 
 	/* Create authenticator, which unlocks collection */
-	rv = gck_authenticator_create (GCK_OBJECT (collection), NULL, 0, &auth); 
+	rv = gck_authenticator_create (GCK_OBJECT (collection),
+	                               gck_session_get_manager (session),
+	                               NULL, 0, &auth);
 	g_assert (rv == CKR_OK);
+
 	gck_session_add_session_object (session, NULL, GCK_OBJECT (auth));
 	g_object_unref (auth);
 }
diff --git a/pkcs11/ssh-store/gck-ssh-module.c b/pkcs11/ssh-store/gck-ssh-module.c
index 98521b8..5e7813b 100644
--- a/pkcs11/ssh-store/gck-ssh-module.c
+++ b/pkcs11/ssh-store/gck-ssh-module.c
@@ -100,7 +100,6 @@ static void
 file_load (GckFileTracker *tracker, const gchar *path, GckSshModule *self)
 {
 	GckSshPrivateKey *key;
-	GckSshPublicKey *pubkey;
 	gchar *private_path;
 	GckManager *manager;
 	GError *error = NULL;
@@ -109,6 +108,8 @@ file_load (GckFileTracker *tracker, const gchar *path, GckSshModule *self)
 	g_return_if_fail (path);
 	g_return_if_fail (GCK_IS_SSH_MODULE (self));
 	
+	manager = gck_module_get_manager (GCK_MODULE (self));
+
 	private_path = private_path_for_public (path);
 	if (!private_path || !g_file_test (private_path, G_FILE_TEST_IS_REGULAR)) {
 		g_message ("no private key present for public key: %s", path);
@@ -131,18 +132,11 @@ file_load (GckFileTracker *tracker, const gchar *path, GckSshModule *self)
 		g_message ("couldn't parse data: %s: %s", path,
 		           error && error->message ? error->message : "");
 		g_clear_error (&error);
+		gck_object_expose (GCK_OBJECT (key), FALSE);
 		
 	/* When successful register with the object manager */
 	} else {
-		manager = gck_module_get_manager (GCK_MODULE (self));
-		
-		/* Make sure the private key has the right manager */
-		if (!gck_object_get_manager (GCK_OBJECT (key))) 
-			gck_manager_register_object (manager, GCK_OBJECT (key));
-		
-		pubkey = gck_ssh_private_key_get_public_key (key);
-		if (!gck_object_get_manager (GCK_OBJECT (pubkey)))
-			gck_manager_register_object (manager, GCK_OBJECT (pubkey));
+		gck_object_expose (GCK_OBJECT (key), TRUE);
 	}
 
 	g_free (private_path);
diff --git a/pkcs11/ssh-store/gck-ssh-private-key.c b/pkcs11/ssh-store/gck-ssh-private-key.c
index b4ee233..1099fce 100644
--- a/pkcs11/ssh-store/gck-ssh-private-key.c
+++ b/pkcs11/ssh-store/gck-ssh-private-key.c
@@ -27,6 +27,7 @@
 #include "gck/gck-attributes.h"
 #include "gck/gck-authenticator.h"
 #include "gck/gck-manager.h"
+#include "gck/gck-module.h"
 #include "gck/gck-object.h"
 #include "gck/gck-sexp.h"
 #include "gck/gck-util.h"
@@ -181,6 +182,13 @@ gck_ssh_private_key_unlock (GckObject *base, GckAuthenticator *auth)
 	return rv;
 }
 
+static void
+gck_ssh_private_key_expose (GckObject *base, gboolean expose)
+{
+	GCK_OBJECT_CLASS (gck_ssh_private_key_parent_class)->expose_object (base, expose);
+	gck_object_expose (GCK_OBJECT (GCK_SSH_PRIVATE_KEY (base)->pubkey), expose);
+}
+
 static GObject* 
 gck_ssh_private_key_constructor (GType type, guint n_props, GObjectConstructParam *props) 
 {
@@ -281,6 +289,7 @@ gck_ssh_private_key_class_init (GckSshPrivateKeyClass *klass)
 	
 	gck_class->get_attribute = gck_ssh_private_key_get_attribute;
 	gck_class->unlock = gck_ssh_private_key_unlock;
+	gck_class->expose_object = gck_ssh_private_key_expose;
 	
 	g_object_class_install_property (gobject_class, PROP_LABEL,
 	           g_param_spec_string ("label", "Label", "Object Label", 
@@ -299,7 +308,7 @@ GckSshPrivateKey*
 gck_ssh_private_key_new (GckModule *module, const gchar *unique)
 {
 	return g_object_new (GCK_TYPE_SSH_PRIVATE_KEY, "unique", unique, 
-	                     "module", module, NULL);
+	                     "module", module, "manager", gck_module_get_manager (module), NULL);
 }
 
 gboolean
diff --git a/pkcs11/ssh-store/gck-ssh-public-key.c b/pkcs11/ssh-store/gck-ssh-public-key.c
index f6e6970..34347ee 100644
--- a/pkcs11/ssh-store/gck-ssh-public-key.c
+++ b/pkcs11/ssh-store/gck-ssh-public-key.c
@@ -24,6 +24,7 @@
 #include "gck-ssh-public-key.h"
 
 #include "gck/gck-attributes.h"
+#include "gck/gck-module.h"
 #include "gck/gck-object.h"
 #include "gck/gck-util.h"
 
@@ -132,7 +133,7 @@ GckSshPublicKey*
 gck_ssh_public_key_new (GckModule *module, const gchar *unique)
 {
 	return g_object_new (GCK_TYPE_SSH_PUBLIC_KEY, "unique", unique, 
-	                     "module", module, NULL);
+	                     "module", module, "manager", gck_module_get_manager (module), NULL);
 }
 
 const gchar*
diff --git a/pkcs11/ssh-store/tests/unit-test-private-key.c b/pkcs11/ssh-store/tests/unit-test-private-key.c
index fc26ea1..b32b28b 100644
--- a/pkcs11/ssh-store/tests/unit-test-private-key.c
+++ b/pkcs11/ssh-store/tests/unit-test-private-key.c
@@ -89,7 +89,7 @@ DEFINE_TEST(private_key_parse_and_unlock)
 	g_free (pub_path);
 	g_free (priv_path);
 
-	rv = gck_authenticator_create (GCK_OBJECT (key), (guchar*)"password", 8, &auth);
+	rv = gck_authenticator_create (GCK_OBJECT (key), NULL, (guchar*)"password", 8, &auth);
 	g_assert (rv == CKR_OK);
 	
 	g_object_unref (auth);
diff --git a/pkcs11/user-store/gck-user-private-key.c b/pkcs11/user-store/gck-user-private-key.c
index 9453ccf..e8cf598 100644
--- a/pkcs11/user-store/gck-user-private-key.c
+++ b/pkcs11/user-store/gck-user-private-key.c
@@ -75,8 +75,10 @@ factory_create_private_key (GckSession *session, GckTransaction *transaction,
 	if (sexp == NULL)
 		return;
 	
-	key = g_object_new (GCK_TYPE_USER_PRIVATE_KEY, "base-sexp", sexp, 
-	                    "module", gck_session_get_module (session), NULL);
+	key = g_object_new (GCK_TYPE_USER_PRIVATE_KEY, "base-sexp", sexp,
+	                    "module", gck_session_get_module (session),
+	                    "manager", gck_manager_for_template (attrs, n_attrs, session),
+	                    NULL);
 	g_return_if_fail (!key->private_sexp);
 	key->private_sexp = gck_sexp_ref (sexp);
 	
diff --git a/pkcs11/user-store/gck-user-public-key.c b/pkcs11/user-store/gck-user-public-key.c
index 56259df..7ece187 100644
--- a/pkcs11/user-store/gck-user-public-key.c
+++ b/pkcs11/user-store/gck-user-public-key.c
@@ -57,8 +57,10 @@ factory_create_public_key (GckSession *session, GckTransaction *transaction,
 
 	sexp = gck_public_key_create_sexp (session, transaction, attrs, n_attrs);
 	if (sexp != NULL) {
-		*object = g_object_new (GCK_TYPE_USER_PUBLIC_KEY, "base-sexp", sexp, 
-		                        "module", gck_session_get_module (session), NULL);
+		*object = g_object_new (GCK_TYPE_USER_PUBLIC_KEY, "base-sexp", sexp,
+		                        "module", gck_session_get_module (session),
+		                        "manager", gck_manager_for_template (attrs, n_attrs, session),
+		                        NULL);
 		gck_sexp_unref (sexp);
 	}
 }
diff --git a/pkcs11/user-store/gck-user-storage.c b/pkcs11/user-store/gck-user-storage.c
index 8eea500..5b002e6 100644
--- a/pkcs11/user-store/gck-user-storage.c
+++ b/pkcs11/user-store/gck-user-storage.c
@@ -444,7 +444,7 @@ take_object_ownership (GckUserStorage *self, const gchar *identifier, GckObject
 	g_hash_table_replace (self->object_to_identifier, object, str);;
 	
 	g_object_set (object, "store", self, NULL);
-	gck_manager_register_object (self->manager, object);
+	gck_object_expose (object, TRUE);
 }
 
 static gboolean
@@ -542,7 +542,8 @@ data_file_entry_added (GckDataFile *store, const gchar *identifier, GckUserStora
 	}
 	
 	/* Create a new object for this identifier */
-	object = g_object_new (type, "unique", identifier, "module", self->module, NULL);
+	object = g_object_new (type, "unique", identifier, "module", self->module,
+	                       "manager", gck_module_get_manager (self->module), NULL);
 	g_return_if_fail (GCK_IS_SERIALIZABLE (object));
 	g_return_if_fail (GCK_SERIALIZABLE_GET_INTERFACE (object)->extension);
 



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