summary refs log tree commit diff
path: root/crypto/src/asn1/x509
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/x509')
-rw-r--r--crypto/src/asn1/x509/AuthorityInformationAccess.cs10
-rw-r--r--crypto/src/asn1/x509/CRLDistPoint.cs13
-rw-r--r--crypto/src/asn1/x509/CertificatePolicies.cs7
-rw-r--r--crypto/src/asn1/x509/TargetInformation.cs21
-rw-r--r--crypto/src/asn1/x509/Targets.cs21
-rw-r--r--crypto/src/asn1/x509/qualified/SemanticsInformation.cs11
6 files changed, 23 insertions, 60 deletions
diff --git a/crypto/src/asn1/x509/AuthorityInformationAccess.cs b/crypto/src/asn1/x509/AuthorityInformationAccess.cs
index c601322c5..488f8b8a9 100644
--- a/crypto/src/asn1/x509/AuthorityInformationAccess.cs
+++ b/crypto/src/asn1/x509/AuthorityInformationAccess.cs
@@ -43,18 +43,12 @@ namespace Org.BouncyCastle.Asn1.X509
 
         private readonly AccessDescription[] descriptions;
 
-        private AuthorityInformationAccess(
-            Asn1Sequence seq)
+        private AuthorityInformationAccess(Asn1Sequence seq)
         {
             if (seq.Count < 1)
                 throw new ArgumentException("sequence may not be empty");
 
-            this.descriptions = new AccessDescription[seq.Count];
-
-            for (int i = 0; i < seq.Count; ++i)
-            {
-                descriptions[i] = AccessDescription.GetInstance(seq[i]);
-            }
+            this.descriptions = seq.MapElements(AccessDescription.GetInstance);
         }
 
         public AuthorityInformationAccess(
diff --git a/crypto/src/asn1/x509/CRLDistPoint.cs b/crypto/src/asn1/x509/CRLDistPoint.cs
index 518bf3f00..889769f29 100644
--- a/crypto/src/asn1/x509/CRLDistPoint.cs
+++ b/crypto/src/asn1/x509/CRLDistPoint.cs
@@ -41,24 +41,17 @@ namespace Org.BouncyCastle.Asn1.X509
 			seq = new DerSequence(points);
         }
 
-		/**
+        /**
          * Return the distribution points making up the sequence.
          *
          * @return DistributionPoint[]
          */
         public DistributionPoint[] GetDistributionPoints()
         {
-            DistributionPoint[] dp = new DistributionPoint[seq.Count];
-
-			for (int i = 0; i != seq.Count; ++i)
-            {
-                dp[i] = DistributionPoint.GetInstance(seq[i]);
-            }
-
-			return dp;
+            return seq.MapElements(DistributionPoint.GetInstance);
         }
 
-		/**
+        /**
          * Produce an object suitable for an Asn1OutputStream.
          * <pre>
          * CrlDistPoint ::= Sequence SIZE {1..MAX} OF DistributionPoint
diff --git a/crypto/src/asn1/x509/CertificatePolicies.cs b/crypto/src/asn1/x509/CertificatePolicies.cs
index 97214bd3f..1deef19d3 100644
--- a/crypto/src/asn1/x509/CertificatePolicies.cs
+++ b/crypto/src/asn1/x509/CertificatePolicies.cs
@@ -49,12 +49,7 @@ namespace Org.BouncyCastle.Asn1.X509
 
         private CertificatePolicies(Asn1Sequence seq)
         {
-            this.policyInformation = new PolicyInformation[seq.Count];
-
-            for (int i = 0; i < seq.Count; ++i)
-            {
-                policyInformation[i] = PolicyInformation.GetInstance(seq[i]);
-            }
+            this.policyInformation = seq.MapElements(PolicyInformation.GetInstance);
         }
 
         public virtual PolicyInformation[] GetPolicyInformation()
diff --git a/crypto/src/asn1/x509/TargetInformation.cs b/crypto/src/asn1/x509/TargetInformation.cs
index 2bf218977..c51e1e891 100644
--- a/crypto/src/asn1/x509/TargetInformation.cs
+++ b/crypto/src/asn1/x509/TargetInformation.cs
@@ -56,32 +56,25 @@ namespace Org.BouncyCastle.Asn1.X509
 			this.targets = targets;
 		}
 
-		/**
+        /**
 		 * Returns the targets in this target information extension.
 		 * <p>
 		 * The ArrayList is cloned before it is returned.</p>
 		 * 
 		 * @return Returns the targets.
 		 */
-		public virtual Targets[] GetTargetsObjects()
-		{
-			Targets[] result = new Targets[targets.Count];
-
-			for (int i = 0; i < targets.Count; ++i)
-			{
-				result[i] = Targets.GetInstance(targets[i]);
-			}
+        public virtual Targets[] GetTargetsObjects()
+        {
+            return targets.MapElements(Targets.GetInstance);
+        }
 
-			return result;
-		}
-
-		/**
+        /**
 		 * Constructs a target information from a single targets element. 
 		 * According to RFC 3281 only one targets element must be produced.
 		 * 
 		 * @param targets A Targets instance.
 		 */
-		public TargetInformation(
+        public TargetInformation(
 			Targets targets)
 		{
 			this.targets = new DerSequence(targets);
diff --git a/crypto/src/asn1/x509/Targets.cs b/crypto/src/asn1/x509/Targets.cs
index 0387e1f6b..93af8006d 100644
--- a/crypto/src/asn1/x509/Targets.cs
+++ b/crypto/src/asn1/x509/Targets.cs
@@ -85,26 +85,19 @@ namespace Org.BouncyCastle.Asn1.X509
 			this.targets = new DerSequence(targets);
 		}
 
-		/**
+        /**
 		 * Returns the targets in an <code>ArrayList</code>.
 		 * <p>
 		 * The ArrayList is cloned before it is returned.</p>
 		 * 
 		 * @return Returns the targets.
 		 */
-		public virtual Target[] GetTargets()
-		{
-			Target[] result = new Target[targets.Count];
-
-			for (int i = 0; i < targets.Count; ++i)
-			{
-				result[i] = Target.GetInstance(targets[i]);
-			}
-
-			return result;
-		}
+        public virtual Target[] GetTargets()
+        {
+            return targets.MapElements(Target.GetInstance);
+        }
 
-		/**
+        /**
 		 * Produce an object suitable for an Asn1OutputStream.
 		 * 
 		 * Returns:
@@ -115,7 +108,7 @@ namespace Org.BouncyCastle.Asn1.X509
 		 * 
 		 * @return an Asn1Object
 		 */
-		public override Asn1Object ToAsn1Object()
+        public override Asn1Object ToAsn1Object()
 		{
 			return targets;
 		}
diff --git a/crypto/src/asn1/x509/qualified/SemanticsInformation.cs b/crypto/src/asn1/x509/qualified/SemanticsInformation.cs
index 1106e10b1..36a15edec 100644
--- a/crypto/src/asn1/x509/qualified/SemanticsInformation.cs
+++ b/crypto/src/asn1/x509/qualified/SemanticsInformation.cs
@@ -61,18 +61,13 @@ namespace Org.BouncyCastle.Asn1.X509.Qualified
                 }
             }
 
-			if (obj != null)
+            if (obj != null)
             {
-                Asn1Sequence generalNameSeq = Asn1Sequence.GetInstance(obj);
-                nameRegistrationAuthorities = new GeneralName[generalNameSeq.Count];
-                for (int i= 0; i < generalNameSeq.Count; i++)
-                {
-                    nameRegistrationAuthorities[i] = GeneralName.GetInstance(generalNameSeq[i]);
-                }
+                this.nameRegistrationAuthorities = Asn1Sequence.GetInstance(obj).MapElements(GeneralName.GetInstance);
             }
         }
 
-		public SemanticsInformation(
+        public SemanticsInformation(
             DerObjectIdentifier semanticsIdentifier,
             GeneralName[] generalNames)
         {