AttributeTable.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System.Collections.Generic;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509
  6. {
  7. public class AttributeTable
  8. {
  9. private readonly IDictionary<DerObjectIdentifier, AttributeX509> m_attributes;
  10. public AttributeTable(IDictionary<DerObjectIdentifier, AttributeX509> attrs)
  11. {
  12. m_attributes = new Dictionary<DerObjectIdentifier, AttributeX509>(attrs);
  13. }
  14. public AttributeTable(Asn1EncodableVector v)
  15. {
  16. m_attributes = new Dictionary<DerObjectIdentifier, AttributeX509>(v.Count);
  17. for (int i = 0; i != v.Count; i++)
  18. {
  19. AttributeX509 a = AttributeX509.GetInstance(v[i]);
  20. m_attributes.Add(a.AttrType, a);
  21. }
  22. }
  23. public AttributeTable(Asn1Set s)
  24. {
  25. m_attributes = new Dictionary<DerObjectIdentifier, AttributeX509>(s.Count);
  26. for (int i = 0; i != s.Count; i++)
  27. {
  28. AttributeX509 a = AttributeX509.GetInstance(s[i]);
  29. m_attributes.Add(a.AttrType, a);
  30. }
  31. }
  32. public AttributeX509 Get(DerObjectIdentifier oid)
  33. {
  34. return CollectionUtilities.GetValueOrNull(m_attributes, oid);
  35. }
  36. public IDictionary<DerObjectIdentifier, AttributeX509> ToDictionary()
  37. {
  38. return new Dictionary<DerObjectIdentifier, AttributeX509>(m_attributes);
  39. }
  40. }
  41. }
  42. #pragma warning restore
  43. #endif