summary refs log tree commit diff
path: root/crypto/src/asn1/esf/OtherRevRefs.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2024-05-26 22:58:57 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2024-05-26 22:58:57 +0700
commit46c46cecd4f62abf854576314751e44b320168ba (patch)
tree6bafc67dbf0f5480d9814e7764e770faad233f66 /crypto/src/asn1/esf/OtherRevRefs.cs
parentAuto-adjust DateTime precision for GeneralizedTime in X.509 (and OCSP) (diff)
downloadBouncyCastle.NET-ed25519-46c46cecd4f62abf854576314751e44b320168ba.tar.xz
Refactoring in Asn1.Esf
Diffstat (limited to 'crypto/src/asn1/esf/OtherRevRefs.cs')
-rw-r--r--crypto/src/asn1/esf/OtherRevRefs.cs102
1 files changed, 42 insertions, 60 deletions
diff --git a/crypto/src/asn1/esf/OtherRevRefs.cs b/crypto/src/asn1/esf/OtherRevRefs.cs
index 446031e5a..3aeade98c 100644
--- a/crypto/src/asn1/esf/OtherRevRefs.cs
+++ b/crypto/src/asn1/esf/OtherRevRefs.cs
@@ -1,80 +1,62 @@
 using System;
 
-using Org.BouncyCastle.Utilities;
-
 namespace Org.BouncyCastle.Asn1.Esf
 {
-	/// <remarks>
-	/// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition
-	/// <code>
-	/// OtherRevRefs ::= SEQUENCE 
-	/// {
-	///		otherRevRefType      OtherRevRefType,
-	///		otherRevRefs         ANY DEFINED BY otherRevRefType
-	/// }
-	///
-	/// OtherRevRefType ::= OBJECT IDENTIFIER
-	/// </code>
-	/// </remarks>
-	public class OtherRevRefs
+    /// <remarks>
+    /// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition
+    /// <code>
+    /// OtherRevRefs ::= SEQUENCE 
+    /// {
+    ///		otherRevRefType      OtherRevRefType,
+    ///		otherRevRefs         ANY DEFINED BY otherRevRefType
+    /// }
+    ///
+    /// OtherRevRefType ::= OBJECT IDENTIFIER
+    /// </code>
+    /// </remarks>
+    public class OtherRevRefs
 		: Asn1Encodable
 	{
-		private readonly DerObjectIdentifier	otherRevRefType;
-		private readonly Asn1Object				otherRevRefs;
-
-		public static OtherRevRefs GetInstance(
-			object obj)
+		public static OtherRevRefs GetInstance(object obj)
 		{
-			if (obj == null || obj is OtherRevRefs)
-				return (OtherRevRefs) obj;
+			if (obj == null)
+				return null;
+			if (obj is OtherRevRefs otherRevRefs)
+				return otherRevRefs;
+			return new OtherRevRefs(Asn1Sequence.GetInstance(obj));
+		}
 
-			if (obj is Asn1Sequence)
-				return new OtherRevRefs((Asn1Sequence) obj);
+        public static OtherRevRefs GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
+        {
+            return new OtherRevRefs(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
+        }
 
-			throw new ArgumentException(
-				"Unknown object in 'OtherRevRefs' factory: "
-                    + Platform.GetTypeName(obj),
-				"obj");
-		}
+        private readonly DerObjectIdentifier m_otherRevRefType;
+        private readonly Asn1Encodable m_otherRevRefs;
 
-		private OtherRevRefs(
-			Asn1Sequence seq)
+        private OtherRevRefs(Asn1Sequence seq)
 		{
-			if (seq == null)
-				throw new ArgumentNullException("seq");
-			if (seq.Count != 2)
-				throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
+            int count = seq.Count;
+            if (count != 2)
+                throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
 
-			this.otherRevRefType = (DerObjectIdentifier) seq[0].ToAsn1Object();
-			this.otherRevRefs = seq[1].ToAsn1Object();
+			m_otherRevRefType = DerObjectIdentifier.GetInstance(seq[0]);
+			m_otherRevRefs = seq[1];
 		}
 
-		public OtherRevRefs(
-			DerObjectIdentifier	otherRevRefType,
-			Asn1Encodable		otherRevRefs)
-		{
-			if (otherRevRefType == null)
-				throw new ArgumentNullException("otherRevRefType");
-			if (otherRevRefs == null)
-				throw new ArgumentNullException("otherRevRefs");
+        public OtherRevRefs(DerObjectIdentifier otherRevRefType, Asn1Encodable otherRevRefs)
+        {
+			m_otherRevRefType = otherRevRefType ?? throw new ArgumentNullException(nameof(otherRevRefType));
+            m_otherRevRefs = otherRevRefs ?? throw new ArgumentNullException(nameof(otherRevRefs));
+        }
 
-			this.otherRevRefType = otherRevRefType;
-			this.otherRevRefs = otherRevRefs.ToAsn1Object();
-		}
+        public DerObjectIdentifier OtherRevRefType => m_otherRevRefType;
 
-		public DerObjectIdentifier OtherRevRefType
-		{
-			get { return otherRevRefType; }
-		}
+		public Asn1Encodable OtherRevRefsData => m_otherRevRefs;
 
-		public Asn1Object OtherRevRefsObject
-		{
-			get { return otherRevRefs; }
-		}
+		[Obsolete("Use 'OtherRevRefsData' instead")]
+		public Asn1Object OtherRevRefsObject => m_otherRevRefs.ToAsn1Object();
 
-		public override Asn1Object ToAsn1Object()
-		{
-			return new DerSequence(otherRevRefType, otherRevRefs);
-		}
+		public override Asn1Object ToAsn1Object() => new DerSequence(m_otherRevRefType, m_otherRevRefs);
 	}
 }