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.

178 lines
3.3 KiB

  1. #ifndef _BASICPROVIDER_HXX_
  2. #define _BASICPROVIDER_HXX_
  3. class BASIC_AUTH_PROVIDER : public AUTH_PROVIDER
  4. {
  5. public:
  6. BASIC_AUTH_PROVIDER()
  7. {
  8. }
  9. HRESULT
  10. Initialize(
  11. DWORD dwInternalId
  12. )
  13. {
  14. SetInternalId( dwInternalId );
  15. return NO_ERROR;
  16. }
  17. VOID
  18. Terminate(
  19. VOID
  20. )
  21. {
  22. }
  23. HRESULT
  24. DoesApply(
  25. W3_MAIN_CONTEXT * pMainContext,
  26. BOOL * pfApplies
  27. );
  28. HRESULT
  29. DoAuthenticate(
  30. W3_MAIN_CONTEXT * pMainContext,
  31. BOOL * pfFilterFinished
  32. );
  33. HRESULT
  34. OnAccessDenied(
  35. W3_MAIN_CONTEXT * pMainContext
  36. );
  37. DWORD
  38. QueryAuthType(
  39. VOID
  40. )
  41. {
  42. return MD_AUTH_BASIC;
  43. }
  44. private:
  45. virtual ~BASIC_AUTH_PROVIDER()
  46. {
  47. }
  48. };
  49. class BASIC_USER_CONTEXT : public W3_USER_CONTEXT
  50. {
  51. public:
  52. BASIC_USER_CONTEXT( AUTH_PROVIDER * pProvider )
  53. : W3_USER_CONTEXT( pProvider )
  54. {
  55. _pCachedToken = NULL;
  56. }
  57. HRESULT
  58. Create(
  59. TOKEN_CACHE_ENTRY * pCachedToken,
  60. STRU & strUserName,
  61. STRU & strDomainName,
  62. STRU & strUnmappedPassword,
  63. STRU & strRemoteUserName,
  64. STRU & strMappedDomainUser,
  65. DWORD dwLogonMethod
  66. );
  67. WCHAR *
  68. QueryUserName(
  69. VOID
  70. )
  71. {
  72. return _strUserName.QueryStr();
  73. }
  74. WCHAR *
  75. QueryRemoteUserName(
  76. VOID
  77. )
  78. {
  79. return _strRemoteUserName.QueryStr();
  80. }
  81. WCHAR *
  82. QueryPassword(
  83. VOID
  84. )
  85. {
  86. return _strPassword.QueryStr();
  87. }
  88. DWORD
  89. QueryAuthType(
  90. VOID
  91. )
  92. {
  93. return MD_AUTH_BASIC;
  94. }
  95. TOKEN_CACHE_ENTRY *
  96. QueryCachedToken(
  97. VOID
  98. )
  99. {
  100. return _pCachedToken;
  101. }
  102. HANDLE
  103. QueryImpersonationToken(
  104. VOID
  105. )
  106. {
  107. DBG_ASSERT( _pCachedToken != NULL );
  108. return _pCachedToken->QueryImpersonationToken();
  109. }
  110. HANDLE
  111. QueryPrimaryToken(
  112. VOID
  113. )
  114. {
  115. DBG_ASSERT( _pCachedToken != NULL );
  116. return _pCachedToken->QueryPrimaryToken();
  117. }
  118. PSID
  119. QuerySid(
  120. VOID
  121. )
  122. {
  123. DBG_ASSERT( _pCachedToken != NULL );
  124. return _pCachedToken->QuerySid();
  125. }
  126. LARGE_INTEGER *
  127. QueryExpiry(
  128. VOID
  129. )
  130. {
  131. return QueryCachedToken()->QueryExpiry();
  132. }
  133. private:
  134. TOKEN_CACHE_ENTRY * _pCachedToken;
  135. STRU _strUserName;
  136. STRU _strPassword;
  137. STRU _strRemoteUserName;
  138. virtual ~BASIC_USER_CONTEXT()
  139. {
  140. if ( _pCachedToken != NULL )
  141. {
  142. _pCachedToken->DereferenceCacheEntry();
  143. _pCachedToken = NULL;
  144. }
  145. if( _strPassword.QueryCB() )
  146. {
  147. ZeroMemory( ( VOID * )_strPassword.QueryStr(),
  148. _strPassword.QueryCB() );
  149. }
  150. }
  151. };
  152. #endif