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.

159 lines
4.7 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // @doc
  4. //
  5. // @module CSecureTicket.h | Declaration of the CSecureTicket 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. class CProfileSchema;
  16. //-----------------------------------------------------------------------------
  17. //
  18. // @class CSecureTicket | This class abstracts out a number of common
  19. // secure ticket operations.
  20. //
  21. //-----------------------------------------------------------------------------
  22. class CSecureTicket
  23. {
  24. // @access Protected members.
  25. protected:
  26. // @cmember Has this instance been initialized?
  27. bool m_bInitialized;
  28. // @cmember Holds the raw ticket cookie passed in via
  29. // <mf CSecureTicket::PutTicket>.
  30. CComBSTR m_cbstrRaw;
  31. // holds the unencrypted ticket
  32. CComBSTR m_cbstrUnencrypted;
  33. // passport siteid
  34. LONG m_lPassportSiteId;
  35. // @cmember Base handler.
  36. CPassportHandlerBase* m_pHandler;
  37. // interface to encrypt/decrypt funcs
  38. CComPtr<ILoginServer> m_piLoginServer;
  39. CComPtr<INetworkServerCrypt> m_piNetworkServerCrypt;
  40. // gets the unencrypted ticket
  41. void GetUnencryptedTicket();
  42. // encrypt back
  43. void EncryptUnencryptedTicket();
  44. // schema for the secure ticket
  45. CAutoPtr<CProfileSchema> m_piProfileSchema;
  46. // field positions
  47. CAutoVectorPtr<UINT> m_rgPositions;
  48. CAutoVectorPtr<UINT> m_rgBitPositions;
  49. // enum for field position index
  50. enum {k_MemberIdLow = 0, k_MemberIdHigh, k_Pwd,
  51. k_Version, k_Time, k_Flags};
  52. // ticket version
  53. static const long k_lCurrentVersion = 1;
  54. // @access Public members.
  55. public:
  56. // @cmember Default constructor.
  57. CSecureTicket();
  58. // @cmember Default destructor.
  59. ~CSecureTicket();
  60. // @cmember Initialize this object using the existing MSPSec cookie.
  61. void PutSecureTicket(LPCWSTR szSecureTicketCookie);
  62. // @member Get the secure ticket cookie.
  63. void GetSecureTicket(CStringW& cszSecureTicket);
  64. // @cmember Has this object been initialized yet?
  65. bool IsInitialized(void);
  66. // @cmember Does this object contain a valid secure ticket?
  67. bool IsValid(void);
  68. // @cmember Create a secure ticket cookie string using only information
  69. // passed in.
  70. static void Make(ULONG ulMemberIdLow,
  71. ULONG ulMemberIdHigh,
  72. LPCWSTR szPassword,
  73. ULONG ulDomainSiteId,
  74. USHORT nKeyVersion,
  75. CStringW& cszSecureTicketCookie
  76. );
  77. //
  78. // @cmember Create a secure ticket with the new schema
  79. // Note that this is not a static member. The caller can still change
  80. // the ticket if necessary.
  81. // Also key version and domain ID params are gone. These are always
  82. // the same for the DA.
  83. //
  84. void Make2(ULONG ulMemberIdLow,
  85. ULONG ulMemberIdHigh,
  86. LPCWSTR szPassword,
  87. LONG lTicketTime = 0,
  88. LONG lFlags = 0,
  89. LONG lVersion = k_lCurrentVersion
  90. );
  91. // @cmember Check the member id high/low and password passed in against
  92. // the current secure ticket.
  93. bool CheckPassword(ULONG ulMemberIdLow,
  94. ULONG ulMemberIdHigh,
  95. LPCWSTR cwszPassword
  96. );
  97. // @cmember Check the member id high/low passed in against the current
  98. // secure ticket.
  99. bool CheckMemberId(ULONG ulMemberIdLow,
  100. ULONG ulMemberIdHigh
  101. );
  102. // @cmember Check the member id high/low as well as ticket time passed in against the current
  103. // secure ticket.
  104. bool CheckTicketIntegrity(ULONG ulMemberIdLow,
  105. ULONG ulMemberIdHigh,
  106. time_t SignInTime
  107. );
  108. // @cmember Set the secure cookie.
  109. static HRESULT Set(LPCWSTR szSecureTicketCookie,
  110. bool bPersist);
  111. // @cmember Expire the secure cookie.
  112. static HRESULT Expire(void);
  113. // get secure ticket flags
  114. LONG GetFlags();
  115. // set secure ticket flags
  116. void SetFlags(LONG lFlags);
  117. // get/set ticket time
  118. time_t GetTicketTime();
  119. void SetTicketTime(time_t);
  120. // get PUID
  121. DWORD GetPUIDLow();
  122. LONG GetPUIDHigh();
  123. // known secure ticket flags
  124. static const LONG g_fPinEntered = 1;
  125. };