ASN1Sequence seq = (ASN1Sequence)en.nextElement();
ASN1Sequence seq = ASN1Sequence.getInstance(((DEREncodable)en.nextElement()).getDERObject());
    public CertStore getCertificatesAndCRLs(        String  type,        String  provider)        throws NoSuchAlgorithmException, NoSuchProviderException, CMSException    {        if (_certStore == null)        {            List                    certsAndcrls = new ArrayList();            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();            CertificateFactory      cf;            try            {                cf = CertificateFactory.getInstance("X.509", provider);            }            catch (CertificateException ex)            {                throw new CMSException("can't get certificate factory.", ex);            }            //            // load the certificates and revocation lists if we have any            //            try            {                ASN1SetParser s = _signedData.getCertificates();                    if (s != null)                {                    ASN1Set set = ASN1Set.getInstance(s.getDERObject());                    for (Enumeration en = set.getObjects(); en.hasMoreElements();)                    {                        DERObject obj = (DERObject)en.nextElement();                        try                        {                            if (obj instanceof ASN1Sequence)                            {                                certsAndcrls.add(cf.generateCertificate(                                    new ByteArrayInputStream(obj.getEncoded())));                            }                        }                        catch (IOException ex)                        {                            throw new CMSException(                                    "can't re-encode certificate!", ex);                        }                        catch (CertificateException ex)                        {                            throw new CMSException(                                    "can't re-encode certificate!", ex);                        }                            bOut.reset();                    }                }                    s = _signedData.getCrls();                    if (s != null)                {                    ASN1Set set = ASN1Set.getInstance(s.getDERObject());                    for (Enumeration en = set.getObjects(); en.hasMoreElements();)                    {                        ASN1Sequence seq = (ASN1Sequence)en.nextElement();                        try                        {                            certsAndcrls.add(cf.generateCRL(                                new ByteArrayInputStream(seq.getEncoded())));                        }                        catch (IOException ex)                        {                            throw new CMSException("can't re-encode CRL!", ex);                        }                        catch (CRLException ex)                        {                            throw new CMSException("can't re-encode CRL!", ex);                        }                            bOut.reset();                    }                }            }            catch (IOException e)            {                throw new CMSException("io exception: " + e.getMessage(), e);            }            try            {                _certStore = CertStore.getInstance(type,                     new CollectionCertStoreParameters(certsAndcrls), provider);            }            catch (InvalidAlgorithmParameterException e)            {                throw new CMSException("can't setup the CertStore", e);            }        }        return _certStore;    }