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.

130 lines
3.3 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: ExtendedKeyUsage.h
  5. Content: Declaration of the CExtendedKeyUsage.
  6. History: 11-15-99 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __EXTENDEDKEYUSAGE_H_
  9. #define __EXTENDEDKEYUSAGE_H_
  10. #include "Resource.h"
  11. #include "Error.h"
  12. #include "Lock.h"
  13. #include "Debug.h"
  14. #include "EKUs.h"
  15. ////////////////////////////////////////////////////////////////////////////////
  16. //
  17. // Exported functions.
  18. //
  19. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  20. Function : CreateExtendedKeyUsageObject
  21. Synopsis : Create an IExtendedKeyUsage object and populate the object
  22. with EKU data from the certificate.
  23. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT.
  24. IExtendedKeyUsage ** ppIExtendedKeyUsage - Pointer to pointer to
  25. IExtendedKeyUsage
  26. object.
  27. Remark :
  28. ------------------------------------------------------------------------------*/
  29. HRESULT CreateExtendedKeyUsageObject (PCCERT_CONTEXT pCertContext,
  30. IExtendedKeyUsage ** ppIExtendedKeyUsage);
  31. ///////////////////////////////////////////////////////////////////////////////
  32. //
  33. // CExtendedKeyUsage
  34. //
  35. class ATL_NO_VTABLE CExtendedKeyUsage :
  36. public CComObjectRootEx<CComMultiThreadModel>,
  37. public CComCoClass<CExtendedKeyUsage, &CLSID_ExtendedKeyUsage>,
  38. public ICAPICOMError<CExtendedKeyUsage, &IID_IExtendedKeyUsage>,
  39. public IDispatchImpl<IExtendedKeyUsage, &IID_IExtendedKeyUsage, &LIBID_CAPICOM,
  40. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  41. {
  42. public:
  43. CExtendedKeyUsage()
  44. {
  45. }
  46. DECLARE_NO_REGISTRY()
  47. DECLARE_GET_CONTROLLING_UNKNOWN()
  48. DECLARE_PROTECT_FINAL_CONSTRUCT()
  49. BEGIN_COM_MAP(CExtendedKeyUsage)
  50. COM_INTERFACE_ENTRY(IExtendedKeyUsage)
  51. COM_INTERFACE_ENTRY(IDispatch)
  52. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  53. END_COM_MAP()
  54. BEGIN_CATEGORY_MAP(CExtendedKeyUsage)
  55. END_CATEGORY_MAP()
  56. HRESULT FinalConstruct()
  57. {
  58. HRESULT hr;
  59. if (FAILED(hr = m_Lock.Initialized()))
  60. {
  61. DebugTrace("Error [%#x]: Critical section could not be created for ExtendedKeyUsage object.\n", hr);
  62. return hr;
  63. }
  64. m_pIEKUs = NULL;
  65. m_bIsPresent = VARIANT_FALSE;
  66. m_bIsCritical = VARIANT_FALSE;
  67. return S_OK;
  68. }
  69. void FinalRelease()
  70. {
  71. m_pIEKUs.Release();
  72. }
  73. //
  74. // IExtendedKeyUsage
  75. //
  76. public:
  77. STDMETHOD(get_IsPresent)
  78. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  79. STDMETHOD(get_IsCritical)
  80. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  81. STDMETHOD(get_EKUs)
  82. (/*[out, retval]*/ IEKUs ** pVal);
  83. //
  84. // None COM functions.
  85. //
  86. STDMETHOD(Init)
  87. (PCCERT_CONTEXT pCertContext);
  88. private:
  89. CLock m_Lock;
  90. CComPtr<IEKUs> m_pIEKUs;
  91. VARIANT_BOOL m_bIsPresent;
  92. VARIANT_BOOL m_bIsCritical;
  93. };
  94. #endif //__EXTENDEDKEYUSAGE_H_