2 * Copyright (c) 1998-2004,2011,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 * CCallbackMgr.h -- Code that communicates with processes that install a callback
27 * with the Keychain Manager to receive keychain events.
29 #ifndef _SECURITY_CCALLBACKMGR_H_
30 #define _SECURITY_CCALLBACKMGR_H_
32 #include <security_keychain/Keychains.h>
33 #include <security_utilities/cfmach++.h>
34 #include <securityd_client/ssnotify.h>
35 #include <securityd_client/dictionary.h>
36 #include <securityd_client/eventlistener.h>
38 #include "KCEventNotifier.h"
43 namespace KeychainCore
54 CallbackInfo(SecKeychainCallback inCallbackFunction
,SecKeychainEventMask inEventMask
,void *inContext
);
56 bool operator ==(const CallbackInfo
& other
) const;
57 bool operator !=(const CallbackInfo
& other
) const;
59 SecKeychainCallback mCallback
;
60 SecKeychainEventMask mEventMask
;
65 typedef CallbackInfo
*CallbackInfoPtr
;
66 typedef CallbackInfo
const *ConstCallbackInfoPtr
;
68 typedef list
<CallbackInfo
>::iterator CallbackInfoListIterator
;
69 typedef list
<CallbackInfo
>::const_iterator ConstCallbackInfoListIterator
;
72 class CCallbackMgr
: public SecurityServer::EventListener
78 static CCallbackMgr
& Instance();
80 static void AddCallback( SecKeychainCallback inCallbackFunction
, SecKeychainEventMask inEventMask
, void* inContext
);
82 static void RemoveCallback( SecKeychainCallback inCallbackFunction
);
83 //static void RemoveCallbackUPP(KCCallbackUPP inCallbackFunction);
84 static bool HasCallbacks()
85 { return CCallbackMgr::Instance().mEventCallbacks
.size() > 0; };
89 void consume (SecurityServer::NotificationDomain domain
, SecurityServer::NotificationEvent whichEvent
,
90 const CssmData
&data
);
92 static void AlertClients(const list
<CallbackInfo
> &eventCallbacks
, SecKeychainEvent inEvent
, pid_t inPid
,
93 const Keychain
& inKeychain
, const Item
&inItem
);
95 list
<CallbackInfo
> mEventCallbacks
;
98 } // end namespace KeychainCore
100 } // end namespace Security
102 #endif // !_SECURITY_CCALLBACKMGR_H_