2 * Copyright (c) 2004-2008,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // pcscmonitor - use PCSC to monitor smartcard reader/card state for securityd
28 #ifndef _H_PCSCMONITOR
29 #define _H_PCSCMONITOR
32 #include "tokencache.h"
35 #include <security_utilities/pcsc++.h>
36 #include <security_utilities/coderepository.h>
41 // A PCSCMonitor uses PCSC to monitor the state of smartcard readers and
42 // tokens (cards) in the system, and dispatches messages and events to the
43 // various related players in securityd. There should be at most one of these
44 // objects active within securityd.
46 class PCSCMonitor
: private Listener
, private MachServer::Timer
{
49 forcedOff
, // no service under any circumstances
50 externalDaemon
// use externally launched daemon if present (do not manage pcscd)
53 PCSCMonitor(Server
&server
, const char* pathToCache
, ServiceLevel level
= externalDaemon
);
57 TokenCache
& tokenCache();
61 void notifyMe(Notification
*message
);
66 void clearReaders(Reader::Type type
);
69 void startSoftTokens();
70 void loadSoftToken(Bundle
*tokendBundle
);
73 ServiceLevel mServiceLevel
; // level of service requested/determined
75 std::string mCachePath
; // path to cache directory
76 TokenCache
*mTokenCache
; // cache object (lazy)
78 typedef map
<string
, RefPointer
<Reader
> > ReaderMap
;
79 typedef set
<RefPointer
<Reader
> > ReaderSet
;
80 ReaderMap mReaders
; // presently known PCSC Readers (aka slots)
82 class Watcher
: public Thread
{
84 Watcher(Server
&server
, TokenCache
&tokenCache
, ReaderMap
& readers
);
91 TokenCache
&mTokenCache
;
92 PCSC::Session mSession
; // PCSC client session
98 #endif //_H_PCSCMONITOR