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.

181 lines
3.1 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. );
  32. HRESULT
  33. OnAccessDenied(
  34. W3_MAIN_CONTEXT * pMainContext
  35. );
  36. DWORD
  37. QueryAuthType(
  38. VOID
  39. )
  40. {
  41. return MD_AUTH_BASIC;
  42. }
  43. private:
  44. virtual ~BASIC_AUTH_PROVIDER()
  45. {
  46. }
  47. };
  48. class BASIC_USER_CONTEXT : public W3_USER_CONTEXT
  49. {
  50. public:
  51. BASIC_USER_CONTEXT( AUTH_PROVIDER * pProvider )
  52. : W3_USER_CONTEXT( pProvider )
  53. {
  54. _pCachedToken = NULL;
  55. _fDelegatable = FALSE;
  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. BOOL
  82. QueryDelegatable(
  83. VOID
  84. )
  85. {
  86. return _fDelegatable;
  87. }
  88. WCHAR *
  89. QueryPassword(
  90. VOID
  91. )
  92. {
  93. return _strPassword.QueryStr();
  94. }
  95. DWORD
  96. QueryAuthType(
  97. VOID
  98. )
  99. {
  100. return MD_AUTH_BASIC;
  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. TOKEN_CACHE_ENTRY *
  134. QueryCachedToken(
  135. VOID
  136. )
  137. {
  138. return _pCachedToken;
  139. }
  140. private:
  141. TOKEN_CACHE_ENTRY * _pCachedToken;
  142. BOOL _fDelegatable;
  143. STRU _strUserName;
  144. STRU _strPassword;
  145. STRU _strRemoteUserName;
  146. virtual ~BASIC_USER_CONTEXT()
  147. {
  148. if ( _pCachedToken != NULL )
  149. {
  150. _pCachedToken->DereferenceCacheEntry();
  151. _pCachedToken = NULL;
  152. }
  153. }
  154. };
  155. #endif