Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.2 KiB

  1. #include "wzrdpvk.h"
  2. #include "certca.h"
  3. #include "cautil.h"
  4. #include "CertRequesterContext.h"
  5. #include "CertDSManager.h"
  6. #include "CertRequester.h"
  7. HRESULT CertRequester::MakeCertRequester(IN LPCWSTR pwszAccountName,
  8. IN LPCWSTR pwszMachineName,
  9. IN DWORD dwCertOpenStoreFlag,
  10. IN DWORD dwPurpose,
  11. IN CERT_WIZARD_INFO *pCertWizardInfo,
  12. OUT CertRequester **ppCertRequester,
  13. OUT UINT *pIDS)
  14. {
  15. CertDSManager *pDSManager = NULL;
  16. CertRequesterContext *pContext = NULL;
  17. HRESULT hr = E_FAIL;
  18. if (NULL == ppCertRequester)
  19. return E_INVALIDARG;
  20. // 1) Attempt to construct a CertRequesterContext:
  21. //
  22. if (S_OK != (hr = CertRequesterContext::MakeCertRequesterContext
  23. (pwszAccountName,
  24. pwszMachineName,
  25. dwCertOpenStoreFlag,
  26. pCertWizardInfo,
  27. &pContext,
  28. pIDS)))
  29. goto MakeCertRequesterContextError;
  30. if (S_OK != (hr = pContext->Initialize()))
  31. {
  32. *pIDS = pContext->GetErrorString();
  33. goto InitializeError;
  34. }
  35. // 2) Attempt to construct a CertDSManager:
  36. //
  37. if (S_OK != (hr = CertDSManager::MakeDSManager(&pDSManager)))
  38. {
  39. *pIDS=IDS_NO_AD;
  40. goto MakeDSManagerError;
  41. }
  42. // 3) Create the CertRequester itself:
  43. //
  44. switch (dwPurpose)
  45. {
  46. case CRYPTUI_WIZ_CERT_ENROLL:
  47. *ppCertRequester = new EnrollmentCertRequester(pCertWizardInfo);
  48. break;
  49. case CRYPTUI_WIZ_CERT_RENEW:
  50. *ppCertRequester = new RenewalCertRequester(pCertWizardInfo);
  51. break;
  52. default:
  53. goto InvalidArgError;
  54. }
  55. if (NULL == *ppCertRequester)
  56. goto MemoryError;
  57. (*ppCertRequester)->SetContext(pContext);
  58. (*ppCertRequester)->SetDSManager(pDSManager);
  59. hr = S_OK;
  60. CommonReturn:
  61. return hr;
  62. ErrorReturn:
  63. if (NULL != pContext) { delete pContext; }
  64. goto CommonReturn;
  65. SET_HRESULT(MakeDSManagerError, hr);
  66. SET_HRESULT(InitializeError, hr);
  67. SET_HRESULT(InvalidArgError, E_INVALIDARG);
  68. SET_HRESULT(MakeCertRequesterContextError, hr);
  69. SET_HRESULT(MemoryError, E_OUTOFMEMORY);
  70. }