diff options
Diffstat (limited to 'crypto/src/asn1/esf/OcspIdentifier.cs')
-rw-r--r-- | crypto/src/asn1/esf/OcspIdentifier.cs | 92 |
1 files changed, 38 insertions, 54 deletions
diff --git a/crypto/src/asn1/esf/OcspIdentifier.cs b/crypto/src/asn1/esf/OcspIdentifier.cs index fa3d60291..ddf26a7bc 100644 --- a/crypto/src/asn1/esf/OcspIdentifier.cs +++ b/crypto/src/asn1/esf/OcspIdentifier.cs @@ -2,52 +2,48 @@ using System; using Org.BouncyCastle.Asn1.Ocsp; using Org.BouncyCastle.Asn1.X509; -using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Asn1.Esf { - /// <remarks> - /// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition - /// <code> - /// OcspIdentifier ::= SEQUENCE { - /// ocspResponderID ResponderID, - /// -- As in OCSP response data - /// producedAt GeneralizedTime - /// -- As in OCSP response data - /// } - /// </code> - /// </remarks> - public class OcspIdentifier + /// <remarks> + /// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition + /// <code> + /// OcspIdentifier ::= SEQUENCE { + /// ocspResponderID ResponderID, + /// -- As in OCSP response data + /// producedAt GeneralizedTime + /// -- As in OCSP response data + /// } + /// </code> + /// </remarks> + public class OcspIdentifier : Asn1Encodable { - private readonly ResponderID ocspResponderID; - private readonly Asn1GeneralizedTime producedAt; - - public static OcspIdentifier GetInstance( - object obj) + public static OcspIdentifier GetInstance(object obj) { - if (obj == null || obj is OcspIdentifier) - return (OcspIdentifier) obj; + if (obj == null) + return null; + if (obj is OcspIdentifier ocspIdentifier) + return ocspIdentifier; + return new OcspIdentifier(Asn1Sequence.GetInstance(obj)); + } - if (obj is Asn1Sequence) - return new OcspIdentifier((Asn1Sequence) obj); + public static OcspIdentifier GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return new OcspIdentifier(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + } - throw new ArgumentException( - "Unknown object in 'OcspIdentifier' factory: " - + Platform.GetTypeName(obj), - "obj"); - } + private readonly ResponderID m_ocspResponderID; + private readonly Asn1GeneralizedTime m_producedAt; - private OcspIdentifier( - Asn1Sequence seq) + private OcspIdentifier(Asn1Sequence seq) { - if (seq == null) - throw new ArgumentNullException("seq"); - if (seq.Count != 2) - throw new ArgumentException("Bad sequence size: " + seq.Count, "seq"); + int count = 2; + if (count != 2) + throw new ArgumentException("Bad sequence size: " + count, nameof(seq)); - this.ocspResponderID = ResponderID.GetInstance(seq[0].ToAsn1Object()); - this.producedAt = (Asn1GeneralizedTime)seq[1].ToAsn1Object(); + m_ocspResponderID = ResponderID.GetInstance(seq[0]); + m_producedAt = Asn1GeneralizedTime.GetInstance(seq[1]); } public OcspIdentifier(ResponderID ocspResponderID, DateTime producedAt) @@ -57,28 +53,16 @@ namespace Org.BouncyCastle.Asn1.Esf public OcspIdentifier(ResponderID ocspResponderID, Asn1GeneralizedTime producedAt) { - if (ocspResponderID == null) - throw new ArgumentNullException(nameof(ocspResponderID)); - if (producedAt == null) - throw new ArgumentNullException(nameof(producedAt)); - - this.ocspResponderID = ocspResponderID; - this.producedAt = producedAt; + m_ocspResponderID = ocspResponderID ?? throw new ArgumentNullException(nameof(ocspResponderID)); + m_producedAt = producedAt ?? throw new ArgumentNullException(nameof(producedAt)); } - public ResponderID OcspResponderID - { - get { return ocspResponderID; } - } + public ResponderID OcspResponderID => m_ocspResponderID; - public DateTime ProducedAt - { - get { return producedAt.ToDateTime(); } - } + public Asn1GeneralizedTime ProducedAtData => m_producedAt; - public override Asn1Object ToAsn1Object() - { - return new DerSequence(ocspResponderID, producedAt); - } + public DateTime ProducedAt => m_producedAt.ToDateTime(); + + public override Asn1Object ToAsn1Object() => new DerSequence(m_ocspResponderID, m_producedAt); } } |