summary refs log tree commit diff
path: root/crypto/src/asn1/cms/OriginatorIdentifierOrKey.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/cms/OriginatorIdentifierOrKey.cs')
-rw-r--r--crypto/src/asn1/cms/OriginatorIdentifierOrKey.cs73
1 files changed, 29 insertions, 44 deletions
diff --git a/crypto/src/asn1/cms/OriginatorIdentifierOrKey.cs b/crypto/src/asn1/cms/OriginatorIdentifierOrKey.cs
index 6b4c0488e..12b1f518d 100644
--- a/crypto/src/asn1/cms/OriginatorIdentifierOrKey.cs
+++ b/crypto/src/asn1/cms/OriginatorIdentifierOrKey.cs
@@ -8,6 +8,35 @@ namespace Org.BouncyCastle.Asn1.Cms
     public class OriginatorIdentifierOrKey
         : Asn1Encodable, IAsn1Choice
     {
+        public static OriginatorIdentifierOrKey GetInstance(
+            object o)
+        {
+            if (o == null)
+                return null;
+
+            if (o is OriginatorIdentifierOrKey originatorIdentifierOrKey)
+                return originatorIdentifierOrKey;
+
+            if (o is IssuerAndSerialNumber issuerAndSerialNumber)
+                return new OriginatorIdentifierOrKey(issuerAndSerialNumber);
+
+            if (o is SubjectKeyIdentifier subjectKeyIdentifier)
+                return new OriginatorIdentifierOrKey(subjectKeyIdentifier);
+
+            if (o is OriginatorPublicKey originatorPublicKey)
+                return new OriginatorIdentifierOrKey(originatorPublicKey);
+
+            if (o is Asn1TaggedObject taggedObject)
+                return new OriginatorIdentifierOrKey(Asn1Utilities.CheckTagClass(taggedObject, Asn1Tags.ContextSpecific));
+
+            throw new ArgumentException("Invalid OriginatorIdentifierOrKey: " + Platform.GetTypeName(o));
+        }
+
+        public static OriginatorIdentifierOrKey GetInstance(Asn1TaggedObject o, bool explicitly)
+        {
+            return Asn1Utilities.GetInstanceFromChoice(o, explicitly, GetInstance);
+        }
+
         private readonly Asn1Encodable id;
 
         public OriginatorIdentifierOrKey(IssuerAndSerialNumber id)
@@ -31,50 +60,6 @@ namespace Org.BouncyCastle.Asn1.Cms
 			this.id = id;
 		}
 
-		/**
-         * return an OriginatorIdentifierOrKey object from a tagged object.
-         *
-         * @param o the tagged object holding the object we want.
-         * @param explicitly true if the object is meant to be explicitly
-         *              tagged false otherwise.
-         * @exception ArgumentException if the object held by the
-         *          tagged object cannot be converted.
-         */
-        public static OriginatorIdentifierOrKey GetInstance(Asn1TaggedObject o, bool explicitly)
-        {
-            return Asn1Utilities.GetInstanceFromChoice(o, explicitly, GetInstance);
-        }
-
-        /**
-         * return an OriginatorIdentifierOrKey object from the given object.
-         *
-         * @param o the object we want converted.
-         * @exception ArgumentException if the object cannot be converted.
-         */
-        public static OriginatorIdentifierOrKey GetInstance(
-            object o)
-        {
-            if (o == null)
-                return null;
-
-            if (o is OriginatorIdentifierOrKey originatorIdentifierOrKey)
-                return originatorIdentifierOrKey;
-
-			if (o is IssuerAndSerialNumber issuerAndSerialNumber)
-				return new OriginatorIdentifierOrKey(issuerAndSerialNumber);
-
-			if (o is SubjectKeyIdentifier subjectKeyIdentifier)
-				return new OriginatorIdentifierOrKey(subjectKeyIdentifier);
-
-			if (o is OriginatorPublicKey originatorPublicKey)
-				return new OriginatorIdentifierOrKey(originatorPublicKey);
-
-			if (o is Asn1TaggedObject taggedObject)
-				return new OriginatorIdentifierOrKey(Asn1Utilities.CheckTagClass(taggedObject, Asn1Tags.ContextSpecific));
-
-            throw new ArgumentException("Invalid OriginatorIdentifierOrKey: " + Platform.GetTypeName(o));
-        }
-
 		public Asn1Encodable ID
 		{
 			get { return id; }