Leaked source code of windows server 2003
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.

164 lines
4.6 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000
  3. File: CertificateStatus.h
  4. Content: Declaration of CCertificateStatus.
  5. History: 11-15-99 dsie created
  6. ------------------------------------------------------------------------------*/
  7. #ifndef __CERTIFICATESTATUS_H_
  8. #define __CERTIFICATESTATUS_H_
  9. #include "Resource.h"
  10. #include "Error.h"
  11. #include "Lock.h"
  12. #include "Debug.h"
  13. #include "EKU.h"
  14. #define CAPICOM_DEFAULT_URL_RETRIEVAL_TIMEOUT (15) // Default is 15 seconds.
  15. #define CAPICOM_MAX_URL_RETRIEVAL_TIMEOUT (120) // Maximum 2 minutes.
  16. ////////////////////////////////////////////////////////////////////////////////
  17. //
  18. // Exported functions.
  19. //
  20. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21. Function : CreateCertificateStatusObject
  22. Synopsis : Create an ICertificateStatus object.
  23. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT.
  24. ICertificateStatus ** ppICertificateStatus - Pointer to pointer
  25. ICertificateStatus
  26. object.
  27. Remark :
  28. ------------------------------------------------------------------------------*/
  29. HRESULT CreateCertificateStatusObject (PCCERT_CONTEXT pCertContext,
  30. ICertificateStatus ** ppICertificateStatus);
  31. ////////////////////////////////////////////////////////////////////////////////
  32. //
  33. // CCertificateStatus
  34. //
  35. class ATL_NO_VTABLE CCertificateStatus :
  36. public CComObjectRootEx<CComMultiThreadModel>,
  37. public CComCoClass<CCertificateStatus, &CLSID_CertificateStatus>,
  38. public ICAPICOMError<CCertificateStatus, &IID_ICertificateStatus2>,
  39. public IDispatchImpl<ICertificateStatus2, &IID_ICertificateStatus2, &LIBID_CAPICOM,
  40. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  41. {
  42. public:
  43. CCertificateStatus()
  44. {
  45. }
  46. DECLARE_NO_REGISTRY()
  47. DECLARE_GET_CONTROLLING_UNKNOWN()
  48. DECLARE_PROTECT_FINAL_CONSTRUCT()
  49. BEGIN_COM_MAP(CCertificateStatus)
  50. COM_INTERFACE_ENTRY(ICertificateStatus)
  51. COM_INTERFACE_ENTRY(ICertificateStatus2)
  52. COM_INTERFACE_ENTRY(IDispatch)
  53. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  54. END_COM_MAP()
  55. BEGIN_CATEGORY_MAP(CCertificateStatus)
  56. END_CATEGORY_MAP()
  57. HRESULT FinalConstruct()
  58. {
  59. HRESULT hr;
  60. if (FAILED(hr = m_Lock.Initialized()))
  61. {
  62. DebugTrace("Error [%#x]: Critical section could not be created for CertificateStatus object.\n", hr);
  63. return hr;
  64. }
  65. m_pIEKU = NULL;
  66. m_pICertificatePolicies = NULL;
  67. m_pIApplicationPolicies = NULL;
  68. m_CheckFlag = CAPICOM_CHECK_NONE;
  69. m_pCertContext = NULL;
  70. m_VerificationTime = (DATE) 0;
  71. m_dwUrlRetrievalTimeout = 0;
  72. return S_OK;
  73. }
  74. void FinalRelease()
  75. {
  76. m_pIEKU.Release();
  77. m_pICertificatePolicies.Release();
  78. m_pIApplicationPolicies.Release();
  79. if (m_pCertContext)
  80. {
  81. ::CertFreeCertificateContext(m_pCertContext);
  82. }
  83. }
  84. //
  85. // ICertificateStatus
  86. //
  87. public:
  88. STDMETHOD(EKU)
  89. (/*[out, retval]*/ IEKU ** pVal);
  90. STDMETHOD(get_CheckFlag)
  91. (/*[out, retval]*/ CAPICOM_CHECK_FLAG * pVal);
  92. STDMETHOD(put_CheckFlag)
  93. (/*[in]*/ CAPICOM_CHECK_FLAG newVal);
  94. STDMETHOD(get_Result)
  95. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  96. STDMETHOD(get_VerificationTime)
  97. (/*[out, retval]*/ DATE * pVal);
  98. STDMETHOD(put_VerificationTime)
  99. (/*[in]*/ DATE newVal);
  100. STDMETHOD(get_UrlRetrievalTimeout)
  101. (/*[out, retval]*/ long * pVal);
  102. STDMETHOD(put_UrlRetrievalTimeout)
  103. (/*[in]*/ long newVal);
  104. STDMETHOD(CertificatePolicies)
  105. (/*[out, retval]*/ IOIDs ** pVal);
  106. STDMETHOD(ApplicationPolicies)
  107. (/*[out, retval]*/ IOIDs ** pVal);
  108. //
  109. // None COM functions.
  110. //
  111. STDMETHOD(Init)(PCCERT_CONTEXT pCertContext);
  112. private:
  113. CLock m_Lock;
  114. DATE m_VerificationTime;
  115. DWORD m_dwUrlRetrievalTimeout;
  116. CComPtr<IEKU> m_pIEKU;
  117. CComPtr<IOIDs> m_pICertificatePolicies;
  118. CComPtr<IOIDs> m_pIApplicationPolicies;
  119. PCCERT_CONTEXT m_pCertContext;
  120. CAPICOM_CHECK_FLAG m_CheckFlag;
  121. };
  122. #endif //__CERTIFICATESTATUS_H_