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.

163 lines
4.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // EAPSession.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file declares the class EAPSession.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 01/15/1998 Original version.
  16. // 05/08/1998 Convert to new EAP interface.
  17. // 08/27/1998 Use new EAPFSM class.
  18. // 10/13/1998 Add maxPacketLength property.
  19. // 11/13/1998 Add event log handles.
  20. // 05/20/1999 Identity is now a Unicode string.
  21. //
  22. ///////////////////////////////////////////////////////////////////////////////
  23. #ifndef _EAPSESSION_H_
  24. #define _EAPSESSION_H_
  25. #if _MSC_VER >= 1000
  26. #pragma once
  27. #endif
  28. #include <nocopy.h>
  29. #include <raseapif.h>
  30. #include <iastlutl.h>
  31. #include <vector>
  32. using namespace IASTL;
  33. #include <eapfsm.h>
  34. // Forward references.
  35. class EAPType;
  36. ///////////////////////////////////////////////////////////////////////////////
  37. //
  38. // CLASS
  39. //
  40. // EAPStruct<T>
  41. //
  42. // DESCRIPTION
  43. //
  44. // Wraps a raseapif struct to handle initialization.
  45. //
  46. ///////////////////////////////////////////////////////////////////////////////
  47. template <class T>
  48. class EAPStruct : public T
  49. {
  50. public:
  51. EAPStruct() throw ()
  52. { clear(); }
  53. void clear() throw ()
  54. {
  55. memset(this, 0, sizeof(T));
  56. dwSizeInBytes = sizeof(T);
  57. }
  58. };
  59. typedef EAPStruct<PPP_EAP_INPUT> EAPInput;
  60. typedef EAPStruct<PPP_EAP_OUTPUT> EAPOutput;
  61. ///////////////////////////////////////////////////////////////////////////////
  62. //
  63. // CLASS
  64. //
  65. // EAPSession
  66. //
  67. // DESCRIPTION
  68. //
  69. // This class encapsulates the state of an ongoing EAP session.
  70. //
  71. ///////////////////////////////////////////////////////////////////////////////
  72. class EAPSession
  73. : NonCopyable
  74. {
  75. public:
  76. EAPSession(
  77. const IASAttribute& accountName,
  78. std::vector<EAPType*>& eapTypes
  79. );
  80. ~EAPSession() throw ();
  81. // Returns the ID for this session.
  82. DWORD getID() const throw ()
  83. { return id; }
  84. PCWSTR getAccountName() const throw ()
  85. { return account->Value.String.pszWide; }
  86. // Begin a new session.
  87. IASREQUESTSTATUS begin(
  88. IASRequest& request,
  89. PPPP_EAP_PACKET recvPacket
  90. );
  91. // Continue an existent session.
  92. IASREQUESTSTATUS process(
  93. IASRequest& request,
  94. PPPP_EAP_PACKET recvPacket
  95. );
  96. static HRESULT initialize() throw ();
  97. static void finalize() throw ();
  98. protected:
  99. // Performs the last action returned by the EAP DLL. May be called multiple
  100. // times per action due to retransmissions.
  101. IASREQUESTSTATUS doAction(IASRequest& request);
  102. void clearType() throw ();
  103. void setType(EAPType* newType);
  104. //////////
  105. // Constant properties of a session.
  106. //////////
  107. const DWORD id; // Unique session ID.
  108. IASAttributeVector all;
  109. EAPInput eapInput;
  110. EAPType* currentType; // current EAP type being used.
  111. const IASAttribute account; // NT4-Account-Name of the user.
  112. const IASAttribute state; // State attribute.
  113. //////////
  114. // Current state of a session.
  115. //////////
  116. EAPFSM fsm; // FSM governing the session.
  117. DWORD maxPacketLength; // Max. length of the send packet.
  118. IASAttributeVector profile; // Authorization profile.
  119. IASAttributeVector config; // Configuration for the various EAP types.
  120. PVOID workBuffer; // EAP DLL's context buffer.
  121. EAPOutput eapOutput; // Last output from the EAP DLL.
  122. PPPP_EAP_PACKET sendPacket; // Last packet sent.
  123. // Next available session ID.
  124. static LONG theNextID;
  125. // Initialization refCount.
  126. static LONG theRefCount;
  127. // Session-Timeout for non-interactive sessions.
  128. static IASAttribute theNormalTimeout;
  129. // Session-Timeout for interactive sessions.
  130. static IASAttribute theInteractiveTimeout;
  131. // IAS event log handle;
  132. static HANDLE theIASEventLog;
  133. // RAS event log handle;
  134. static HANDLE theRASEventLog;
  135. };
  136. #endif // _EAPSESSION_H_