summary refs log tree commit diff
path: root/crypto/src/cms/OriginatorInfoGenerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms/OriginatorInfoGenerator.cs')
-rw-r--r--crypto/src/cms/OriginatorInfoGenerator.cs59
1 files changed, 45 insertions, 14 deletions
diff --git a/crypto/src/cms/OriginatorInfoGenerator.cs b/crypto/src/cms/OriginatorInfoGenerator.cs
index d7d24dcc4..ec6d2d8d8 100644
--- a/crypto/src/cms/OriginatorInfoGenerator.cs
+++ b/crypto/src/cms/OriginatorInfoGenerator.cs
@@ -1,9 +1,7 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
-using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Utilities.Collections;
 using Org.BouncyCastle.X509;
 
@@ -11,30 +9,63 @@ namespace Org.BouncyCastle.Cms
 {
     public class OriginatorInfoGenerator
     {
-        private readonly List<X509CertificateStructure> origCerts;
-        private readonly List<CertificateList> origCrls;
+        private readonly List<Asn1Encodable> origCerts;
+        private readonly List<Asn1Encodable> origCrls;
 
         public OriginatorInfoGenerator(X509Certificate origCert)
         {
-            this.origCerts = new List<X509CertificateStructure>();
+            this.origCerts = new List<Asn1Encodable>{ origCert.CertificateStructure };
             this.origCrls = null;
-            origCerts.Add(origCert.CertificateStructure);
         }
 
-        public OriginatorInfoGenerator(IStore<X509Certificate> origCerts)
-            : this(origCerts, null)
+        public OriginatorInfoGenerator(IStore<X509Certificate> x509Certs)
+            : this(x509Certs, null, null, null)
         {
         }
 
-        public OriginatorInfoGenerator(IStore<X509Certificate> origCerts, IStore<X509Crl> origCrls)
+        public OriginatorInfoGenerator(IStore<X509Certificate> x509Certs, IStore<X509Crl> x509Crls)
+            : this(x509Certs, x509Crls, null, null)
         {
-            this.origCerts = CmsUtilities.GetCertificatesFromStore(origCerts);
-            this.origCrls = origCrls == null ? null : CmsUtilities.GetCrlsFromStore(origCrls);
         }
- 
+
+        public OriginatorInfoGenerator(IStore<X509Certificate> x509Certs, IStore<X509Crl> x509Crls,
+            IStore<X509V2AttributeCertificate> x509AttrCerts, IStore<OtherRevocationInfoFormat> otherRevocationInfos)
+        {
+            List<Asn1Encodable> certificates = null;
+            if (x509Certs != null || x509AttrCerts != null)
+            {
+                certificates = new List<Asn1Encodable>();
+                if (x509Certs != null)
+                {
+                    certificates.AddRange(CmsUtilities.GetCertificatesFromStore(x509Certs));
+                }
+                if (x509AttrCerts != null)
+                {
+                    certificates.AddRange(CmsUtilities.GetAttributeCertificatesFromStore(x509AttrCerts));
+                }
+            }
+
+            List<Asn1Encodable> revocations = null;
+            if (x509Crls != null || otherRevocationInfos != null)
+            {
+                revocations = new List<Asn1Encodable>();
+                if (x509Crls != null)
+                {
+                    revocations.AddRange(CmsUtilities.GetCrlsFromStore(x509Crls));
+                }
+                if (otherRevocationInfos != null)
+                {
+                    revocations.AddRange(CmsUtilities.GetOtherRevocationInfosFromStore(otherRevocationInfos));
+                }
+            }
+
+            this.origCerts = certificates;
+            this.origCrls = revocations;
+        }
+
         public virtual OriginatorInfo Generate()
         {
-            Asn1Set certSet = CmsUtilities.CreateDerSetFromList(origCerts);
+            Asn1Set certSet = origCerts == null ? null : CmsUtilities.CreateDerSetFromList(origCerts);
             Asn1Set crlSet = origCrls == null ? null : CmsUtilities.CreateDerSetFromList(origCrls);
             return new OriginatorInfo(certSet, crlSet);
         }