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.

232 lines
4.5 KiB

  1. #ifndef _IISCERTMAPPROVIDER_HXX_
  2. #define _IISCERTMAPPROVIDER_HXX_
  3. class IISCERTMAP_AUTH_PROVIDER : public AUTH_PROVIDER
  4. {
  5. public:
  6. IISCERTMAP_AUTH_PROVIDER()
  7. {
  8. }
  9. virtual ~IISCERTMAP_AUTH_PROVIDER()
  10. {
  11. }
  12. HRESULT
  13. Initialize(
  14. DWORD dwInternalId
  15. )
  16. {
  17. SetInternalId( dwInternalId );
  18. return NO_ERROR;
  19. }
  20. VOID
  21. Terminate(
  22. VOID
  23. )
  24. {
  25. }
  26. HRESULT
  27. DoesApply(
  28. W3_MAIN_CONTEXT * pMainContext,
  29. BOOL * pfApplies
  30. );
  31. HRESULT
  32. DoAuthenticate(
  33. W3_MAIN_CONTEXT * pMainContext,
  34. BOOL * pfFilterFinished
  35. );
  36. HRESULT
  37. OnAccessDenied(
  38. W3_MAIN_CONTEXT * pMainContext
  39. );
  40. DWORD
  41. QueryAuthType(
  42. VOID
  43. )
  44. {
  45. //
  46. // This really isn't a metabase auth type.
  47. // It is important to note that
  48. // there must be no MD_AUTH_* defined that
  49. // equals to MD_ACCESS_MAP_CERT
  50. //
  51. return MD_ACCESS_MAP_CERT;
  52. }
  53. };
  54. //
  55. // IISCERTMAP_CONTEXT_STATE is used to communicate information from DoesApply()
  56. // to DoAuthenticate() of IISCERTMAP_AUTH_PROVIDER
  57. //
  58. class IISCERTMAP_CONTEXT_STATE : public W3_MAIN_CONTEXT_STATE
  59. {
  60. public:
  61. IISCERTMAP_CONTEXT_STATE(
  62. TOKEN_CACHE_ENTRY * pCachedToken,
  63. BOOL fClientCertDeniedByIISCertMap
  64. )
  65. {
  66. if ( pCachedToken != NULL )
  67. {
  68. pCachedToken->ReferenceCacheEntry();
  69. }
  70. else
  71. {
  72. //
  73. // if fClientCertDeniedByIISCertMap is TRUE then p
  74. // CachedToken should be NULL
  75. //
  76. DBG_ASSERT( fClientCertDeniedByIISCertMap );
  77. }
  78. _pCachedIISCertMapToken = pCachedToken;
  79. _fClientCertDeniedByIISCertMap = fClientCertDeniedByIISCertMap;
  80. }
  81. BOOL
  82. Cleanup(
  83. W3_MAIN_CONTEXT * /*pMainContext*/
  84. )
  85. {
  86. if ( _pCachedIISCertMapToken != NULL )
  87. {
  88. _pCachedIISCertMapToken->DereferenceCacheEntry();
  89. _pCachedIISCertMapToken = NULL;
  90. }
  91. delete this;
  92. return TRUE;
  93. }
  94. TOKEN_CACHE_ENTRY *
  95. QueryCachedIISCertMapToken(
  96. VOID
  97. )
  98. {
  99. return _pCachedIISCertMapToken;
  100. }
  101. BOOL
  102. QueryClientCertDeniedByIISCertMap(
  103. VOID
  104. )
  105. {
  106. return _fClientCertDeniedByIISCertMap;
  107. }
  108. private:
  109. TOKEN_CACHE_ENTRY * _pCachedIISCertMapToken;
  110. //
  111. // flag that IIS certificate mapper has denied authentication
  112. //
  113. BOOL _fClientCertDeniedByIISCertMap;
  114. };
  115. class IISCERTMAP_USER_CONTEXT : public W3_USER_CONTEXT
  116. {
  117. public:
  118. IISCERTMAP_USER_CONTEXT( AUTH_PROVIDER * pProvider )
  119. : W3_USER_CONTEXT( pProvider )
  120. {
  121. _achUserName[ 0 ] = L'\0';
  122. }
  123. virtual ~IISCERTMAP_USER_CONTEXT()
  124. {
  125. if ( _pCachedToken != NULL )
  126. {
  127. _pCachedToken->DereferenceCacheEntry();
  128. _pCachedToken = NULL;
  129. }
  130. }
  131. HRESULT
  132. Create(
  133. TOKEN_CACHE_ENTRY * _pCachedToken
  134. );
  135. WCHAR *
  136. QueryUserName(
  137. VOID
  138. )
  139. {
  140. return _achUserName;
  141. }
  142. WCHAR *
  143. QueryPassword(
  144. VOID
  145. )
  146. {
  147. return L"";
  148. }
  149. DWORD
  150. QueryAuthType(
  151. VOID
  152. )
  153. {
  154. //
  155. // This really isn't a metabase auth type.
  156. // It is important to note that
  157. // there must be no MD_AUTH_* defined that
  158. // equals to MD_ACCESS_MAP_CERT
  159. //
  160. return MD_ACCESS_MAP_CERT;
  161. }
  162. TOKEN_CACHE_ENTRY *
  163. QueryCachedToken(
  164. VOID
  165. )
  166. {
  167. return _pCachedToken;
  168. }
  169. HANDLE
  170. QueryImpersonationToken(
  171. VOID
  172. )
  173. {
  174. DBG_ASSERT( _pCachedToken != NULL );
  175. return _pCachedToken->QueryImpersonationToken();
  176. }
  177. HANDLE
  178. QueryPrimaryToken(
  179. VOID
  180. )
  181. {
  182. DBG_ASSERT( _pCachedToken != NULL );
  183. return _pCachedToken->QueryPrimaryToken();
  184. }
  185. BOOL
  186. IsValid(
  187. VOID
  188. )
  189. {
  190. return TRUE;
  191. }
  192. private:
  193. WCHAR _achUserName[ UNLEN + 1 ];
  194. TOKEN_CACHE_ENTRY * _pCachedToken;
  195. };
  196. #endif