Attribute.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms
  6. {
  7. public class Attribute
  8. : Asn1Encodable
  9. {
  10. private DerObjectIdentifier attrType;
  11. private Asn1Set attrValues;
  12. /**
  13. * return an Attribute object from the given object.
  14. *
  15. * @param o the object we want converted.
  16. * @exception ArgumentException if the object cannot be converted.
  17. */
  18. public static Attribute GetInstance(
  19. object obj)
  20. {
  21. if (obj == null || obj is Attribute)
  22. return (Attribute) obj;
  23. if (obj is Asn1Sequence)
  24. return new Attribute((Asn1Sequence) obj);
  25. throw new ArgumentException("unknown object in factory: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  26. }
  27. public Attribute(
  28. Asn1Sequence seq)
  29. {
  30. attrType = (DerObjectIdentifier)seq[0];
  31. attrValues = (Asn1Set)seq[1];
  32. }
  33. public Attribute(
  34. DerObjectIdentifier attrType,
  35. Asn1Set attrValues)
  36. {
  37. this.attrType = attrType;
  38. this.attrValues = attrValues;
  39. }
  40. public DerObjectIdentifier AttrType
  41. {
  42. get { return attrType; }
  43. }
  44. public Asn1Set AttrValues
  45. {
  46. get { return attrValues; }
  47. }
  48. /**
  49. * Produce an object suitable for an Asn1OutputStream.
  50. * <pre>
  51. * Attribute ::= SEQUENCE {
  52. * attrType OBJECT IDENTIFIER,
  53. * attrValues SET OF AttributeValue
  54. * }
  55. * </pre>
  56. */
  57. public override Asn1Object ToAsn1Object()
  58. {
  59. return new DerSequence(attrType, attrValues);
  60. }
  61. }
  62. }
  63. #pragma warning restore
  64. #endif