summary refs log tree commit diff
path: root/crypto/src/asn1/esf/CompleteCertificateRefs.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/esf/CompleteCertificateRefs.cs')
-rw-r--r--crypto/src/asn1/esf/CompleteCertificateRefs.cs54
1 files changed, 20 insertions, 34 deletions
diff --git a/crypto/src/asn1/esf/CompleteCertificateRefs.cs b/crypto/src/asn1/esf/CompleteCertificateRefs.cs
index 24727dc25..4e8f122ca 100644
--- a/crypto/src/asn1/esf/CompleteCertificateRefs.cs
+++ b/crypto/src/asn1/esf/CompleteCertificateRefs.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.1 Complete Certificate Refs Attribute Definition
-	/// <code>
-	/// CompleteCertificateRefs ::= SEQUENCE OF OtherCertID
-	/// </code>
-	/// </remarks>
-	public class CompleteCertificateRefs
+    /// <remarks>
+    /// RFC 3126: 4.2.1 Complete Certificate Refs Attribute Definition
+    /// <code>
+    /// CompleteCertificateRefs ::= SEQUENCE OF OtherCertID
+    /// </code>
+    /// </remarks>
+    public class CompleteCertificateRefs
 		: Asn1Encodable
 	{
-		private readonly Asn1Sequence m_otherCertIDs;
-
 		public static CompleteCertificateRefs GetInstance(object obj)
 		{
 			if (obj == null)
 				return null;
-
             if (obj is CompleteCertificateRefs completeCertificateRefs)
 				return completeCertificateRefs;
-
-			if (obj is Asn1Sequence asn1Sequence)
-				return new CompleteCertificateRefs(asn1Sequence);
-
-			throw new ArgumentException("Unknown object in 'CompleteCertificateRefs' factory: " + Platform.GetTypeName(obj),
-				nameof(obj));
+			return new CompleteCertificateRefs(Asn1Sequence.GetInstance(obj));
 		}
 
-		private CompleteCertificateRefs(Asn1Sequence seq)
-		{
-			if (seq == null)
-				throw new ArgumentNullException(nameof(seq));
+        public static CompleteCertificateRefs GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
+        {
+            return new CompleteCertificateRefs(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
+        }
 
-            // Validate
-            seq.MapElements(element => OtherCertID.GetInstance(element.ToAsn1Object()));
+        private readonly Asn1Sequence m_otherCertIDs;
 
+        private CompleteCertificateRefs(Asn1Sequence seq)
+		{
             m_otherCertIDs = seq;
+            m_otherCertIDs.MapElements(OtherCertID.GetInstance); // Validate
 		}
 
 		public CompleteCertificateRefs(params OtherCertID[] otherCertIDs)
@@ -47,7 +39,7 @@ namespace Org.BouncyCastle.Asn1.Esf
 			if (otherCertIDs == null)
 				throw new ArgumentNullException(nameof(otherCertIDs));
 
-			m_otherCertIDs = new DerSequence(otherCertIDs);
+			m_otherCertIDs = DerSequence.FromElements(otherCertIDs);
 		}
 
 		public CompleteCertificateRefs(IEnumerable<OtherCertID> otherCertIDs)
@@ -55,17 +47,11 @@ namespace Org.BouncyCastle.Asn1.Esf
 			if (otherCertIDs == null)
                 throw new ArgumentNullException(nameof(otherCertIDs));
 
-            m_otherCertIDs = new DerSequence(Asn1EncodableVector.FromEnumerable(otherCertIDs));
+            m_otherCertIDs = DerSequence.FromVector(Asn1EncodableVector.FromEnumerable(otherCertIDs));
 		}
 
-		public OtherCertID[] GetOtherCertIDs()
-		{
-            return m_otherCertIDs.MapElements(element => OtherCertID.GetInstance(element.ToAsn1Object()));
-		}
+		public OtherCertID[] GetOtherCertIDs() => m_otherCertIDs.MapElements(OtherCertID.GetInstance);
 
-		public override Asn1Object ToAsn1Object()
-		{
-			return m_otherCertIDs;
-		}
+		public override Asn1Object ToAsn1Object() => m_otherCertIDs;
 	}
 }