#include "SDCSPDLPlugin.h"
#include "SDCSPSession.h"
#include "SDDLSession.h"
#include <securityd_client/dictionary.h>
using namespace SecurityServer;
SDCSPDLPlugin::SDCSPDLPlugin()
: EventListener(kNotificationDomainCDSA, kNotificationAllEvents),
mRawCsp(gGuidAppleCSP)
{
mInitialized = true;
EventListener::FinishedInitialization(this);
}
SDCSPDLPlugin::~SDCSPDLPlugin()
{
}
PluginSession *
SDCSPDLPlugin::makeSession(CSSM_MODULE_HANDLE handle,
const CSSM_VERSION &version,
uint32 subserviceId,
CSSM_SERVICE_TYPE subserviceType,
CSSM_ATTACH_FLAGS attachFlags,
const CSSM_UPCALLS &upcalls)
{
switch (subserviceType)
{
case CSSM_SERVICE_CSP:
return new SDCSPSession(handle,
*this,
version,
subserviceId,
subserviceType,
attachFlags,
upcalls,
mSDCSPDLSession,
mRawCsp);
case CSSM_SERVICE_DL:
return new SDDLSession(handle,
*this,
version,
subserviceId,
subserviceType,
attachFlags,
upcalls,
mDatabaseManager,
mSDCSPDLSession);
default:
CssmError::throwMe(CSSMERR_CSSM_INVALID_SERVICE_MASK);
}
}
void SDCSPDLPlugin::consume(NotificationDomain domain, NotificationEvent event,
const CssmData &data)
{
NameValueDictionary nvd(data);
assert(domain == kNotificationDomainCDSA);
if (const NameValuePair *uidp = nvd.FindByName(SSUID_KEY)) {
CssmSubserviceUid *uid = (CssmSubserviceUid *)uidp->Value().data();
assert(uid);
secinfo("sdcspdl", "sending callback %d upstream", event);
sendCallback(event, n2h (uid->subserviceId()), CSSM_SERVICE_DL | CSSM_SERVICE_CSP);
} else
secinfo("sdcspdl", "callback event %d has no SSUID data", event);
}