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.

235 lines
4.3 KiB

  1. #ifndef _IIS_CTL_HXX_
  2. #define _IIS_CTL_HXX_
  3. /*++
  4. Copyright (c) 2001 Microsoft Corporation
  5. Module Name :
  6. iisctl.hxx
  7. Abstract:
  8. IIS CTL (Certificate Trust List) handler
  9. This gets used only with SSL client certificates
  10. Author:
  11. Jaroslav Dunajsky
  12. Environment:
  13. Win32 - User Mode
  14. Project:
  15. Stream Filter Worker Process
  16. --*/
  17. class IIS_CTL_HASH;
  18. class CERT_STORE;
  19. #define IIS_CTL_SIGNATURE (DWORD)'CTLS'
  20. #define IIS_CTL_SIGNATURE_FREE (DWORD)'ctls'
  21. class IIS_CTL
  22. {
  23. public:
  24. BOOL
  25. CheckSignature(
  26. VOID
  27. ) const
  28. {
  29. return _dwSignature == IIS_CTL_SIGNATURE;
  30. }
  31. CREDENTIAL_ID *
  32. QueryCredentialId(
  33. VOID
  34. ) const
  35. {
  36. return _pCredentialId;
  37. }
  38. VOID
  39. ReferenceIisCtl(
  40. VOID
  41. )
  42. {
  43. InterlockedIncrement( &_cRefs );
  44. }
  45. VOID
  46. DereferenceIisCtl(
  47. VOID
  48. )
  49. {
  50. if ( !InterlockedDecrement( &_cRefs ) )
  51. {
  52. delete this;
  53. }
  54. }
  55. HCERTSTORE
  56. QueryStore(
  57. VOID
  58. ) const
  59. {
  60. return _pCtlStore->QueryStore();
  61. }
  62. HRESULT
  63. VerifyContainsCert(
  64. IN PCCERT_CONTEXT pChainTop,
  65. OUT BOOL * pfContainsCert
  66. );
  67. static
  68. HRESULT
  69. Initialize(
  70. VOID
  71. );
  72. static
  73. VOID
  74. Terminate(
  75. VOID
  76. );
  77. static
  78. HRESULT
  79. GetIisCtl(
  80. IN WCHAR * pszSslCtlIdentifier,
  81. IN WCHAR * pszSslCtlStoreName,
  82. OUT IIS_CTL ** ppIisCtl
  83. );
  84. static
  85. HRESULT
  86. FlushByStore(
  87. IN CERT_STORE * pCertStore
  88. );
  89. static
  90. VOID
  91. Cleanup(
  92. VOID
  93. );
  94. private:
  95. // Private Constructor
  96. // use GetIisCtl to get referenced instance of the object
  97. //
  98. IIS_CTL(
  99. IN CREDENTIAL_ID * pCredentialId
  100. );
  101. // Private Destructor
  102. // use DereferenceIisCtl() for cleanup
  103. //
  104. virtual
  105. ~IIS_CTL();
  106. HRESULT
  107. SetupIisCtl(
  108. IN WCHAR * pszSslCtlIdentifier,
  109. IN WCHAR * pszSslCtlStoreName
  110. );
  111. static
  112. LK_PREDICATE
  113. CertStorePredicate(
  114. IN IIS_CTL * pIisCtl,
  115. IN void * pvState
  116. );
  117. static
  118. HRESULT
  119. BuildCredentialId(
  120. IN WCHAR * pszSslCtlIdentifier,
  121. OUT CREDENTIAL_ID * pCredentialId
  122. );
  123. DWORD _dwSignature;
  124. LONG _cRefs;
  125. PCCTL_CONTEXT _pCtlContext;
  126. CERT_STORE * _pCtlStore;
  127. CREDENTIAL_ID * _pCredentialId;
  128. static IIS_CTL_HASH * sm_pIisCtlHash;
  129. };
  130. class IIS_CTL_HASH
  131. : public CTypedHashTable<
  132. IIS_CTL_HASH,
  133. IIS_CTL,
  134. CREDENTIAL_ID *
  135. >
  136. {
  137. public:
  138. IIS_CTL_HASH()
  139. : CTypedHashTable< IIS_CTL_HASH,
  140. IIS_CTL,
  141. CREDENTIAL_ID * > ( "IIS_CTL_HASH" )
  142. {
  143. }
  144. static
  145. CREDENTIAL_ID *
  146. ExtractKey(
  147. const IIS_CTL * pIisCtl
  148. )
  149. {
  150. return pIisCtl->QueryCredentialId();
  151. }
  152. static
  153. DWORD
  154. CalcKeyHash(
  155. CREDENTIAL_ID * pCredentialId
  156. )
  157. {
  158. return HashBlob( pCredentialId->QueryBuffer(),
  159. pCredentialId->QuerySize() );
  160. }
  161. static
  162. bool
  163. EqualKeys(
  164. CREDENTIAL_ID * pId1,
  165. CREDENTIAL_ID * pId2
  166. )
  167. {
  168. return CREDENTIAL_ID::IsEqual( pId1, pId2 );
  169. }
  170. static
  171. void
  172. AddRefRecord(
  173. IIS_CTL * pIisCtl,
  174. int nIncr
  175. )
  176. {
  177. if ( nIncr == +1 )
  178. {
  179. pIisCtl->ReferenceIisCtl();
  180. }
  181. else if ( nIncr == -1 )
  182. {
  183. pIisCtl->DereferenceIisCtl();
  184. }
  185. }
  186. private:
  187. //
  188. // Not implemented methods
  189. // Declarations present to prevent compiler
  190. // to generate default ones.
  191. //
  192. IIS_CTL_HASH( const IIS_CTL_HASH& );
  193. IIS_CTL_HASH& operator=( const IIS_CTL_HASH& );
  194. };
  195. #endif