package org.bouncycastle.cms;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.cms.OriginatorInfo;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.cert.X509CRLHolder;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.util.CollectionStore;
import org.bouncycastle.util.Store;

public class OriginatorInformation
{
    private OriginatorInfo originatorInfo;

    OriginatorInformation(OriginatorInfo originatorInfo)
    {
        this.originatorInfo = originatorInfo;
    }

    /**
     * Return the certificates stored in the underlying OriginatorInfo object.
     *
     * @return a Store of X509CertificateHolder objects.
     */
    public Store getCertificates()
    {
        ASN1Set certSet = originatorInfo.getCertificates();

        if (certSet != null)
        {
            List certList = new ArrayList(certSet.size());

            for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)
            {
                ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();

                if (obj instanceof ASN1Sequence)
                {
                    certList.add(new X509CertificateHolder(Certificate.getInstance(obj)));
                }
            }

            return new CollectionStore(certList);
        }

        return new CollectionStore(new ArrayList());
    }

    /**
     * Return the CRLs stored in the underlying OriginatorInfo object.
     *
     * @return a Store of X509CRLHolder objects.
     */
    public Store getCRLs()
    {
        ASN1Set crlSet = originatorInfo.getCRLs();

        if (crlSet != null)
        {
            List    crlList = new ArrayList(crlSet.size());

            for (Enumeration en = crlSet.getObjects(); en.hasMoreElements();)
            {
                ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();

                if (obj instanceof ASN1Sequence)
                {
                    crlList.add(new X509CRLHolder(CertificateList.getInstance(obj)));
                }
            }

            return new CollectionStore(crlList);
        }

        return new CollectionStore(new ArrayList());
    }

    /**
     * Return the underlying ASN.1 object defining this SignerInformation object.
     *
     * @return a OriginatorInfo.
     */
    public OriginatorInfo toASN1Structure()
    {
        return originatorInfo;
    }
}

@@ -35,2433 +35,828 @@
 ort 
-java.util.ArrayList;%0Aimport java.util.Enumeration;%0Aimport java.util.List;%0A%0Aimport org.bouncycastle.asn1.ASN1Encodable;%0Aimport org.bouncycastle.asn1.ASN1Primitive;%0Aimport org.bouncycastle.asn1.ASN1Sequence;%0Aimport org.bouncycastle.asn1.ASN1Set;%0Aimport org.bouncycastle.asn1.cms.OriginatorInfo;%0Aimport org.bouncycastle.asn1.x509.Certificate;%0Aimport org.bouncycastle.asn1.x509.CertificateList;%0Aimport org.bouncycastle.cert.X509CRLHolder;%0Aimport org.bouncycastle.cert.X509CertificateHolder;%0Aimport org.bouncycastle.util.CollectionStore;%0Aimport org.bouncycastle.util.Store;%0A%0Apublic class OriginatorInformation%0A%7B%0A    private OriginatorInfo originatorInfo;%0A%0A    OriginatorInformation(OriginatorInfo originatorInfo)%0A    %7B%0A        this.originatorInfo = originatorInfo;%0A    %7D%0A%0A    /**%0A     * Return the certificates stored in the underlying OriginatorInfo object.%0A     *%0A     * @return a Store of X509CertificateHolder objects.%0A     */%0A    public Store getCertificates()%0A    %7B%0A        ASN1Set certSet = originatorInfo.getCertificates();%0A%0A        if (certSet != null)%0A        %7B%0A            List certList = new ArrayList(certSet.size());%0A%0A            for (Enumeration en = certSet.getObjects(); en.hasMoreElements();)%0A            %7B%0A                ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();%0A%0A                if (obj instanceof ASN1Sequence)%0A                %7B%0A                    certList.add(new X509CertificateHolder(Certificate.getInstance(obj)));%0A                %7D%0A            %7D%0A%0A            return new CollectionStore(certList);%0A        %7D%0A%0A        return new CollectionStore(new ArrayList());%0A    %7D%0A%0A    /**%0A     * Return the CRLs stored in the underlying OriginatorInfo object.%0A     *%0A     * @return a Store of X509CRLHolder objects.%0A     */%0A    public Store getCRLs()%0A    %7B%0A        ASN1Set crlSet = originatorInfo.getCRLs();%0A%0A        if (crlSet != null)%0A        %7B%0A            List    crlList = new ArrayList(crlSet.size());%0A%0A            for (Enumeration en = crlSet.getObjects(); en.hasMoreElements();)%0A            %7B%0A                ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive();%0A%0A                if (obj instanceof ASN1Sequence)%0A                %7B%0A                    crlList.add(new X509CRLHolder(CertificateList.getInstance(obj)));%0A                %7D%0A            %7D%0A%0A            return new CollectionStore(crlList);%0A        %7D%0A%0A        return new CollectionStore(new ArrayList
+org.bouncycastle.asn1.cms.OriginatorInfo;%0Aimport org.bouncycastle.util.Store;%0A%0Apublic class OriginatorInformation%0A%7B%0A    private OriginatorInfo originatorInfo;%0A%0A    OriginatorInformation(OriginatorInfo originatorInfo)%0A    %7B%0A        this.originatorInfo = originatorInfo;%0A    %7D%0A%0A    /**%0A     * Return the certificates stored in the underlying OriginatorInfo object.%0A     *%0A     * @return a Store of X509CertificateHolder objects.%0A     */%0A    public Store getCertificates()%0A    %7B%0A        return CMSSignedHelper.INSTANCE.getCertificates(originatorInfo.getCertificates());%0A    %7D%0A%0A    /**%0A     * Return the CRLs stored in the underlying OriginatorInfo object.%0A     *%0A     * @return a Store of X509CRLHolder objects.%0A     */%0A    public Store getCRLs()%0A    %7B%0A        return CMSSignedHelper.INSTANCE.getCRLs(originatorInfo.getCRLs
 ());

Use utility methods