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.

138 lines
2.6 KiB

  1. #ifndef _CERTCONTEXT_HXX_
  2. #define _CERTCONTEXT_HXX_
  3. #include <wincrypt.h>
  4. #define HEX_DIGIT( nDigit ) \
  5. (WCHAR)((nDigit) > 9 ? \
  6. (nDigit) - 10 + L'a' \
  7. : (nDigit) + L'0')
  8. class CERTIFICATE_CONTEXT
  9. {
  10. public:
  11. CERTIFICATE_CONTEXT(
  12. HTTP_SSL_CLIENT_CERT_INFO * pClientCertInfo
  13. );
  14. virtual ~CERTIFICATE_CONTEXT();
  15. VOID
  16. QueryEncodedCertificate(
  17. PVOID * ppvData,
  18. DWORD * pcbData
  19. )
  20. {
  21. DBG_ASSERT( ppvData != NULL );
  22. DBG_ASSERT( pcbData != NULL );
  23. *ppvData = _pClientCertInfo->pCertEncoded;
  24. *pcbData = _pClientCertInfo->CertEncodedSize;
  25. }
  26. DWORD
  27. QueryFlags(
  28. VOID
  29. ) const
  30. {
  31. return _pClientCertInfo->CertFlags;
  32. }
  33. DWORD
  34. QueryDeniedByMapper(
  35. VOID
  36. ) const
  37. {
  38. return _pClientCertInfo->CertDeniedByMapper;
  39. }
  40. HANDLE
  41. QueryImpersonationToken(
  42. VOID
  43. ) const
  44. {
  45. return _pClientCertInfo->Token;
  46. }
  47. HRESULT
  48. GetFlags(
  49. STRA * pstrFlags
  50. );
  51. HRESULT
  52. GetSerialNumber(
  53. STRA * pstrSerialNumber
  54. );
  55. HRESULT
  56. GetCookie(
  57. STRA * pstrCookie
  58. );
  59. HRESULT
  60. GetIssuer(
  61. STRA * pstrIssuer
  62. );
  63. HRESULT
  64. GetSubject(
  65. STRA * pstrIssuer
  66. );
  67. VOID *
  68. operator new(
  69. size_t size
  70. )
  71. {
  72. DBG_ASSERT( size == sizeof( CERTIFICATE_CONTEXT ) );
  73. DBG_ASSERT( sm_pachCertContexts != NULL );
  74. return sm_pachCertContexts->Alloc();
  75. }
  76. VOID
  77. operator delete(
  78. VOID * pCertContext
  79. )
  80. {
  81. DBG_ASSERT( pCertContext != NULL );
  82. DBG_ASSERT( sm_pachCertContexts != NULL );
  83. DBG_REQUIRE( sm_pachCertContexts->Free( pCertContext ) );
  84. }
  85. static
  86. HRESULT
  87. Initialize(
  88. VOID
  89. );
  90. static
  91. VOID
  92. Terminate(
  93. VOID
  94. );
  95. private:
  96. CERT_INFO *
  97. QueryCertInfo(
  98. VOID
  99. )
  100. {
  101. return (CERT_INFO*) _buffCertInfo.QueryPtr();
  102. }
  103. HRESULT
  104. DecodeCert(
  105. VOID
  106. );
  107. HTTP_SSL_CLIENT_CERT_INFO * _pClientCertInfo;
  108. BOOL _fCertDecoded;
  109. CERT_INFO _CertInfo;
  110. BUFFER _buffCertInfo;
  111. static HCRYPTPROV sm_CryptProvider;
  112. static ALLOC_CACHE_HANDLER * sm_pachCertContexts;
  113. };
  114. #endif