2 * Copyright (c) 2004,2011-2012,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 // SDCSPDLPlugin.cpp - Securityd-based CSP/DL plug-in module.
28 #include "SDCSPDLPlugin.h"
30 #include "SDCSPSession.h"
31 #include "SDDLSession.h"
32 #include <securityd_client/dictionary.h>
34 using namespace SecurityServer
;
38 // Make and break the plugin object
40 SDCSPDLPlugin::SDCSPDLPlugin()
41 : EventListener(kNotificationDomainCDSA
, kNotificationAllEvents
),
42 mRawCsp(gGuidAppleCSP
)
44 EventListener::FinishedInitialization(this);
47 SDCSPDLPlugin::~SDCSPDLPlugin()
53 // Create a new plugin session, our way
56 SDCSPDLPlugin::makeSession(CSSM_MODULE_HANDLE handle
,
57 const CSSM_VERSION
&version
,
59 CSSM_SERVICE_TYPE subserviceType
,
60 CSSM_ATTACH_FLAGS attachFlags
,
61 const CSSM_UPCALLS
&upcalls
)
63 switch (subserviceType
)
65 case CSSM_SERVICE_CSP
:
66 return new SDCSPSession(handle
,
76 return new SDDLSession(handle
,
86 CssmError::throwMe(CSSMERR_CSSM_INVALID_SERVICE_MASK
);
87 // return 0; // placebo
93 // Accept callback notifications from securityd and dispatch them
94 // upstream through CSSM.
96 void SDCSPDLPlugin::consume(NotificationDomain domain
, NotificationEvent event
,
99 NameValueDictionary
nvd(data
);
100 assert(domain
== kNotificationDomainCDSA
);
101 if (const NameValuePair
*uidp
= nvd
.FindByName(SSUID_KEY
)) {
102 CssmSubserviceUid
*uid
= (CssmSubserviceUid
*)uidp
->Value().data();
104 secinfo("sdcspdl", "sending callback %d upstream", event
);
105 sendCallback(event
, n2h (uid
->subserviceId()), CSSM_SERVICE_DL
| CSSM_SERVICE_CSP
);
107 secinfo("sdcspdl", "callback event %d has no SSUID data", event
);