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.

280 lines
5.6 KiB

  1. #ifndef _PASSPORTPROVIDER_HXX_
  2. #define _PASSPORTPROVIDER_HXX_
  3. #include <passport.h>
  4. class PASSPORT_AUTH_PROVIDER : public AUTH_PROVIDER
  5. {
  6. public:
  7. PASSPORT_AUTH_PROVIDER()
  8. : _fInitialized( FALSE )
  9. {
  10. }
  11. virtual ~PASSPORT_AUTH_PROVIDER()
  12. {
  13. }
  14. HRESULT
  15. Initialize(
  16. DWORD dwInternalId
  17. );
  18. VOID
  19. Terminate(
  20. VOID
  21. );
  22. HRESULT
  23. DoesApply(
  24. W3_MAIN_CONTEXT * pMainContext,
  25. BOOL * pfApplies
  26. );
  27. HRESULT
  28. DoAuthenticate(
  29. W3_MAIN_CONTEXT * pMainContext,
  30. BOOL * pfFilterFinished
  31. );
  32. HRESULT
  33. OnAccessDenied(
  34. W3_MAIN_CONTEXT * pMainContext
  35. );
  36. HRESULT
  37. DoTweenerSpecialCase(
  38. W3_MAIN_CONTEXT * pMainContext,
  39. BOOL * pfTweenerHandled
  40. );
  41. HRESULT
  42. EscapeAmpersands(
  43. STRA & strUrl
  44. );
  45. DWORD
  46. QueryAuthType(
  47. VOID
  48. )
  49. {
  50. return MD_AUTH_PASSPORT;
  51. }
  52. private:
  53. BOOL _fInitialized;
  54. CRITICAL_SECTION _csInitLock;
  55. };
  56. #define PASSPORT_CONTEXT_SIGNATURE 'SCFP'
  57. #define PASSPORT_CONTEXT_SIGNATURE_FREE 'xcfp'
  58. class PASSPORT_CONTEXT : public W3_MAIN_CONTEXT_STATE
  59. {
  60. public:
  61. PASSPORT_CONTEXT()
  62. {
  63. _fAuthenticated = FALSE;
  64. _pPassportManager = NULL;
  65. _fTweener = FALSE;
  66. _dwSignature = PASSPORT_CONTEXT_SIGNATURE;
  67. }
  68. virtual ~PASSPORT_CONTEXT()
  69. {
  70. _dwSignature = PASSPORT_CONTEXT_SIGNATURE_FREE;
  71. if ( _pPassportManager != NULL )
  72. {
  73. _pPassportManager->Release();
  74. _pPassportManager = NULL;
  75. }
  76. }
  77. BOOL
  78. Cleanup(
  79. W3_MAIN_CONTEXT * pMainContext
  80. )
  81. {
  82. UNREFERENCED_PARAMETER( pMainContext );
  83. delete this;
  84. return TRUE;
  85. }
  86. BOOL
  87. CheckSignature(
  88. VOID
  89. ) const
  90. {
  91. return _dwSignature == PASSPORT_CONTEXT_SIGNATURE;
  92. }
  93. HRESULT
  94. Create(
  95. W3_FILTER_CONTEXT * pFilterContext
  96. );
  97. VOID
  98. SetTweener(
  99. BOOL fTweener
  100. )
  101. {
  102. _fTweener = fTweener;
  103. }
  104. BOOL
  105. QueryIsTweener(
  106. VOID
  107. ) const
  108. {
  109. return _fTweener;
  110. }
  111. BOOL
  112. QueryUserError(
  113. VOID
  114. );
  115. HRESULT
  116. SetupDefaultRedirect(
  117. W3_MAIN_CONTEXT * pMainContext,
  118. BOOL * pfSetupRedirect
  119. );
  120. HRESULT
  121. DoesApply(
  122. HTTP_FILTER_CONTEXT * pfc,
  123. BOOL * pfDoesApply,
  124. STRA * pstrReturnCookie
  125. );
  126. HRESULT
  127. DoAuthenticate(
  128. W3_MAIN_CONTEXT * pMainContext,
  129. TOKEN_CACHE_ENTRY ** ppCachedToken,
  130. STRU * pstrAuthUser,
  131. STRU * pstrRemoteUser,
  132. STRU & strDomainName
  133. );
  134. HRESULT
  135. OnChallenge(
  136. STRU & strOriginalUrl
  137. );
  138. BOOL
  139. QueryIsAuthenticated(
  140. VOID
  141. ) const
  142. {
  143. return _fAuthenticated;
  144. }
  145. static
  146. HRESULT
  147. Initialize(
  148. VOID
  149. );
  150. static
  151. VOID
  152. Terminate(
  153. VOID
  154. );
  155. private:
  156. DWORD _dwSignature;
  157. IPassportManager3 * _pPassportManager;
  158. BOOL _fAuthenticated;
  159. BOOL _fTweener;
  160. BUFFER _buffCookie;
  161. static IPassportFactory * sm_pPassportManagerFactory;
  162. static BSTR sm_bstrMemberIdHigh;
  163. static BSTR sm_bstrMemberIdLow;
  164. static BSTR sm_bstrReturnUrl;
  165. static BSTR sm_bstrTimeWindow;
  166. static BSTR sm_bstrForceSignIn;
  167. static BSTR sm_bstrCoBrandTemplate;
  168. static BSTR sm_bstrLanguageId;
  169. static BSTR sm_bstrSecureLevel;
  170. };
  171. class PASSPORT_USER_CONTEXT : public W3_USER_CONTEXT
  172. {
  173. public:
  174. PASSPORT_USER_CONTEXT( AUTH_PROVIDER * pProvider )
  175. : W3_USER_CONTEXT( pProvider )
  176. {
  177. _pToken = NULL;
  178. }
  179. virtual ~PASSPORT_USER_CONTEXT()
  180. {
  181. if ( _pToken != NULL )
  182. {
  183. _pToken->DereferenceCacheEntry();
  184. _pToken = NULL;
  185. }
  186. }
  187. HRESULT
  188. Create(
  189. TOKEN_CACHE_ENTRY * pToken,
  190. STRU & strAuthUser,
  191. STRU & strRemoteUser
  192. );
  193. WCHAR *
  194. QueryUserName(
  195. VOID
  196. )
  197. {
  198. return _strAuthUser.QueryStr();
  199. }
  200. WCHAR *
  201. QueryRemoteUserName(
  202. VOID
  203. )
  204. {
  205. return _strRemoteUser.QueryStr();
  206. }
  207. WCHAR *
  208. QueryPassword(
  209. VOID
  210. )
  211. {
  212. return L"";
  213. }
  214. DWORD
  215. QueryAuthType(
  216. VOID
  217. )
  218. {
  219. return MD_AUTH_PASSPORT;
  220. }
  221. HANDLE
  222. QueryImpersonationToken(
  223. VOID
  224. );
  225. HANDLE
  226. QueryPrimaryToken(
  227. VOID
  228. );
  229. private:
  230. STRU _strAuthUser;
  231. STRU _strRemoteUser;
  232. TOKEN_CACHE_ENTRY * _pToken;
  233. };
  234. #endif