PkixPolicyNode.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using System.Text;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  7. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
  8. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Pkix
  9. {
  10. /// <summary>
  11. /// Summary description for PkixPolicyNode.
  12. /// </summary>
  13. public class PkixPolicyNode
  14. // : IPolicyNode
  15. {
  16. protected IList mChildren;
  17. protected int mDepth;
  18. protected ISet mExpectedPolicies;
  19. protected PkixPolicyNode mParent;
  20. protected ISet mPolicyQualifiers;
  21. protected string mValidPolicy;
  22. protected bool mCritical;
  23. public virtual int Depth
  24. {
  25. get { return this.mDepth; }
  26. }
  27. public virtual IEnumerable Children
  28. {
  29. get { return new EnumerableProxy(mChildren); }
  30. }
  31. public virtual bool IsCritical
  32. {
  33. get { return this.mCritical; }
  34. set { this.mCritical = value; }
  35. }
  36. public virtual ISet PolicyQualifiers
  37. {
  38. get { return new HashSet(this.mPolicyQualifiers); }
  39. }
  40. public virtual string ValidPolicy
  41. {
  42. get { return this.mValidPolicy; }
  43. }
  44. public virtual bool HasChildren
  45. {
  46. get { return mChildren.Count != 0; }
  47. }
  48. public virtual ISet ExpectedPolicies
  49. {
  50. get { return new HashSet(this.mExpectedPolicies); }
  51. set { this.mExpectedPolicies = new HashSet(value); }
  52. }
  53. public virtual PkixPolicyNode Parent
  54. {
  55. get { return this.mParent; }
  56. set { this.mParent = value; }
  57. }
  58. /// Constructors
  59. public PkixPolicyNode(
  60. IList children,
  61. int depth,
  62. ISet expectedPolicies,
  63. PkixPolicyNode parent,
  64. ISet policyQualifiers,
  65. string validPolicy,
  66. bool critical)
  67. {
  68. if (children == null)
  69. {
  70. this.mChildren = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList();
  71. }
  72. else
  73. {
  74. this.mChildren = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(children);
  75. }
  76. this.mDepth = depth;
  77. this.mExpectedPolicies = expectedPolicies;
  78. this.mParent = parent;
  79. this.mPolicyQualifiers = policyQualifiers;
  80. this.mValidPolicy = validPolicy;
  81. this.mCritical = critical;
  82. }
  83. public virtual void AddChild(
  84. PkixPolicyNode child)
  85. {
  86. child.Parent = this;
  87. mChildren.Add(child);
  88. }
  89. public virtual void RemoveChild(
  90. PkixPolicyNode child)
  91. {
  92. mChildren.Remove(child);
  93. }
  94. public override string ToString()
  95. {
  96. return ToString("");
  97. }
  98. public virtual string ToString(
  99. string indent)
  100. {
  101. StringBuilder buf = new StringBuilder();
  102. buf.Append(indent);
  103. buf.Append(mValidPolicy);
  104. buf.Append(" {");
  105. buf.Append(BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.NewLine);
  106. foreach (PkixPolicyNode child in mChildren)
  107. {
  108. buf.Append(child.ToString(indent + " "));
  109. }
  110. buf.Append(indent);
  111. buf.Append("}");
  112. buf.Append(BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.NewLine);
  113. return buf.ToString();
  114. }
  115. public virtual object Clone()
  116. {
  117. return Copy();
  118. }
  119. public virtual PkixPolicyNode Copy()
  120. {
  121. PkixPolicyNode node = new PkixPolicyNode(
  122. BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(),
  123. mDepth,
  124. new HashSet(mExpectedPolicies),
  125. null,
  126. new HashSet(mPolicyQualifiers),
  127. mValidPolicy,
  128. mCritical);
  129. foreach (PkixPolicyNode child in mChildren)
  130. {
  131. PkixPolicyNode copy = child.Copy();
  132. copy.Parent = node;
  133. node.AddChild(copy);
  134. }
  135. return node;
  136. }
  137. }
  138. }
  139. #pragma warning restore
  140. #endif