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.

133 lines
3.7 KiB

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