AttributeX509
using System;
namespace Org.BouncyCastle.Asn1.X509
{
public class AttributeX509 : Asn1Encodable
{
private readonly DerObjectIdentifier m_attrType;
private readonly Asn1Set m_attrValues;
public DerObjectIdentifier AttrType => m_attrType;
public Asn1Set AttrValues => m_attrValues;
public static AttributeX509 GetInstance(object obj)
{
if (obj == null)
return null;
AttributeX509 attributeX = obj as AttributeX509;
if (attributeX != null)
return attributeX;
return new AttributeX509(Asn1Sequence.GetInstance(obj));
}
public static AttributeX509 GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new AttributeX509(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
public static AttributeX509 GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new AttributeX509(Asn1Sequence.GetTagged(taggedObject, declaredExplicit));
}
private AttributeX509(Asn1Sequence seq)
{
int count = seq.Count;
if (count != 2)
throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq");
m_attrType = DerObjectIdentifier.GetInstance(seq[0]);
m_attrValues = Asn1Set.GetInstance(seq[1]);
}
public AttributeX509(DerObjectIdentifier attrType, Asn1Set attrValues)
{
if (attrType == null)
throw new ArgumentNullException("attrType");
m_attrType = attrType;
if (attrValues == null)
throw new ArgumentNullException("attrValues");
m_attrValues = attrValues;
}
public Asn1Encodable[] GetAttributeValues()
{
return m_attrValues.ToArray();
}
public override Asn1Object ToAsn1Object()
{
return new DerSequence(m_attrType, m_attrValues);
}
}
}