4
* Copyright (C) 2009 Stefan Walter
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General License as
8
* published by the Free Software Foundation; either version 2.1 of
9
* the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General License for more details.
16
* You should have received a copy of the GNU Lesser General
17
* License along with this program; if not, see
18
* <http://www.gnu.org/licenses/>.
23
#include "mock-locked-object.h"
25
#include "gkm/gkm-attributes.h"
26
#include "gkm/gkm-credential.h"
28
G_DEFINE_TYPE (MockLockedObject, mock_locked_object, GKM_TYPE_OBJECT);
30
/* -----------------------------------------------------------------------------
34
/* -----------------------------------------------------------------------------
39
mock_locked_object_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATTRIBUTE* attr)
43
return gkm_attribute_set_ulong (attr, CKO_DATA);
44
case CKA_ALWAYS_AUTHENTICATE:
45
return gkm_attribute_set_bool (attr, TRUE);
48
return GKM_OBJECT_CLASS (mock_locked_object_parent_class)->get_attribute (base, session, attr);
52
mock_locked_object_real_unlock (GkmObject *base, GkmCredential *auth)
54
const gchar *password;
57
password = gkm_credential_get_password (auth, &n_password);
58
if (n_password == 4 && memcmp (password, "mock", 4) == 0)
61
return CKR_USER_NOT_LOGGED_IN;
65
mock_locked_object_init (MockLockedObject *self)
71
mock_locked_object_class_init (MockLockedObjectClass *klass)
73
GkmObjectClass *gkm_class = GKM_OBJECT_CLASS (klass);
74
mock_locked_object_parent_class = g_type_class_peek_parent (klass);
75
gkm_class->get_attribute = mock_locked_object_real_get_attribute;
76
gkm_class->unlock = mock_locked_object_real_unlock;
79
/* -----------------------------------------------------------------------------
84
mock_locked_object_new (GkmModule *module, GkmManager *manager)
86
return g_object_new (MOCK_TYPE_LOCKED_OBJECT,