summary refs log tree commit diff
path: root/crypto/src/asn1/isismtt
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-06-04 16:55:26 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-06-04 16:55:26 +0700
commit3eb93b423abeefbdc03f0ecc38751d76428ba23e (patch)
treef364f857c54f65eb59462560b1f282b896eecf8b /crypto/src/asn1/isismtt
parentPort LinkedCertificate from bc-java (diff)
downloadBouncyCastle.NET-ed25519-3eb93b423abeefbdc03f0ecc38751d76428ba23e.tar.xz
Refactoring
Diffstat (limited to 'crypto/src/asn1/isismtt')
-rw-r--r--crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs11
-rw-r--r--crypto/src/asn1/isismtt/x509/Admissions.cs20
-rw-r--r--crypto/src/asn1/isismtt/x509/NamingAuthority.cs18
-rw-r--r--crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs36
-rw-r--r--crypto/src/asn1/isismtt/x509/ProfessionInfo.cs37
5 files changed, 49 insertions, 73 deletions
diff --git a/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs b/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs
index 4b6264ae0..a45075ee4 100644
--- a/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs
+++ b/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs
@@ -243,13 +243,10 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
         */
         public override Asn1Object ToAsn1Object()
         {
-            Asn1EncodableVector vec = new Asn1EncodableVector();
-            if (admissionAuthority != null)
-            {
-                vec.Add(admissionAuthority);
-            }
-            vec.Add(contentsOfAdmissions);
-            return new DerSequence(vec);
+            Asn1EncodableVector v = new Asn1EncodableVector();
+            v.AddOptional(admissionAuthority);
+            v.Add(contentsOfAdmissions);
+            return new DerSequence(v);
         }
 
         /**
diff --git a/crypto/src/asn1/isismtt/x509/Admissions.cs b/crypto/src/asn1/isismtt/x509/Admissions.cs
index e914db0b5..2aa6764bb 100644
--- a/crypto/src/asn1/isismtt/x509/Admissions.cs
+++ b/crypto/src/asn1/isismtt/x509/Admissions.cs
@@ -167,21 +167,11 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 		*/
 		public override Asn1Object ToAsn1Object()
 		{
-			Asn1EncodableVector vec = new Asn1EncodableVector();
-
-			if (admissionAuthority != null)
-			{
-				vec.Add(new DerTaggedObject(true, 0, admissionAuthority));
-			}
-
-			if (namingAuthority != null)
-			{
-				vec.Add(new DerTaggedObject(true, 1, namingAuthority));
-			}
-
-			vec.Add(professionInfos);
-
-			return new DerSequence(vec);
+			Asn1EncodableVector v = new Asn1EncodableVector();
+            v.AddOptionalTagged(true, 0, admissionAuthority);
+            v.AddOptionalTagged(true, 1, namingAuthority);
+			v.Add(professionInfos);
+			return new DerSequence(v);
 		}
 	}
 }
diff --git a/crypto/src/asn1/isismtt/x509/NamingAuthority.cs b/crypto/src/asn1/isismtt/x509/NamingAuthority.cs
index 35539f488..543dcecc7 100644
--- a/crypto/src/asn1/isismtt/x509/NamingAuthority.cs
+++ b/crypto/src/asn1/isismtt/x509/NamingAuthority.cs
@@ -196,20 +196,16 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 		*/
 		public override Asn1Object ToAsn1Object()
 		{
-			Asn1EncodableVector vec = new Asn1EncodableVector();
-			if (namingAuthorityID != null)
-			{
-				vec.Add(namingAuthorityID);
-			}
+			Asn1EncodableVector v = new Asn1EncodableVector();
+            v.AddOptional(namingAuthorityID);
+
 			if (namingAuthorityUrl != null)
 			{
-				vec.Add(new DerIA5String(namingAuthorityUrl, true));
+				v.Add(new DerIA5String(namingAuthorityUrl, true));
 			}
-			if (namingAuthorityText != null)
-			{
-				vec.Add(namingAuthorityText);
-			}
-			return new DerSequence(vec);
+
+            v.AddOptional(namingAuthorityText);
+			return new DerSequence(v);
 		}
 	}
 }
diff --git a/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs b/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs
index f42364699..60d3a88e8 100644
--- a/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs
+++ b/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs
@@ -209,25 +209,25 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 		*/
 		public override Asn1Object ToAsn1Object()
 		{
-			Asn1EncodableVector vec = new Asn1EncodableVector();
-			if (country != null)
-			{
-				vec.Add(new DerTaggedObject(true, 1, new DerPrintableString(country, true)));
-			}
-			if (typeOfSubstitution != null)
-			{
-				vec.Add(new DerTaggedObject(true, 2, typeOfSubstitution));
-			}
-			if (thirdPerson != null)
-			{
-				vec.Add(new DerTaggedObject(true, 3, thirdPerson));
-			}
-			else
-			{
-				vec.Add(new DerTaggedObject(true, 3, certRef));
-			}
+            Asn1EncodableVector v = new Asn1EncodableVector();
+
+            if (country != null)
+            {
+                v.Add(new DerTaggedObject(true, 1, new DerPrintableString(country, true)));
+            }
+
+            v.AddOptionalTagged(true, 2, typeOfSubstitution);
+
+            if (thirdPerson != null)
+            {
+                v.Add(new DerTaggedObject(true, 3, thirdPerson));
+            }
+            else
+            {
+                v.Add(new DerTaggedObject(true, 3, certRef));
+            }
 
-			return new DerSequence(vec);
+            return new DerSequence(v);
 		}
 	}
 }
diff --git a/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs b/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs
index 671a465af..b65757c09 100644
--- a/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs
+++ b/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs
@@ -302,28 +302,21 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 		*
 		* @return an Asn1Object
 		*/
-		public override Asn1Object ToAsn1Object()
-		{
-			Asn1EncodableVector vec = new Asn1EncodableVector();
-			if (namingAuthority != null)
-			{
-				vec.Add(new DerTaggedObject(true, 0, namingAuthority));
-			}
-			vec.Add(professionItems);
-			if (professionOids != null)
-			{
-				vec.Add(professionOids);
-			}
-			if (registrationNumber != null)
-			{
-				vec.Add(new DerPrintableString(registrationNumber, true));
-			}
-			if (addProfessionInfo != null)
-			{
-				vec.Add(addProfessionInfo);
-			}
-			return new DerSequence(vec);
-		}
+        public override Asn1Object ToAsn1Object()
+        {
+            Asn1EncodableVector v = new Asn1EncodableVector();
+            v.AddOptionalTagged(true, 0, namingAuthority);
+            v.Add(professionItems);
+            v.AddOptional(professionOids);
+
+            if (registrationNumber != null)
+            {
+                v.Add(new DerPrintableString(registrationNumber, true));
+            }
+
+            v.AddOptional(addProfessionInfo);
+            return new DerSequence(v);
+        }
 
 		/**
 		* @return Returns the addProfessionInfo.