gnome-keyring r1543 - in trunk: . pkcs11/gck pkcs11/roots-store pkcs11/ssh-store pkcs11/user-store
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-keyring r1543 - in trunk: . pkcs11/gck pkcs11/roots-store pkcs11/ssh-store pkcs11/user-store
- Date: Tue, 10 Feb 2009 04:07:06 +0000 (UTC)
Author: nnielsen
Date: Tue Feb 10 04:07:06 2009
New Revision: 1543
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1543&view=rev
Log:
Allow dynamically changing the slot info and token info.
Modified:
trunk/ChangeLog
trunk/pkcs11/gck/gck-module.c
trunk/pkcs11/gck/gck-module.h
trunk/pkcs11/roots-store/gck-roots-module.c
trunk/pkcs11/ssh-store/gck-ssh-module.c
trunk/pkcs11/user-store/gck-user-module.c
Modified: trunk/pkcs11/gck/gck-module.c
==============================================================================
--- trunk/pkcs11/gck/gck-module.c (original)
+++ trunk/pkcs11/gck/gck-module.c Tue Feb 10 04:07:06 2009
@@ -323,6 +323,18 @@
* OBJECT
*/
+static const CK_SLOT_INFO*
+gck_module_real_get_slot_info (GckModule *self)
+{
+ return &default_slot_info;
+}
+
+static const CK_TOKEN_INFO*
+gck_module_real_get_token_info (GckModule *self)
+{
+ return &default_token_info;
+}
+
static void
gck_module_real_parse_argument (GckModule *self, const gchar *name, const gchar *value)
{
@@ -513,10 +525,8 @@
gobject_class->set_property = gck_module_set_property;
gobject_class->get_property = gck_module_get_property;
- klass->module_info = &default_module_info;
- klass->slot_info = &default_slot_info;
- klass->token_info = &default_token_info;
-
+ klass->get_slot_info = gck_module_real_get_slot_info;
+ klass->get_token_info = gck_module_real_get_token_info;
klass->parse_argument = gck_module_real_parse_argument;
klass->refresh_token = gck_module_real_refresh_token;
klass->store_token_object = gck_module_real_store_token_object;
@@ -553,12 +563,17 @@
gboolean
gck_module_get_write_protected (GckModule *self)
{
- g_return_val_if_fail (GCK_IS_MODULE (self), FALSE);
- g_return_val_if_fail (GCK_MODULE_GET_CLASS (self)->token_info, FALSE);
- return (GCK_MODULE_GET_CLASS (self)->token_info->flags & CKF_WRITE_PROTECTED) ? TRUE : FALSE;
+ const CK_TOKEN_INFO* info;
+
+ g_return_val_if_fail (GCK_IS_MODULE (self), TRUE);
+ g_return_val_if_fail (GCK_MODULE_GET_CLASS (self)->get_token_info, TRUE);
+
+ info = (GCK_MODULE_GET_CLASS (self)->get_token_info) (self);
+ g_return_val_if_fail (info, TRUE);
+
+ return info->flags & CKF_WRITE_PROTECTED;
}
-
GckSession*
gck_module_lookup_session (GckModule *self, CK_SESSION_HANDLE handle)
{
@@ -699,7 +714,7 @@
klass = GCK_MODULE_GET_CLASS (self);
g_return_val_if_fail (klass, CKR_GENERAL_ERROR);
- memcpy (info, klass->module_info, sizeof (CK_INFO));
+ memcpy (info, &default_module_info, sizeof (CK_INFO));
/* Extend all the strings appropriately */
extend_space_string (info->libraryDescription, sizeof (info->libraryDescription));
@@ -739,6 +754,7 @@
CK_RV
gck_module_C_GetSlotInfo (GckModule *self, CK_SLOT_ID id, CK_SLOT_INFO_PTR info)
{
+ const CK_SLOT_INFO *original;
GckModuleClass *klass;
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -752,8 +768,12 @@
klass = GCK_MODULE_GET_CLASS (self);
g_return_val_if_fail (klass, CKR_GENERAL_ERROR);
+ g_return_val_if_fail (klass->get_slot_info, CKR_GENERAL_ERROR);
+
+ original = (klass->get_slot_info) (self);
+ g_return_val_if_fail (original, CKR_GENERAL_ERROR);
- memcpy (info, klass->slot_info, sizeof (CK_SLOT_INFO));
+ memcpy (info, original, sizeof (CK_SLOT_INFO));
/* Extend all the strings appropriately */
extend_space_string (info->manufacturerID, sizeof (info->manufacturerID));
@@ -765,6 +785,7 @@
CK_RV
gck_module_C_GetTokenInfo (GckModule *self, CK_SLOT_ID id, CK_TOKEN_INFO_PTR info)
{
+ const CK_TOKEN_INFO *original;
GckModuleClass *klass;
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -778,19 +799,20 @@
klass = GCK_MODULE_GET_CLASS (self);
g_return_val_if_fail (klass, CKR_GENERAL_ERROR);
+ g_return_val_if_fail (klass->get_token_info, CKR_GENERAL_ERROR);
- memcpy (info, klass->token_info, sizeof (CK_TOKEN_INFO));
+ original = (klass->get_token_info) (self);
+ g_return_val_if_fail (original, CKR_GENERAL_ERROR);
+ memcpy (info, original, sizeof (CK_TOKEN_INFO));
+
/* Extend all the strings appropriately */
extend_space_string (info->label, sizeof (info->label));
extend_space_string (info->manufacturerID, sizeof (info->manufacturerID));
extend_space_string (info->model, sizeof (info->model));
extend_space_string (info->serialNumber, sizeof (info->serialNumber));
-
- /* We don't purport to have a clock */
- memset (info->utcTime, 0, sizeof (info->utcTime));
-
- return CKR_OK;
+
+ return CKR_OK;
}
CK_RV
Modified: trunk/pkcs11/gck/gck-module.h
==============================================================================
--- trunk/pkcs11/gck/gck-module.h (original)
+++ trunk/pkcs11/gck/gck-module.h Tue Feb 10 04:07:06 2009
@@ -48,14 +48,13 @@
struct _GckModuleClass {
GObjectClass parent_class;
- /* often overridden by defined */
- const CK_INFO *module_info;
- const CK_SLOT_INFO *slot_info;
- const CK_TOKEN_INFO *token_info;
-
/* virtual methods */
void (*parse_argument) (GckModule *self, const gchar *name, const gchar *value);
+
+ const CK_SLOT_INFO* (*get_slot_info) (GckModule *self);
+
+ const CK_TOKEN_INFO* (*get_token_info) (GckModule *self);
CK_RV (*refresh_token) (GckModule *self);
Modified: trunk/pkcs11/roots-store/gck-roots-module.c
==============================================================================
--- trunk/pkcs11/roots-store/gck-roots-module.c (original)
+++ trunk/pkcs11/roots-store/gck-roots-module.c Tue Feb 10 04:07:06 2009
@@ -244,6 +244,18 @@
* OBJECT
*/
+static const CK_SLOT_INFO*
+gck_roots_module_real_get_slot_info (GckModule *self)
+{
+ return &gck_roots_module_slot_info;
+}
+
+static const CK_TOKEN_INFO*
+gck_roots_module_real_get_token_info (GckModule *self)
+{
+ return &gck_roots_module_token_info;
+}
+
static void
gck_roots_module_real_parse_argument (GckModule *base, const gchar *name, const gchar *value)
{
@@ -336,11 +348,10 @@
gobject_class->dispose = gck_roots_module_dispose;
gobject_class->finalize = gck_roots_module_finalize;
+ module_class->get_slot_info = gck_roots_module_real_get_slot_info;
+ module_class->get_token_info = gck_roots_module_real_get_token_info;
module_class->parse_argument = gck_roots_module_real_parse_argument;
module_class->refresh_token = gck_roots_module_real_refresh_token;
-
- module_class->slot_info = &gck_roots_module_slot_info;
- module_class->token_info = &gck_roots_module_token_info;
}
/* ---------------------------------------------------------------------------------------
Modified: trunk/pkcs11/ssh-store/gck-ssh-module.c
==============================================================================
--- trunk/pkcs11/ssh-store/gck-ssh-module.c (original)
+++ trunk/pkcs11/ssh-store/gck-ssh-module.c Tue Feb 10 04:07:06 2009
@@ -157,6 +157,18 @@
* OBJECT
*/
+static const CK_SLOT_INFO*
+gck_ssh_module_real_get_slot_info (GckModule *self)
+{
+ return &gck_ssh_module_slot_info;
+}
+
+static const CK_TOKEN_INFO*
+gck_ssh_module_real_get_token_info (GckModule *self)
+{
+ return &gck_ssh_module_token_info;
+}
+
static void
gck_ssh_module_real_parse_argument (GckModule *base, const gchar *name, const gchar *value)
{
@@ -237,11 +249,10 @@
gobject_class->dispose = gck_ssh_module_dispose;
gobject_class->finalize = gck_ssh_module_finalize;
+ module_class->get_slot_info = gck_ssh_module_real_get_slot_info;
+ module_class->get_token_info = gck_ssh_module_real_get_token_info;
module_class->parse_argument = gck_ssh_module_real_parse_argument;
module_class->refresh_token = gck_ssh_module_real_refresh_token;
-
- module_class->slot_info = &gck_ssh_module_slot_info;
- module_class->token_info = &gck_ssh_module_token_info;
}
/* ----------------------------------------------------------------------------
Modified: trunk/pkcs11/user-store/gck-user-module.c
==============================================================================
--- trunk/pkcs11/user-store/gck-user-module.c (original)
+++ trunk/pkcs11/user-store/gck-user-module.c Tue Feb 10 04:07:06 2009
@@ -92,6 +92,18 @@
* OBJECT
*/
+static const CK_SLOT_INFO*
+gck_user_module_real_get_slot_info (GckModule *self)
+{
+ return &gck_user_module_slot_info;
+}
+
+static const CK_TOKEN_INFO*
+gck_user_module_real_get_token_info (GckModule *self)
+{
+ return &gck_user_module_token_info;
+}
+
static void
gck_user_module_real_parse_argument (GckModule *base, const gchar *name, const gchar *value)
{
@@ -282,6 +294,8 @@
gobject_class->dispose = gck_user_module_dispose;
gobject_class->finalize = gck_user_module_finalize;
+ module_class->get_slot_info = gck_user_module_real_get_slot_info;
+ module_class->get_token_info = gck_user_module_real_get_token_info;
module_class->parse_argument = gck_user_module_real_parse_argument;
module_class->refresh_token = gck_user_module_real_refresh_token;
module_class->store_token_object = gck_user_module_real_store_token_object;
@@ -289,9 +303,6 @@
module_class->login_user = gck_user_module_real_login_user;
module_class->logout_user = gck_user_module_real_logout_user;
module_class->login_change = gck_user_module_real_login_change;
-
- module_class->slot_info = &gck_user_module_slot_info;
- module_class->token_info = &gck_user_module_token_info;
}
/* ----------------------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]