To Implement IComponentAuthenticate in a Service Provider
Include Sac.h and Scserver.h.
Link to Mssachlp.lib.
Add the Keys.c file that you received when you signed the license agreement for your project.
Declare a CSecureChannelServer object. This object must be available to all other objects implemented in your component.
Implement IComponentAuthenticate on the main object of your component. For a service provider, this is the object that implements IMDServiceProvider. Use code similar to the following example in the constructor for your main object:
CMediaDevMgr::CmediaDevMgr() { g_pAppSCServer = new CSecureChannelServer(); if (g_pAppSCServer) { g_pAppSCServer->SetCertificate(SAC_CERT_V1, (BYTE*)abCert, sizeof(abCert), (BYTE*)abPVK, sizeof(abPVK) ); } }
Delegate the methods of IComponentAuthenticate to the global CSecureChannelServer object. Use code such as:
// Example to implement SACAuth. HRESULT CMediaDevMgr::SACAuth(DWORD dwProtocolID, DWORD dwPass, BYTE *pbDataIn, DWORD dwDataInLen, BYTE **ppbDataOut, DWORD *pdwDataOutLen) { HRESULT hr; if (g_pAppSCServer) { hr = g_pAppSCServer->SACAuth(dwProtocolID, dwPass, pbDataIn, dwDataInLen, ppbDataOut, pdwDataOutLen); } else { hr = E_FAIL; } return hr; // Example of how to implement SACGetProtocols. HRESULT CMediaDevMgr::SACGetProtocols(DWORD **ppdwProtocols, DWORD *pdwProtocolCount) { HRESULT hr; if (g_pAppSCServer) { hr = g_pAppSCServer->SACGetProtocols(ppdwProtocols, pdwProtocolCount); } else { hr = E_FAIL; } return hr; }
When the caller has not been authenticated, return WMDM_E_NOT_CERTIFIED from all of your methods.
See Also