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.

210 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. session.h
  5. Abstract:
  6. This interface abstracts a Passport Session.
  7. Author:
  8. Biao Wang (biaow) 01-Oct-2000
  9. --*/
  10. #ifndef SESSION_H
  11. #define SESSION_H
  12. class SESSION
  13. {
  14. public:
  15. static
  16. BOOL CreateObject(PCWSTR pwszHttpStack, HINTERNET hSession, SESSION*& pSess);
  17. public:
  18. SESSION(void);
  19. virtual ~SESSION(void);
  20. UINT GetSessionId(void) const { return m_SessionId; }
  21. BOOL Match(UINT SessionId) const { return SessionId == m_SessionId; }
  22. void AddRef(void) { ++m_RefCount; }
  23. void RemoveRef(void)
  24. {
  25. if (m_RefCount > 0)
  26. {
  27. --m_RefCount;
  28. }
  29. }
  30. UINT RefCount(void) const { return m_RefCount; }
  31. // methods to retrieve the registry-configured value
  32. // PCWSTR GetLoginHost(void) const { return m_wDAHostName; }
  33. // PCWSTR GetLoginTarget(void) const { return m_wDATargetObj; }
  34. PCWSTR GetRegistrationUrl(void) const { return m_wRegistrationUrl; }
  35. BOOL GetDAInfoFromPPNexus(
  36. IN BOOL fForce,
  37. IN PWSTR pwszRegUrl, // user supplied buffer ...
  38. IN OUT PDWORD pdwRegUrlLen, // ... and length (will be updated to actual length
  39. // on successful return)
  40. IN PWSTR pwszDARealm, // user supplied buffer ...
  41. IN OUT PDWORD pdwDARealmLen // ... and length (will be updated to actual length
  42. // on successful return)
  43. );
  44. BOOL GetDAInfo(PCWSTR pwszSignIn,
  45. LPWSTR pwszDAHostName,
  46. DWORD HostNameLen,
  47. LPWSTR pwszDAHostObj,
  48. DWORD HostObjLen);
  49. BOOL UpdateDAInfo(
  50. PCWSTR pwszSignIn,
  51. PCWSTR pwszDAUrl
  52. );
  53. BOOL PurgeDAInfo(PCWSTR pwszSignIn);
  54. DWORD GetNexusVersion(void);
  55. BOOL GetCachedCreds(
  56. PCWSTR pwszRealm,
  57. PCWSTR pwszTarget,
  58. PCREDENTIALW** pppCreds,
  59. DWORD* pdwCreds
  60. );
  61. BOOL GetRealm(
  62. PWSTR pwszDARealm, // user supplied buffer ...
  63. PDWORD pdwDARealmLen // ... and length (will be updated to actual length
  64. // on successful return)
  65. ) const;
  66. virtual BOOL Open(PCWSTR pwszHttpStack, HINTERNET) = 0;
  67. virtual void Close(void) = 0;
  68. // methods below abstracts a subset of WinInet/WinHttp functionalities.
  69. virtual HINTERNET Connect(
  70. LPCWSTR lpwszServerName,
  71. INTERNET_PORT) = 0;
  72. virtual HINTERNET OpenRequest(
  73. HINTERNET hConnect,
  74. LPCWSTR lpwszVerb,
  75. LPCWSTR lpwszObjectName,
  76. DWORD dwFlags,
  77. DWORD_PTR dwContext = 0) = 0;
  78. virtual BOOL SendRequest(
  79. HINTERNET hRequest,
  80. LPCWSTR lpwszHeaders,
  81. DWORD dwHeadersLength,
  82. DWORD_PTR dwContext = 0) = 0;
  83. virtual BOOL QueryHeaders(
  84. HINTERNET hRequest,
  85. DWORD dwInfoLevel,
  86. LPVOID lpvBuffer,
  87. LPDWORD lpdwBufferLength,
  88. LPDWORD lpdwIndex = NULL) = 0;
  89. virtual BOOL CloseHandle(
  90. IN HINTERNET hInternet) = 0;
  91. virtual BOOL QueryOption(
  92. HINTERNET hInternet,
  93. DWORD dwOption,
  94. LPVOID lpBuffer,
  95. LPDWORD lpdwBufferLength) = 0;
  96. virtual BOOL SetOption(
  97. HINTERNET hInternet,
  98. DWORD dwOption,
  99. LPVOID lpBuffer,
  100. DWORD dwBufferLength) = 0;
  101. virtual HINTERNET OpenUrl(
  102. LPCWSTR lpwszUrl,
  103. LPCWSTR lpwszHeaders,
  104. DWORD dwHeadersLength,
  105. DWORD dwFlags) = 0;
  106. virtual BOOL ReadFile(
  107. HINTERNET hFile,
  108. LPVOID lpBuffer,
  109. DWORD dwNumberOfBytesToRead,
  110. LPDWORD lpdwNumberOfBytesRead) = 0;
  111. virtual BOOL CrackUrl(
  112. LPCWSTR lpszUrl,
  113. DWORD dwUrlLength,
  114. DWORD dwFlags,
  115. PVOID/*LPURL_COMPONENTSW*/ lpUrlComponents) = 0;
  116. virtual PVOID SetStatusCallback(
  117. HINTERNET hInternet,
  118. PVOID lpfnCallback
  119. ) = 0;
  120. virtual BOOL AddHeaders(
  121. HINTERNET hConnect,
  122. LPCWSTR lpszHeaders,
  123. DWORD dwHeadersLength,
  124. DWORD dwModifiers
  125. ) = 0;
  126. virtual BOOL IsHostBypassProxy(
  127. INTERNET_SCHEME tScheme,
  128. LPCSTR pszHost,
  129. DWORD cchHost) = 0;
  130. #ifdef PP_DEMO
  131. virtual BOOL ContactPartner(PCWSTR pwszPartnerUrl,
  132. PCWSTR pwszVerb,
  133. PCWSTR pwszHeaders,
  134. PWSTR pwszData,
  135. PDWORD pdwDataLength
  136. ) = 0;
  137. #endif // PP_DEMO
  138. LPCWSTR GetCurrentDAUrl(void) const { return m_wCurrentDAUrl; }
  139. protected:
  140. static UINT m_SessionIdSeed;
  141. HMODULE m_hHttpStack;
  142. HMODULE m_hCredUI;
  143. UINT m_SessionId;
  144. BOOL m_fOwnedSession;
  145. UINT m_RefCount;
  146. // WCHAR m_wDAHostName[256];
  147. // WCHAR m_wDATargetObj[64];
  148. WCHAR m_wRegistrationUrl[256];
  149. PFN_READ_DOMAIN_CRED_W
  150. m_pfnReadDomainCred;
  151. PFN_CRED_FREE m_pfnCredFree;
  152. HKEY m_hKeyLM;
  153. HKEY m_hKeyCU;
  154. HKEY m_hKeyDAMap;
  155. WCHAR m_wDefaultDAUrl[1024];
  156. WCHAR m_wCurrentDAUrl[1024];
  157. DWORD m_LastNexusDownloadTime;
  158. friend class LOGON;
  159. };
  160. #endif // SESSION_H