301
gck_secret_module_real_add_object (GckModule *module, GckTransaction *transaction,
304
GckSecretModule *self = GCK_SECRET_MODULE (module);
305
GckSecretCollection *collection;
306
const gchar *identifier;
309
g_return_if_fail (!gck_transaction_get_failed (transaction));
311
if (GCK_IS_SECRET_COLLECTION (object)) {
312
collection = GCK_SECRET_COLLECTION (object);
314
/* Setup a filename for this collection */
315
identifier = gck_secret_object_get_identifier (GCK_SECRET_OBJECT (collection));
316
filename = identifier_to_new_filename (self, identifier);
317
gck_secret_collection_set_filename (collection, filename);
320
add_collection (self, transaction, collection);
304
325
gck_secret_module_real_store_object (GckModule *module, GckTransaction *transaction,
305
326
GckObject *object)
307
328
GckSecretModule *self = GCK_SECRET_MODULE (module);
308
329
GckSecretCollection *collection = NULL;
309
const gchar *identifier;
312
/* Storing an item */
331
/* Store the item's collection */
313
332
if (GCK_IS_SECRET_ITEM (object)) {
314
333
collection = gck_secret_item_get_collection (GCK_SECRET_ITEM (object));
315
334
g_return_if_fail (GCK_IS_SECRET_COLLECTION (collection));
335
gck_module_store_token_object (GCK_MODULE (self), transaction, GCK_OBJECT (collection));
317
337
/* Storing a collection */
318
338
} else if (GCK_IS_SECRET_COLLECTION (object)) {
319
339
collection = GCK_SECRET_COLLECTION (object);
340
gck_secret_collection_save (collection, transaction);
322
342
/* No other kind of token object */
323
if (collection == NULL) {
324
344
g_warning ("can't store object of type '%s' on secret token", G_OBJECT_TYPE_NAME (object));
325
345
gck_transaction_fail (transaction, CKR_GENERAL_ERROR);
329
/* Setup a filename for this collection */
330
if (!gck_secret_collection_get_filename (collection)) {
331
identifier = gck_secret_object_get_identifier (GCK_SECRET_OBJECT (collection));
332
filename = identifier_to_new_filename (self, identifier);
333
gck_secret_collection_set_filename (collection, filename);
337
gck_secret_collection_save (collection, transaction);
338
if (!gck_transaction_get_failed (transaction))
339
add_collection (self, transaction, collection);
351
358
GCK_OBJECT (self->session_credential) == object)
354
/* Ignore the session keyring collection */
355
if (self->session_collection != NULL &&
356
GCK_OBJECT (self->session_collection) == object)
359
361
/* Removing an item */
360
362
if (GCK_IS_SECRET_ITEM (object)) {
361
363
collection = gck_secret_item_get_collection (GCK_SECRET_ITEM (object));
402
405
manager = gck_module_get_manager (GCK_MODULE (self));
407
collection = g_object_new (GCK_TYPE_SECRET_COLLECTION,
409
"identifier", "session",
404
414
/* Create the 'session' keyring, which is not stored to disk */
405
self->session_collection = g_object_new (GCK_TYPE_SECRET_COLLECTION,
407
"identifier", "session",
410
gck_object_expose (GCK_OBJECT (self->session_collection), TRUE);
415
g_return_val_if_fail (gck_object_is_transient (collection), NULL);
416
gck_module_add_token_object (GCK_MODULE (self), NULL, collection);
417
gck_object_expose (collection, TRUE);
412
419
/* Unlock the 'session' keyring */
413
rv = gck_credential_create (GCK_MODULE (self), manager, GCK_OBJECT (self->session_collection),
420
rv = gck_credential_create (GCK_MODULE (self), manager, GCK_OBJECT (collection),
414
421
NULL, 0, &self->session_credential);
415
422
if (rv == CKR_OK)
416
423
gck_object_expose (GCK_OBJECT (self->session_credential), TRUE);
418
425
g_warning ("couldn't unlock the 'session' keyring");
427
g_object_unref (collection);
420
428
return G_OBJECT (self);
438
446
g_object_unref (self->tracker);
439
447
self->tracker = NULL;
441
if (self->session_collection)
442
g_object_unref (self->session_collection);
443
self->session_collection = NULL;
445
449
if (self->session_credential)
446
450
g_object_unref (self->session_credential);
447
451
self->session_credential = NULL;
484
487
module_class->get_token_info = gck_secret_module_real_get_token_info;
485
488
module_class->parse_argument = gck_secret_module_real_parse_argument;
486
489
module_class->refresh_token = gck_secret_module_real_refresh_token;
490
module_class->add_token_object = gck_secret_module_real_add_object;
491
module_class->store_token_object = gck_secret_module_real_store_object;
487
492
module_class->remove_token_object = gck_secret_module_real_remove_object;
488
module_class->store_token_object = gck_secret_module_real_store_object;
491
495
/* ---------------------------------------------------------------------------------------