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.

202 lines
4.0 KiB

  1. //=============================================================================
  2. //
  3. // MODULE: ASN1PNameSeq.cxx
  4. //
  5. // Description:
  6. //
  7. // Implementation of principal name sequence parsing logic
  8. //
  9. // Modification History
  10. //
  11. // Mark Pustilnik Date: 06/13/02 - created
  12. //
  13. //=============================================================================
  14. #include "ASN1Parser.hxx"
  15. DWORD
  16. ASN1ParserPrincipalNameSequence::DisplayCollectedValues(
  17. IN ASN1FRAME * Frame,
  18. IN ULONG Length,
  19. IN ULPBYTE Address
  20. )
  21. {
  22. DWORD dw;
  23. ASN1VALUE Value;
  24. ULPBYTE s_address = NULL;
  25. ULONG s_length = 0;
  26. for ( ULONG i = 0; i < QueryCollectedCount(); i++ )
  27. {
  28. ASN1VALUE * String = QueryCollectedValue(i);
  29. if ( String->ut == utGeneralString )
  30. {
  31. ULPBYTE address = new BYTE[s_length + ( i ? 1 : 0 ) + String->string.l ];
  32. if ( address == NULL )
  33. {
  34. dw = ERROR_NOT_ENOUGH_MEMORY;
  35. goto Cleanup;
  36. }
  37. if ( i > 0 )
  38. {
  39. RtlCopyMemory(
  40. address,
  41. s_address,
  42. s_length
  43. );
  44. address[s_length++] = '/';
  45. }
  46. RtlCopyMemory(
  47. &address[s_length],
  48. String->string.s,
  49. String->string.l
  50. );
  51. delete [] s_address;
  52. s_address = address;
  53. s_length += String->string.l;
  54. }
  55. else
  56. {
  57. //
  58. // TODO: add an assert
  59. //
  60. dw = ERROR_INTERNAL_ERROR;
  61. goto Cleanup;
  62. }
  63. }
  64. Value.Length = Length;
  65. Value.Address = Address;
  66. Value.ut = utGeneralString;
  67. Value.Allocated = TRUE;
  68. Value.string.l = s_length;
  69. Value.string.s = s_address;
  70. s_address = NULL;
  71. if ( m_hPropertySummary )
  72. {
  73. dw = Display(
  74. Frame,
  75. &Value,
  76. m_hPropertySummary,
  77. 0
  78. );
  79. if ( dw != ERROR_SUCCESS )
  80. {
  81. goto Cleanup;
  82. }
  83. }
  84. if ( QueryValueCollector())
  85. {
  86. dw = QueryValueCollector()->CollectValue( &Value );
  87. if ( dw != ERROR_SUCCESS )
  88. {
  89. goto Cleanup;
  90. }
  91. }
  92. Cleanup:
  93. delete [] s_address;
  94. return dw;
  95. };
  96. DWORD
  97. ASN1ParserPrincipalName::DisplayCollectedValues(
  98. IN ASN1FRAME * Frame,
  99. IN ULONG Length,
  100. IN ULPBYTE Address
  101. )
  102. {
  103. DWORD dw;
  104. ASN1VALUE * NameType;
  105. ASN1VALUE * NameString;
  106. if ( QueryCollectedCount() != 2 )
  107. {
  108. dw = ERROR_INTERNAL_ERROR;
  109. goto Cleanup;
  110. }
  111. NameType = QueryCollectedValue( 0 );
  112. NameString = QueryCollectedValue( 1 );
  113. if ( NameType->ut != utInteger )
  114. {
  115. dw = ERROR_INTERNAL_ERROR;
  116. goto Cleanup;
  117. }
  118. if ( NameString->ut != utGeneralString )
  119. {
  120. dw = ERROR_INTERNAL_ERROR;
  121. goto Cleanup;
  122. }
  123. //
  124. // Display the top-level property
  125. //
  126. dw = Display(
  127. Frame,
  128. NameString,
  129. m_hPropertyTopLevel,
  130. 0
  131. );
  132. if ( dw != ERROR_SUCCESS )
  133. {
  134. goto Cleanup;
  135. }
  136. //
  137. // Done displaying the top-level property; indent the rest to the right
  138. //
  139. Frame->Level += 1;
  140. dw = Display(
  141. Frame,
  142. NameType,
  143. PROP( PrincipalName_type ),
  144. 0
  145. );
  146. if ( dw == ERROR_SUCCESS )
  147. {
  148. dw = Display(
  149. Frame,
  150. NameString,
  151. PROP( PrincipalName_string ),
  152. 0
  153. );
  154. }
  155. //
  156. // Do not forget to undo the indentation
  157. //
  158. Frame->Level -= 1;
  159. if ( dw != ERROR_SUCCESS )
  160. {
  161. goto Cleanup;
  162. }
  163. Cleanup:
  164. return dw;
  165. }