CertBag
using System;
namespace Org.BouncyCastle.Asn1.Pkcs
{
public class CertBag : Asn1Encodable
{
private readonly DerObjectIdentifier m_certID;
private readonly Asn1Encodable m_certValue;
public virtual DerObjectIdentifier CertID => m_certID;
public virtual Asn1Object CertValue => m_certValue.ToAsn1Object();
public virtual Asn1Encodable CertValueEncodable => m_certValue;
public static CertBag GetInstance(object obj)
{
if (obj == null)
return null;
CertBag certBag = obj as CertBag;
if (certBag != null)
return certBag;
return new CertBag(Asn1Sequence.GetInstance(obj));
}
public static CertBag GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new CertBag(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
public static CertBag GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new CertBag(Asn1Sequence.GetTagged(taggedObject, declaredExplicit));
}
private CertBag(Asn1Sequence seq)
{
int count = seq.Count;
if (count != 2)
throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq");
m_certID = DerObjectIdentifier.GetInstance(seq[0]);
m_certValue = Asn1TaggedObject.GetInstance(seq[1], 128, 0).GetExplicitBaseObject();
}
public CertBag(DerObjectIdentifier certID, Asn1Object certValue)
{
if (certID == null)
throw new ArgumentNullException("certID");
m_certID = certID;
if (certValue == null)
throw new ArgumentNullException("certValue");
m_certValue = certValue;
}
public CertBag(DerObjectIdentifier certID, Asn1Encodable certValue)
{
if (certID == null)
throw new ArgumentNullException("certID");
m_certID = certID;
if (certValue == null)
throw new ArgumentNullException("certValue");
m_certValue = certValue;
}
public override Asn1Object ToAsn1Object()
{
return new DerSequence(m_certID, new DerTaggedObject(0, m_certValue));
}
}
}