Pkcs12Entry.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.Collections;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Pkcs
  8. {
  9. public abstract class Pkcs12Entry
  10. {
  11. private readonly IDictionary attributes;
  12. protected internal Pkcs12Entry(
  13. IDictionary attributes)
  14. {
  15. this.attributes = attributes;
  16. foreach (DictionaryEntry entry in attributes)
  17. {
  18. if (!(entry.Key is string))
  19. throw new ArgumentException("Attribute keys must be of type: " + typeof(string).FullName, "attributes");
  20. if (!(entry.Value is Asn1Encodable))
  21. throw new ArgumentException("Attribute values must be of type: " + typeof(Asn1Encodable).FullName, "attributes");
  22. }
  23. }
  24. [Obsolete("Use 'object[index]' syntax instead")]
  25. public Asn1Encodable GetBagAttribute(
  26. DerObjectIdentifier oid)
  27. {
  28. return (Asn1Encodable)this.attributes[oid.Id];
  29. }
  30. [Obsolete("Use 'object[index]' syntax instead")]
  31. public Asn1Encodable GetBagAttribute(
  32. string oid)
  33. {
  34. return (Asn1Encodable)this.attributes[oid];
  35. }
  36. [Obsolete("Use 'BagAttributeKeys' property")]
  37. public IEnumerator GetBagAttributeKeys()
  38. {
  39. return this.attributes.Keys.GetEnumerator();
  40. }
  41. public Asn1Encodable this[
  42. DerObjectIdentifier oid]
  43. {
  44. get { return (Asn1Encodable) this.attributes[oid.Id]; }
  45. }
  46. public Asn1Encodable this[
  47. string oid]
  48. {
  49. get { return (Asn1Encodable) this.attributes[oid]; }
  50. }
  51. public IEnumerable BagAttributeKeys
  52. {
  53. get { return new EnumerableProxy(this.attributes.Keys); }
  54. }
  55. }
  56. }
  57. #pragma warning restore
  58. #endif