AttributeTable.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509
  8. {
  9. public class AttributeTable
  10. {
  11. private readonly IDictionary attributes;
  12. public AttributeTable(
  13. IDictionary attrs)
  14. {
  15. this.attributes = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateHashtable(attrs);
  16. }
  17. #if !(SILVERLIGHT || PORTABLE || NETFX_CORE)
  18. [Obsolete]
  19. public AttributeTable(
  20. Hashtable attrs)
  21. {
  22. this.attributes = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateHashtable(attrs);
  23. }
  24. #endif
  25. public AttributeTable(
  26. Asn1EncodableVector v)
  27. {
  28. this.attributes = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateHashtable(v.Count);
  29. for (int i = 0; i != v.Count; i++)
  30. {
  31. AttributeX509 a = AttributeX509.GetInstance(v[i]);
  32. attributes.Add(a.AttrType, a);
  33. }
  34. }
  35. public AttributeTable(
  36. Asn1Set s)
  37. {
  38. this.attributes = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateHashtable(s.Count);
  39. for (int i = 0; i != s.Count; i++)
  40. {
  41. AttributeX509 a = AttributeX509.GetInstance(s[i]);
  42. attributes.Add(a.AttrType, a);
  43. }
  44. }
  45. public AttributeX509 Get(
  46. DerObjectIdentifier oid)
  47. {
  48. return (AttributeX509) attributes[oid];
  49. }
  50. #if !(SILVERLIGHT || PORTABLE || NETFX_CORE)
  51. public Hashtable ToHashtable()
  52. {
  53. return new Hashtable(attributes);
  54. }
  55. #endif
  56. public IDictionary ToDictionary()
  57. {
  58. return BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateHashtable(attributes);
  59. }
  60. }
  61. }
  62. #pragma warning restore
  63. #endif