summary refs log tree commit diff
path: root/crypto/src/asn1/crmf/CertId.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crypto/src/asn1/crmf/CertId.cs48
1 files changed, 17 insertions, 31 deletions
diff --git a/crypto/src/asn1/crmf/CertId.cs b/crypto/src/asn1/crmf/CertId.cs
index f0cc94691..c63c21ca8 100644
--- a/crypto/src/asn1/crmf/CertId.cs
+++ b/crypto/src/asn1/crmf/CertId.cs
@@ -1,48 +1,37 @@
-using System;
-
-using Org.BouncyCastle.Asn1.X509;
-using Org.BouncyCastle.Utilities;
+using Org.BouncyCastle.Asn1.X509;
 
 namespace Org.BouncyCastle.Asn1.Crmf
 {
     public class CertId
         : Asn1Encodable
     {
-        private readonly GeneralName issuer;
-        private readonly DerInteger serialNumber;
-
-        private CertId(Asn1Sequence seq)
-        {
-            issuer = GeneralName.GetInstance(seq[0]);
-            serialNumber = DerInteger.GetInstance(seq[1]);
-        }
-
         public static CertId GetInstance(object obj)
         {
-            if (obj is CertId)
-                return (CertId)obj;
-
-            if (obj is Asn1Sequence)
-                return new CertId((Asn1Sequence)obj);
-
-            throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj");
+            if (obj == null)
+                return null;
+            if (obj is CertId certID)
+                return certID;
+            return new CertId(Asn1Sequence.GetInstance(obj));
         }
 
         public static CertId GetInstance(Asn1TaggedObject obj, bool isExplicit)
         {
-            return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
+            return new CertId(Asn1Sequence.GetInstance(obj, isExplicit));
         }
 
-        public virtual GeneralName Issuer
-        {
-            get { return issuer; }
-        }
+        private readonly GeneralName m_issuer;
+        private readonly DerInteger m_serialNumber;
 
-        public virtual DerInteger SerialNumber
+        private CertId(Asn1Sequence seq)
         {
-            get { return serialNumber; }
+            m_issuer = GeneralName.GetInstance(seq[0]);
+            m_serialNumber = DerInteger.GetInstance(seq[1]);
         }
 
+        public virtual GeneralName Issuer => m_issuer;
+
+        public virtual DerInteger SerialNumber => m_serialNumber;
+
         /**
          * <pre>
          * CertId ::= SEQUENCE {
@@ -51,9 +40,6 @@ namespace Org.BouncyCastle.Asn1.Crmf
          * </pre>
          * @return a basic ASN.1 object representation.
          */
-        public override Asn1Object ToAsn1Object()
-        {
-            return new DerSequence(issuer, serialNumber);
-        }
+        public override Asn1Object ToAsn1Object() => new DerSequence(m_issuer, m_serialNumber);
     }
 }