private static List<X509Certificate> parsePKIPATH(InputStream is)
            throws CertificateException {
        List<X509Certificate> certList = null;
        CertificateFactory certFac = null;

        if (is == null) {
            throw new CertificateException("input stream is null");
        }

        try {
            DerInputStream dis = new DerInputStream(readAllBytes(is));
            DerValue[] seq = dis.getSequence(3);
            if (seq.length == 0) {
                return Collections.<X509Certificate>emptyList();
            }

            certFac = CertificateFactory.getInstance("X.509");
            certList = new ArrayList<X509Certificate>(seq.length);

            // append certs in reverse order (target to trust anchor)
            for (int i = seq.length-1; i >= 0; i--) {
                certList.add((X509Certificate)certFac.generateCertificate
                    (new ByteArrayInputStream(seq[i].toByteArray())));
            }

            return Collections.unmodifiableList(certList);

        } catch (IOException ioe) {
            throw new CertificateException("IOException parsing PkiPath data: "
                    + ioe, ioe);
        }
    }
private static List < X509Certificate > parsePKIPATH ( InputStream is ) throws CertificateException { List < X509Certificate > certList = null ; CertificateFactory certFac = null ; if ( is == null ) { throw new CertificateException ( "input stream is null" ) ; } try { DerInputStream dis = new DerInputStream ( readAllBytes ( is ) ) ; DerValue [ ] seq = dis . getSequence ( 3 ) ; if ( seq . length == 0 ) { return Collections . < X509Certificate > emptyList ( ) ; } certFac = CertificateFactory . getInstance ( "X.509" ) ; certList = new ArrayList < X509Certificate > ( seq . length ) ; for ( int i = seq . length - 1 ; i >= 0 ; i -- ) { certList . add ( ( X509Certificate ) certFac . generateCertificate ( new ByteArrayInputStream ( seq [ i ] . toByteArray ( ) ) ) ) ; } return Collections . unmodifiableList ( certList ) ; } catch ( IOException ioe ) { throw new CertificateException ( "IOException parsing PkiPath data: " + ioe , ioe ) ; } }
Parse a PKIPATH format CertPath from an InputStream. Return an
unmodifiable List of the certificates.

@param is the <code>InputStream</code> to read the data from
@return an unmodifiable List of the certificates
@exception CertificateException if an exception occurs