if (encodingsArr[0].equals(encoding)) {
// generate the object from PkiPath encoded form
return (X509CertPathImpl) ASN1.decode(in);
} else {
// generate the object from PKCS #7 encoded form
ContentInfo ci = (ContentInfo) ContentInfo.ASN1.decode(in);
SignedData sd = ci.getSignedData();
if (sd == null) {
throw new CertificateException(
Messages.getString("security.160")); //$NON-NLS-1$
}
List certs = sd.getCertificates();
if (certs == null) {
// empty chain of certificates
certs = new ArrayList();
}
List result = new ArrayList();
for (int i=0; i<certs.size(); i++) {
result.add(new X509CertImpl((Certificate) certs.get(i)));
}
return new X509CertPathImpl(result, PKCS7, ci.getEncoded());
}
} catch (IOException e) {
throw new CertificateException(Messages.getString("security.15E", //$NON-NLS-1$
e.getMessage()));
}