Pkcs12Entry.cs 1.7 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. public Asn1Encodable GetBagAttribute(
  25. DerObjectIdentifier oid)
  26. {
  27. return (Asn1Encodable)this.attributes[oid.Id];
  28. }
  29. public Asn1Encodable GetBagAttribute(
  30. string oid)
  31. {
  32. return (Asn1Encodable)this.attributes[oid];
  33. }
  34. public IEnumerator GetBagAttributeKeys()
  35. {
  36. return this.attributes.Keys.GetEnumerator();
  37. }
  38. public Asn1Encodable this[
  39. DerObjectIdentifier oid]
  40. {
  41. get { return (Asn1Encodable) this.attributes[oid.Id]; }
  42. }
  43. public Asn1Encodable this[
  44. string oid]
  45. {
  46. get { return (Asn1Encodable) this.attributes[oid]; }
  47. }
  48. public IEnumerable BagAttributeKeys
  49. {
  50. get { return new EnumerableProxy(this.attributes.Keys); }
  51. }
  52. }
  53. }
  54. #pragma warning restore
  55. #endif