diff options
Diffstat (limited to 'crypto/src/asn1/esf/CompleteRevocationRefs.cs')
-rw-r--r-- | crypto/src/asn1/esf/CompleteRevocationRefs.cs | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/crypto/src/asn1/esf/CompleteRevocationRefs.cs b/crypto/src/asn1/esf/CompleteRevocationRefs.cs index 2c120f0f9..82ac6beab 100644 --- a/crypto/src/asn1/esf/CompleteRevocationRefs.cs +++ b/crypto/src/asn1/esf/CompleteRevocationRefs.cs @@ -1,45 +1,37 @@ using System; using System.Collections.Generic; -using Org.BouncyCastle.Utilities; - namespace Org.BouncyCastle.Asn1.Esf { - /// <remarks> - /// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition - /// <code> - /// CompleteRevocationRefs ::= SEQUENCE OF CrlOcspRef - /// </code> - /// </remarks> - public class CompleteRevocationRefs + /// <remarks> + /// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition + /// <code> + /// CompleteRevocationRefs ::= SEQUENCE OF CrlOcspRef + /// </code> + /// </remarks> + public class CompleteRevocationRefs : Asn1Encodable { - private readonly Asn1Sequence m_crlOcspRefs; - public static CompleteRevocationRefs GetInstance(object obj) { if (obj == null) return null; - if (obj is CompleteRevocationRefs completeRevocationRefs) return completeRevocationRefs; - - if (obj is Asn1Sequence asn1Sequence) - return new CompleteRevocationRefs(asn1Sequence); - - throw new ArgumentException("Unknown object in 'CompleteRevocationRefs' factory: " + Platform.GetTypeName(obj), - nameof(obj)); + return new CompleteRevocationRefs(Asn1Sequence.GetInstance(obj)); } - private CompleteRevocationRefs(Asn1Sequence seq) - { - if (seq == null) - throw new ArgumentNullException(nameof(seq)); + public static CompleteRevocationRefs GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return new CompleteRevocationRefs(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + } - // Validate - seq.MapElements(element => CrlOcspRef.GetInstance(element.ToAsn1Object())); + private readonly Asn1Sequence m_crlOcspRefs; + private CompleteRevocationRefs(Asn1Sequence seq) + { m_crlOcspRefs = seq; + m_crlOcspRefs.MapElements(CrlOcspRef.GetInstance); // Validate } public CompleteRevocationRefs(params CrlOcspRef[] crlOcspRefs) @@ -47,7 +39,7 @@ namespace Org.BouncyCastle.Asn1.Esf if (crlOcspRefs == null) throw new ArgumentNullException(nameof(crlOcspRefs)); - m_crlOcspRefs = new DerSequence(crlOcspRefs); + m_crlOcspRefs = DerSequence.FromElements(crlOcspRefs); } public CompleteRevocationRefs(IEnumerable<CrlOcspRef> crlOcspRefs) @@ -55,17 +47,11 @@ namespace Org.BouncyCastle.Asn1.Esf if (crlOcspRefs == null) throw new ArgumentNullException(nameof(crlOcspRefs)); - m_crlOcspRefs = new DerSequence(Asn1EncodableVector.FromEnumerable(crlOcspRefs)); + m_crlOcspRefs = DerSequence.FromVector(Asn1EncodableVector.FromEnumerable(crlOcspRefs)); } - public CrlOcspRef[] GetCrlOcspRefs() - { - return m_crlOcspRefs.MapElements(element => CrlOcspRef.GetInstance(element.ToAsn1Object())); - } + public CrlOcspRef[] GetCrlOcspRefs() => m_crlOcspRefs.MapElements(CrlOcspRef.GetInstance); - public override Asn1Object ToAsn1Object() - { - return m_crlOcspRefs; - } + public override Asn1Object ToAsn1Object() => m_crlOcspRefs; } } |