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.

164 lines
4.5 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: valattrib.cpp
  4. //
  5. // Synopsis: Implementation of CValAttributes class methods
  6. // The class is responsible for taking the attributes
  7. // in a RADIUS packet and validating their type and
  8. // value
  9. //
  10. // History: 11/22/97 MKarki Created
  11. //
  12. // Copyright (C) Microsoft Corporation
  13. // All rights reserved.
  14. //
  15. //----------------------------------------------------------------
  16. #include "radcommon.h"
  17. #include "valattrib.h"
  18. //+++-------------------------------------------------------------
  19. //
  20. // Function: CValAttributes
  21. //
  22. // Synopsis: This is the constructor of the CValAttributes
  23. // class
  24. //
  25. // Arguments: NONE
  26. //
  27. // Returns: NONE
  28. //
  29. // History: MKarki Created 11/22/97
  30. //
  31. //----------------------------------------------------------------
  32. CValAttributes::CValAttributes(
  33. VOID
  34. )
  35. :m_pCDictionary (NULL)
  36. {
  37. } // end of CValAttributes constructor
  38. //+++-------------------------------------------------------------
  39. //
  40. // Function: ~CValAttributes
  41. //
  42. // Synopsis: This is the destructor of the CValAttributes
  43. // class
  44. //
  45. // Arguments: NONE
  46. //
  47. // Returns: NONE
  48. //
  49. // History: MKarki Created 11/22/97
  50. //
  51. //----------------------------------------------------------------
  52. CValAttributes::~CValAttributes(
  53. VOID
  54. )
  55. {
  56. } // end of CValAttributes destructor
  57. //+++-------------------------------------------------------------
  58. //
  59. // Function: Init
  60. //
  61. // Synopsis: This is the CValAttributes public method used
  62. // to intialize the class object
  63. //
  64. // Arguments:
  65. // [in] CDictionary*
  66. //
  67. // Returns: BOOL - status
  68. //
  69. // History: MKarki Created 11/22/97
  70. //
  71. //----------------------------------------------------------------
  72. BOOL CValAttributes::Init(
  73. CDictionary *pCDictionary,
  74. CReportEvent *pCReportEvent
  75. )
  76. {
  77. BOOL bRetVal = FALSE;
  78. _ASSERT (pCDictionary && pCReportEvent);
  79. m_pCDictionary = pCDictionary;
  80. m_pCReportEvent = pCReportEvent;
  81. return (TRUE);
  82. } // end of CValAttributes::Init method
  83. //+++-------------------------------------------------------------
  84. //
  85. // Function: Validate
  86. //
  87. // Synopsis: This is the CValAttributes public method used
  88. // to validate the packet attributes
  89. //
  90. // Arguments:
  91. // [in] CPacketRadius*
  92. //
  93. // Returns: HRESULT - status
  94. //
  95. // History: MKarki Created 11/22/97
  96. //
  97. //----------------------------------------------------------------
  98. HRESULT
  99. CValAttributes::Validate (
  100. CPacketRadius *pCPacketRadius
  101. )
  102. {
  103. // We only care about Access-Requests.
  104. if (pCPacketRadius->GetInCode() == ACCESS_REQUEST)
  105. {
  106. // We're looking for the Signature and EAP-Message attributes.
  107. BOOL hasSignature = FALSE, hasEapMessage = FALSE;
  108. // Loop through the attributes.
  109. PATTRIBUTEPOSITION p, end;
  110. p = pCPacketRadius->GetInAttributes();
  111. end = p + pCPacketRadius->GetInRadiusAttributeCount();
  112. for ( ; p != end; ++p)
  113. {
  114. if (p->pAttribute->dwId == RADIUS_ATTRIBUTE_SIGNATURE)
  115. {
  116. hasSignature = TRUE;
  117. }
  118. else if (p->pAttribute->dwId == RADIUS_ATTRIBUTE_EAP_MESSAGE)
  119. {
  120. hasEapMessage = TRUE;
  121. }
  122. }
  123. // If EAP-Message is present, then Signature must be as well.
  124. if (hasEapMessage && !hasSignature)
  125. {
  126. IASTraceString("Message Authenticator must accompany EAP-Message.");
  127. // Generate audit event.
  128. PCWSTR strings[] = { pCPacketRadius->GetClientName() };
  129. IASReportEvent(
  130. RADIUS_E_NO_SIGNATURE_WITH_EAP_MESSAGE,
  131. 1,
  132. 0,
  133. strings,
  134. NULL
  135. );
  136. m_pCReportEvent->Process (
  137. RADIUS_MALFORMED_PACKET,
  138. pCPacketRadius->GetInCode(),
  139. pCPacketRadius->GetInLength(),
  140. pCPacketRadius->GetInAddress(),
  141. NULL,
  142. pCPacketRadius->GetInPacket()
  143. );
  144. return RADIUS_E_ERRORS_OCCURRED;
  145. }
  146. }
  147. return S_OK;
  148. }