summary refs log tree commit diff
path: root/crypto/src/x509/extension/X509ExtensionUtil.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/x509/extension/X509ExtensionUtil.cs')
-rw-r--r--crypto/src/x509/extension/X509ExtensionUtil.cs65
1 files changed, 31 insertions, 34 deletions
diff --git a/crypto/src/x509/extension/X509ExtensionUtil.cs b/crypto/src/x509/extension/X509ExtensionUtil.cs
index 5f65ebfda..b751658e1 100644
--- a/crypto/src/x509/extension/X509ExtensionUtil.cs
+++ b/crypto/src/x509/extension/X509ExtensionUtil.cs
@@ -1,11 +1,10 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Security.Certificates;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.X509.Extension
 {
@@ -17,66 +16,64 @@ namespace Org.BouncyCastle.X509.Extension
 			return Asn1Object.FromByteArray(extensionValue.GetOctets());
 		}
 
-		public static ICollection GetIssuerAlternativeNames(
-			X509Certificate cert)
+		public static IList<IList<object>> GetIssuerAlternativeNames(X509Certificate cert)
 		{
 			Asn1OctetString extVal = cert.GetExtensionValue(X509Extensions.IssuerAlternativeName);
 
 			return GetAlternativeName(extVal);
 		}
 
-		public static ICollection GetSubjectAlternativeNames(
-			X509Certificate cert)
+		public static IList<IList<object>> GetSubjectAlternativeNames(X509Certificate cert)
 		{
 			Asn1OctetString extVal = cert.GetExtensionValue(X509Extensions.SubjectAlternativeName);
 
 			return GetAlternativeName(extVal);
 		}
 
-		private static ICollection GetAlternativeName(
+		private static IList<IList<object>> GetAlternativeName(
 			Asn1OctetString extVal)
 		{
-			IList temp = Platform.CreateArrayList();
+			var result = new List<IList<object>>();
 
 			if (extVal != null)
 			{
 				try
 				{
-					Asn1Sequence seq = DerSequence.GetInstance(FromExtensionValue(extVal));
+					Asn1Sequence seq = Asn1Sequence.GetInstance(FromExtensionValue(extVal));
 
 					foreach (Asn1Encodable primName in seq)
 					{
-                        IList list = Platform.CreateArrayList();
-                        GeneralName genName = GeneralName.GetInstance(primName);
+						GeneralName genName = GeneralName.GetInstance(primName);
 
+						var list = new List<object>(2);
 						list.Add(genName.TagNo);
 
 						switch (genName.TagNo)
 						{
-							case GeneralName.EdiPartyName:
-							case GeneralName.X400Address:
-							case GeneralName.OtherName:
-								list.Add(genName.Name.ToAsn1Object());
-								break;
-							case GeneralName.DirectoryName:
-								list.Add(X509Name.GetInstance(genName.Name).ToString());
-								break;
-							case GeneralName.DnsName:
-							case GeneralName.Rfc822Name:
-							case GeneralName.UniformResourceIdentifier:
-								list.Add(((IAsn1String)genName.Name).GetString());
-								break;
-							case GeneralName.RegisteredID:
-								list.Add(DerObjectIdentifier.GetInstance(genName.Name).Id);
-								break;
-							case GeneralName.IPAddress:
-								list.Add(DerOctetString.GetInstance(genName.Name).GetOctets());
-								break;
-							default:
-								throw new IOException("Bad tag number: " + genName.TagNo);
+						case GeneralName.EdiPartyName:
+						case GeneralName.X400Address:
+						case GeneralName.OtherName:
+							list.Add(genName.Name.ToAsn1Object());
+							break;
+						case GeneralName.DirectoryName:
+							list.Add(X509Name.GetInstance(genName.Name).ToString());
+							break;
+						case GeneralName.DnsName:
+						case GeneralName.Rfc822Name:
+						case GeneralName.UniformResourceIdentifier:
+							list.Add(((IAsn1String)genName.Name).GetString());
+							break;
+						case GeneralName.RegisteredID:
+							list.Add(DerObjectIdentifier.GetInstance(genName.Name).Id);
+							break;
+						case GeneralName.IPAddress:
+							list.Add(Asn1OctetString.GetInstance(genName.Name).GetOctets());
+							break;
+						default:
+							throw new IOException("Bad tag number: " + genName.TagNo);
 						}
 
-						temp.Add(list);
+						result.Add(list);
 					}
 				}
 				catch (Exception e)
@@ -85,7 +82,7 @@ namespace Org.BouncyCastle.X509.Extension
 				}
 			}
 
-			return temp;
+			return result;
 		}
 	}
 }