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.

172 lines
4.5 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: procresponse.cpp
  4. //
  5. // Synopsis: Implementation of CProcResponse class methods
  6. //
  7. //
  8. // History: 10/20/97 MKarki Created
  9. //
  10. // Copyright (C) Microsoft Corporation
  11. // All rights reserved.
  12. //
  13. //----------------------------------------------------------------
  14. #include "radcommon.h"
  15. #include "procresponse.h"
  16. //++--------------------------------------------------------------
  17. //
  18. // Function: CProcResponse
  19. //
  20. // Synopsis: This is CProcResponse class constructor
  21. //
  22. // Arguments: NONE
  23. //
  24. // Returns: NONE
  25. //
  26. // History: MKarki Created 10/20/97
  27. //
  28. //----------------------------------------------------------------
  29. CProcResponse::CProcResponse()
  30. : m_pCPreValidator (NULL),
  31. m_pCPacketSender (NULL)
  32. {
  33. } // end of CProcResponse class constructor
  34. //++--------------------------------------------------------------
  35. //
  36. // Function: CProcResponse
  37. //
  38. // Synopsis: This is CProcResponse class destructor
  39. //
  40. // Arguments: NONE
  41. //
  42. // Returns: NONE
  43. //
  44. //
  45. // History: MKarki Created 10/20/97
  46. //
  47. //----------------------------------------------------------------
  48. CProcResponse::~CProcResponse()
  49. {
  50. } // end of CProcResponse class destructor
  51. //++--------------------------------------------------------------
  52. //
  53. // Function: Init
  54. //
  55. // Synopsis: This is CProcResponse class public
  56. // initialization method
  57. //
  58. // Arguments: NONE
  59. //
  60. // Returns: status
  61. //
  62. // History: MKarki Created 10/20/97
  63. //
  64. //----------------------------------------------------------------
  65. BOOL
  66. CProcResponse::Init(
  67. CPreValidator *pCPreValidator,
  68. CPacketSender *pCPacketSender
  69. )
  70. {
  71. _ASSERT (pCPreValidator && pCPacketSender);
  72. m_pCPreValidator = pCPreValidator;
  73. m_pCPacketSender = pCPacketSender;
  74. return (TRUE);
  75. } // end of CProcResponse::Init method
  76. //++--------------------------------------------------------------
  77. //
  78. // Function: ProcessOutPacket
  79. //
  80. // Synopsis: This is CProcResponse class public method
  81. // which carries out the following RADIUS outbound
  82. // packet types:
  83. //
  84. // ACCESS REJECT
  85. // ACCESS CHALLENGE
  86. // ACCESS ACCEPT
  87. // ACCOUNTING RESPONSE
  88. //
  89. //
  90. // Arguments:
  91. // [in] CPacketRadius*
  92. //
  93. // Returns: HRESULT - status
  94. //
  95. //
  96. // History: MKarki Created 10/20/97
  97. //
  98. // Called By: CPreProcessor::StartOutProcessing method
  99. //
  100. //----------------------------------------------------------------
  101. HRESULT
  102. CProcResponse::ProcessOutPacket (
  103. CPacketRadius *pCPacketRadius
  104. )
  105. {
  106. BOOL bStatus = FALSE;
  107. HRESULT hr = S_OK;
  108. BYTE RequestAuthenticator[AUTHENTICATOR_SIZE];
  109. BYTE ResponseAuthenticator[AUTHENTICATOR_SIZE];
  110. __try
  111. {
  112. if (pCPacketRadius->IsOutSignaturePresent ())
  113. {
  114. //
  115. // generate the signature value
  116. //
  117. BYTE SignatureValue[SIGNATURE_SIZE];
  118. DWORD dwSigSize = SIGNATURE_SIZE;
  119. hr = pCPacketRadius->GenerateOutSignature (
  120. SignatureValue,
  121. &dwSigSize
  122. );
  123. if (FAILED (hr)) { __leave; }
  124. //
  125. // set the signature value in attribute already set up
  126. // in the out-bound RADIUS packet
  127. //
  128. hr = pCPacketRadius->SetOutSignature (SignatureValue);
  129. if (FAILED (hr)) {__leave; }
  130. IASTracePrintf ("Message Authenticator Attribute set in out UDP buffer");
  131. }
  132. // generate the response authenticator here
  133. // not specifying an argument means
  134. // use the value from the request authenticatior
  135. //
  136. bStatus = pCPacketRadius->GenerateOutAuthenticator ();
  137. if (FALSE == bStatus)
  138. {
  139. hr = E_FAIL;
  140. __leave;
  141. }
  142. //
  143. // TODO - if validation is required call the validator
  144. // else send the packet on its way
  145. //
  146. hr = m_pCPacketSender->SendPacket (pCPacketRadius);
  147. if (FALSE == bStatus) { __leave; }
  148. }
  149. __finally
  150. {
  151. }
  152. return (hr);
  153. } // end of CProcResponse::ProcessOutPacket method