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.

134 lines
3.5 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: EncodedData.h
  5. Content: Declaration of CEncodedData.
  6. History: 06-15-2001 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __ENCODEDDATA_H_
  9. #define __ENCODEDDATA_H_
  10. #include "Resource.h"
  11. #include "Error.h"
  12. #include "Lock.h"
  13. #include "Debug.h"
  14. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  15. Function : CreateEncodedDataObject
  16. Synopsis : Create and initialize an CEncodedData object.
  17. Parameter: LPSTR pszOid - Pointer to OID string.
  18. CRYPT_DATA_BLOB * pEncodedBlob - Pointer to encoded data blob.
  19. IEncodedData ** ppIEncodedData - Pointer to pointer IEncodedData
  20. object.
  21. Remark :
  22. ------------------------------------------------------------------------------*/
  23. HRESULT CreateEncodedDataObject (LPSTR pszOid,
  24. CRYPT_DATA_BLOB * pEncodedBlob,
  25. IEncodedData ** ppIEncodedData);
  26. ////////////////////////////////////////////////////////////////////////////////
  27. //
  28. // CEncodedData
  29. //
  30. class ATL_NO_VTABLE CEncodedData :
  31. public CComObjectRootEx<CComMultiThreadModel>,
  32. public CComCoClass<CEncodedData, &CLSID_EncodedData>,
  33. public ICAPICOMError<CEncodedData, &IID_IEncodedData>,
  34. public IDispatchImpl<IEncodedData, &IID_IEncodedData, &LIBID_CAPICOM,
  35. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  36. {
  37. public:
  38. CEncodedData()
  39. {
  40. }
  41. DECLARE_NO_REGISTRY()
  42. DECLARE_PROTECT_FINAL_CONSTRUCT()
  43. BEGIN_COM_MAP(CEncodedData)
  44. COM_INTERFACE_ENTRY(IEncodedData)
  45. COM_INTERFACE_ENTRY(IDispatch)
  46. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  47. END_COM_MAP()
  48. BEGIN_CATEGORY_MAP(CEncodedData)
  49. END_CATEGORY_MAP()
  50. HRESULT FinalConstruct()
  51. {
  52. HRESULT hr;
  53. if (FAILED(hr = m_Lock.Initialized()))
  54. {
  55. DebugTrace("Error [%#x]: Critical section could not be created for Certificate object.\n", hr);
  56. return hr;
  57. }
  58. m_pszOid = NULL;
  59. m_pIDecoder = NULL;
  60. m_EncodedBlob.cbData = 0;
  61. m_EncodedBlob.pbData = NULL;
  62. return S_OK;
  63. }
  64. void FinalRelease()
  65. {
  66. m_pIDecoder.Release();
  67. if (m_pszOid)
  68. {
  69. ::CoTaskMemFree(m_pszOid);
  70. }
  71. if (m_EncodedBlob.pbData)
  72. {
  73. ::CoTaskMemFree(m_EncodedBlob.pbData);
  74. }
  75. }
  76. //
  77. // IEncodedData
  78. //
  79. public:
  80. STDMETHOD(get_Value)
  81. (/*[in, defaultvalue(CAPICOM_ENCODE_BASE64)]*/ CAPICOM_ENCODING_TYPE EncodingType,
  82. /*[out, retval]*/ BSTR * pVal);
  83. STDMETHOD(Format)
  84. (/*[in, defaultvalue(VARIANT_FALSE)]*/ VARIANT_BOOL bMultiLines,
  85. /*[out, retval]*/ BSTR * pVal);
  86. STDMETHOD(Decoder)
  87. (/*[out, retval]*/ IDispatch ** pVal);
  88. //
  89. // C++ member function needed to initialize the object.
  90. //
  91. STDMETHOD(Init)
  92. (LPSTR pszOid,
  93. CRYPT_DATA_BLOB * pEncodedBlob);
  94. private:
  95. CLock m_Lock;
  96. LPSTR m_pszOid;
  97. CComPtr<IDispatch> m_pIDecoder;
  98. CRYPT_DATA_BLOB m_EncodedBlob;
  99. };
  100. #endif //__ENCODEDDATA_H_