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.

195 lines
4.9 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 PWSTR pwszRegUrl, // user supplied buffer ...
  37. IN OUT PDWORD pdwRegUrlLen, // ... and length (will be updated to actual length
  38. // on successful return)
  39. IN PWSTR pwszDARealm, // user supplied buffer ...
  40. IN OUT PDWORD pdwDARealmLen // ... and length (will be updated to actual length
  41. // on successful return)
  42. );
  43. BOOL GetDAInfo(PCWSTR pwszSignIn,
  44. LPWSTR pwszDAHostName,
  45. DWORD HostNameLen,
  46. LPWSTR pwszDAHostObj,
  47. DWORD HostObjLen);
  48. BOOL UpdateDAInfo(
  49. PCWSTR pwszSignIn,
  50. PCWSTR pwszDAUrl
  51. );
  52. void Logout(void);
  53. BOOL IsLoggedOut(void) const;
  54. const SYSTEMTIME* GetLogoutTimeStamp(void) const;
  55. void ResetLogoutFlag(void);
  56. virtual BOOL Open(PCWSTR pwszHttpStack, HINTERNET) = 0;
  57. virtual void Close(void) = 0;
  58. // methods below abstracts a subset of WinInet/WinHttp functionalities.
  59. virtual HINTERNET Connect(
  60. LPCWSTR lpwszServerName,
  61. INTERNET_PORT) = 0;
  62. virtual HINTERNET OpenRequest(
  63. HINTERNET hConnect,
  64. LPCWSTR lpwszVerb,
  65. LPCWSTR lpwszObjectName,
  66. DWORD dwFlags,
  67. DWORD_PTR dwContext = 0) = 0;
  68. virtual BOOL SendRequest(
  69. HINTERNET hRequest,
  70. LPCWSTR lpwszHeaders,
  71. DWORD dwHeadersLength,
  72. DWORD_PTR dwContext = 0) = 0;
  73. virtual BOOL QueryHeaders(
  74. HINTERNET hRequest,
  75. DWORD dwInfoLevel,
  76. LPVOID lpvBuffer,
  77. LPDWORD lpdwBufferLength,
  78. LPDWORD lpdwIndex = NULL) = 0;
  79. virtual BOOL CloseHandle(
  80. IN HINTERNET hInternet) = 0;
  81. virtual BOOL QueryOption(
  82. HINTERNET hInternet,
  83. DWORD dwOption,
  84. LPVOID lpBuffer,
  85. LPDWORD lpdwBufferLength) = 0;
  86. virtual BOOL SetOption(
  87. HINTERNET hInternet,
  88. DWORD dwOption,
  89. LPVOID lpBuffer,
  90. DWORD dwBufferLength) = 0;
  91. virtual HINTERNET OpenUrl(
  92. LPCWSTR lpwszUrl,
  93. LPCWSTR lpwszHeaders,
  94. DWORD dwHeadersLength,
  95. DWORD dwFlags) = 0;
  96. virtual BOOL ReadFile(
  97. HINTERNET hFile,
  98. LPVOID lpBuffer,
  99. DWORD dwNumberOfBytesToRead,
  100. LPDWORD lpdwNumberOfBytesRead) = 0;
  101. virtual BOOL CrackUrl(
  102. LPCWSTR lpszUrl,
  103. DWORD dwUrlLength,
  104. DWORD dwFlags,
  105. PVOID/*LPURL_COMPONENTSW*/ lpUrlComponents) = 0;
  106. virtual PVOID SetStatusCallback(
  107. HINTERNET hInternet,
  108. PVOID lpfnCallback
  109. ) = 0;
  110. virtual BOOL AddHeaders(
  111. HINTERNET hConnect,
  112. LPCWSTR lpszHeaders,
  113. DWORD dwHeadersLength,
  114. DWORD dwModifiers
  115. ) = 0;
  116. #ifdef PP_DEMO
  117. virtual BOOL ContactPartner(PCWSTR pwszPartnerUrl,
  118. PCWSTR pwszVerb,
  119. PCWSTR pwszHeaders,
  120. PWSTR pwszData,
  121. PDWORD pdwDataLength
  122. ) = 0;
  123. #endif // PP_DEMO
  124. protected:
  125. static UINT m_SessionIdSeed;
  126. HMODULE m_hHttpStack;
  127. HMODULE m_hCredUI;
  128. UINT m_SessionId;
  129. BOOL m_fOwnedSession;
  130. UINT m_RefCount;
  131. // WCHAR m_wDAHostName[256];
  132. // WCHAR m_wDATargetObj[64];
  133. WCHAR m_wRegistrationUrl[256];
  134. PFN_READ_DOMAIN_CRED_W
  135. m_pfnReadDomainCred;
  136. PFN_CRED_FREE m_pfnCredFree;
  137. HKEY m_hKeyLM;
  138. HKEY m_hKeyCU;
  139. HKEY m_hKeyDAMap;
  140. WCHAR m_wDefaultDAUrl[1024];
  141. DWORD m_LastNexusDownloadTime;
  142. BOOL m_fLogout;
  143. SYSTEMTIME m_LogoutTimeStamp;
  144. friend class LOGON;
  145. };
  146. #endif // SESSION_H