]> git.saurik.com Git - apple/securityd.git/blob - src/token.cpp
977286428b4d0b8d75f98925c4507c8708ffedc8
[apple/securityd.git] / src / token.cpp
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26
27 //
28 // token - internal representation of a (single distinct) hardware token
29 //
30 #include "token.h"
31 #include "reader.h"
32 #include "notifications.h"
33
34
35 Token::Token()
36 {
37 secdebug("token", "%p created", this);
38 }
39
40
41 Token::~Token()
42 {
43 secdebug("token", "%p destroyed", this);
44 }
45
46
47 Reader &Token::reader() const
48 {
49 return referent<Reader>();
50 }
51
52
53 void Token::insert(Reader &slot)
54 {
55 referent(slot);
56 mState = slot.pcscState();
57 //@@@ pupulate MDS here
58 notify(kNotificationCDSAInsertion);
59 }
60
61
62 void Token::remove()
63 {
64 //@@@ clear MDS here
65 notify(kNotificationCDSARemoval);
66 clearReferent();
67 }
68
69
70 //
71 // Send CDSA-layer notifications for this token.
72 // These events are usually received by CDSA plugins working with securityd.
73 // @@@ Need to add CDSA identifier as data
74 //
75 void Token::notify(NotificationEvent event)
76 {
77 Listener::notify(kNotificationDomainCDSA, event, CssmData());
78 }
79
80
81 //
82 // Debug dump support
83 //
84 #if defined(DEBUGDUMP)
85
86 void Token::dumpNode()
87 {
88 PerGlobal::dumpNode();
89 }
90
91 #endif //DEBUGDUMP