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.

209 lines
3.6 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. );
  35. HRESULT
  36. OnAccessDenied(
  37. W3_MAIN_CONTEXT * pMainContext
  38. );
  39. DWORD
  40. QueryAuthType(
  41. VOID
  42. )
  43. {
  44. //
  45. // Yah Yah Yah. This really isn't a metabase auth type.
  46. //
  47. return MD_ACCESS_MAP_CERT;
  48. }
  49. };
  50. //
  51. // IISCERTMAP_CONTEXT_STATE is used to communicate information from DoesApply()
  52. // to DoAuthenticate() of IISCERTMAP_AUTH_PROVIDER
  53. //
  54. class IISCERTMAP_CONTEXT_STATE : public W3_MAIN_CONTEXT_STATE
  55. {
  56. public:
  57. IISCERTMAP_CONTEXT_STATE(
  58. TOKEN_CACHE_ENTRY * pCachedToken,
  59. BOOL fClientCertDeniedByIISCertMap
  60. )
  61. {
  62. pCachedToken->ReferenceCacheEntry();
  63. _pCachedIISCertMapToken = pCachedToken;
  64. _fClientCertDeniedByIISCertMap = fClientCertDeniedByIISCertMap;
  65. }
  66. BOOL
  67. Cleanup(
  68. W3_MAIN_CONTEXT * pMainContext
  69. )
  70. {
  71. if ( _pCachedIISCertMapToken != NULL )
  72. {
  73. _pCachedIISCertMapToken->DereferenceCacheEntry();
  74. _pCachedIISCertMapToken = NULL;
  75. }
  76. delete this;
  77. return TRUE;
  78. }
  79. TOKEN_CACHE_ENTRY *
  80. QueryCachedIISCertMapToken(
  81. VOID
  82. )
  83. {
  84. return _pCachedIISCertMapToken;
  85. }
  86. BOOL
  87. QueryClientCertDeniedByIISCertMap(
  88. VOID
  89. )
  90. {
  91. return _fClientCertDeniedByIISCertMap;
  92. }
  93. private:
  94. TOKEN_CACHE_ENTRY * _pCachedIISCertMapToken;
  95. BOOL _fClientCertDeniedByIISCertMap;
  96. };
  97. class IISCERTMAP_USER_CONTEXT : public W3_USER_CONTEXT
  98. {
  99. public:
  100. IISCERTMAP_USER_CONTEXT( AUTH_PROVIDER * pProvider )
  101. : W3_USER_CONTEXT( pProvider )
  102. {
  103. _fDelegatable = TRUE;
  104. _achUserName[ 0 ] = L'\0';
  105. }
  106. virtual ~IISCERTMAP_USER_CONTEXT()
  107. {
  108. if ( _pCachedToken != NULL )
  109. {
  110. _pCachedToken->DereferenceCacheEntry();
  111. _pCachedToken = NULL;
  112. }
  113. }
  114. HRESULT
  115. Create(
  116. TOKEN_CACHE_ENTRY * _pCachedToken
  117. );
  118. WCHAR *
  119. QueryUserName(
  120. VOID
  121. )
  122. {
  123. return _achUserName;
  124. }
  125. BOOL
  126. QueryDelegatable(
  127. VOID
  128. )
  129. {
  130. return _fDelegatable;
  131. }
  132. WCHAR *
  133. QueryPassword(
  134. VOID
  135. )
  136. {
  137. return L"";
  138. }
  139. DWORD
  140. QueryAuthType(
  141. VOID
  142. )
  143. {
  144. return MD_ACCESS_MAP_CERT;
  145. }
  146. HANDLE
  147. QueryImpersonationToken(
  148. VOID
  149. )
  150. {
  151. DBG_ASSERT( _pCachedToken != NULL );
  152. return _pCachedToken->QueryImpersonationToken();
  153. }
  154. HANDLE
  155. QueryPrimaryToken(
  156. VOID
  157. )
  158. {
  159. DBG_ASSERT( _pCachedToken != NULL );
  160. return _pCachedToken->QueryPrimaryToken();
  161. }
  162. BOOL
  163. IsValid(
  164. VOID
  165. )
  166. {
  167. return TRUE;
  168. }
  169. private:
  170. BOOL _fDelegatable;
  171. WCHAR _achUserName[ UNLEN + 1 ];
  172. TOKEN_CACHE_ENTRY * _pCachedToken;
  173. };
  174. #endif