Attributes.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms
  5. {
  6. public class Attributes
  7. : Asn1Encodable
  8. {
  9. private readonly Asn1Set attributes;
  10. private Attributes(Asn1Set attributes)
  11. {
  12. this.attributes = attributes;
  13. }
  14. public Attributes(Asn1EncodableVector v)
  15. {
  16. attributes = new BerSet(v);
  17. }
  18. public static Attributes GetInstance(object obj)
  19. {
  20. if (obj is Attributes)
  21. return (Attributes)obj;
  22. if (obj != null)
  23. return new Attributes(Asn1Set.GetInstance(obj));
  24. return null;
  25. }
  26. public virtual Attribute[] GetAttributes()
  27. {
  28. Attribute[] rv = new Attribute[attributes.Count];
  29. for (int i = 0; i != rv.Length; i++)
  30. {
  31. rv[i] = Attribute.GetInstance(attributes[i]);
  32. }
  33. return rv;
  34. }
  35. /**
  36. * <pre>
  37. * Attributes ::=
  38. * SET SIZE(1..MAX) OF Attribute -- according to RFC 5652
  39. * </pre>
  40. * @return
  41. */
  42. public override Asn1Object ToAsn1Object()
  43. {
  44. return attributes;
  45. }
  46. }
  47. }
  48. #pragma warning restore
  49. #endif