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.

175 lines
5.4 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // @doc
  4. //
  5. // @module CTicket.h | Declaration of the CTicket class.
  6. //
  7. // Author: Darren Anderson
  8. //
  9. // Date: 5/2/2000
  10. //
  11. // Copyright <cp> 1999-2000 Microsoft Corporation. All Rights Reserved.
  12. //
  13. //-----------------------------------------------------------------------------
  14. #pragma once
  15. //-----------------------------------------------------------------------------
  16. //
  17. // @class CTicket | This class abstracts out a number of common ticket
  18. // operations.
  19. //
  20. //-----------------------------------------------------------------------------
  21. class CTicket
  22. {
  23. // @access Protected members.
  24. protected:
  25. // @cmember Has this instance been initialized?
  26. bool m_bInitialized;
  27. // @cmember Ticket object used for satisfying most method calls.
  28. CComPtr<IPassportTicket2> m_piTicket;
  29. // @cmember Base handler object.
  30. CPassportHandlerBase* m_pHandler;
  31. // @cmember Create a new IPassportTicket object and save it in
  32. // <md CTicket::m_piTicket>.
  33. void CreateTicketObject(void);
  34. // @access Public members.
  35. public:
  36. //
  37. // Note, two-phase construction. Constructor followed
  38. // by PutTicket.
  39. //
  40. // @cmember Default constructor.
  41. CTicket();
  42. // @cmember Default destructor.
  43. ~CTicket();
  44. //
  45. // Pass in profile cookie.
  46. //
  47. // @cmember Initialize this object with a ticket cookie string.
  48. void PutTicket(LPCWSTR szProfile);
  49. //
  50. // Ticket object initialized and profile valid?
  51. //
  52. // @cmember Has this instance been initialized?
  53. bool IsInitialized(void);
  54. // @cmember Does this instance contain a valid ticket?
  55. bool IsValid(void);
  56. //
  57. // Ticket accessor methods.
  58. //
  59. // @cmember Determines if the current user is authenticated based on the
  60. // time window and force signin parameters passed in.
  61. bool IsAuthenticated(ULONG ulTimeWindow,
  62. bool bForceSignin
  63. );
  64. // @cmember Return any network error stored within the ticket.
  65. ULONG GetError(void);
  66. // @cmember Return the time that this ticket was created.
  67. LONG TicketTime(void);
  68. // @cmember Return the time that the user last typed their password.
  69. LONG SignInTime(void);
  70. // @cmember Return the time that the user last typed their PIN.
  71. LONG PinTime(void);
  72. // @cmember Return arbitrary property
  73. HRESULT GetPropertyValue(PWSTR pcszProperty, VARIANT *pvResult);
  74. // @cmember Return the high portion of the user's member id.
  75. ULONG MemberIdHigh(void);
  76. // @cmember Return the low portion of the user's member id.
  77. ULONG MemberIdLow(void);
  78. // @cmember Did the user select 'Save My Password'?
  79. bool HasSavedPassword(void);
  80. //
  81. // Ticket cookie manipulation functions.
  82. //
  83. // @cmember Create a 2.0 ticket cookie string
  84. // using only information passed in.
  85. static void Make2(ULONG ulMemberIdLow,
  86. ULONG ulMemberIdHigh,
  87. LONG lSignInTime,
  88. LONG lTicketTime,
  89. bool bSavePassword,
  90. ULONG ulError,
  91. ULONG ulSiteId,
  92. USHORT nKeyVersion,
  93. LONG nSkew,
  94. ULONG ulSecureLevel,
  95. LONG PassportFlags,
  96. LONG pinTime,
  97. CStringW& cszTicketCookie
  98. );
  99. // @cmember Create a ticket cookie string using some information passed in,
  100. // as well as the internal ticket object.
  101. HRESULT Copy2(ULONG ulSiteId,
  102. USHORT nKeyVersion,
  103. LONG nSkew,
  104. ULONG ulError,
  105. ULONG ulSecureLevel,
  106. LONG PassportFlags,
  107. CStringW& cszTicketCookie
  108. );
  109. // versions for 2.0. of Make and secure. Substitute security level
  110. // for bSecure
  111. // @cmember Create a ticket cookie string using only information passed in.
  112. static void Make(ULONG ulMemberIdLow,
  113. ULONG ulMemberIdHigh,
  114. LONG lSignInTime,
  115. LONG lTicketTime,
  116. bool bSavePassword,
  117. ULONG ulError,
  118. ULONG ulSiteId,
  119. USHORT nKeyVersion,
  120. LONG nSkew,
  121. bool bSecure,
  122. CStringW& cszTicketCookie
  123. );
  124. // @cmember Create a ticket cookie string using some information passed in,
  125. // as well as the internal ticket object.
  126. HRESULT Copy(ULONG ulSiteId,
  127. USHORT nKeyVersion,
  128. LONG nSkew,
  129. ULONG ulError,
  130. bool bSecure,
  131. CStringW& cszTicketCookie
  132. );
  133. // @cmember Place the ticket cookie string into a Set-Cookie header in
  134. // the current response.
  135. static HRESULT Set(LPCWSTR szTicketCookie,
  136. bool bPersist);
  137. // @cmember Place a ticket cookie expiration string into a Set-Cookie
  138. // header in the current response.
  139. static HRESULT Expire();
  140. };
  141. // EOF