keyCerts = new Hashtable();
for (int i = 0; i != chain.size(); i++)
{
SafeBag b = (SafeBag)chain.elementAt(i);
CertBag cb = new CertBag((ASN1Sequence)b.getBagValue());
if (!cb.getCertId().equals(x509Certificate))
{
throw new RuntimeException("Unsupported certificate type: " + cb.getCertId());
}
Certificate cert;
try
{
ByteArrayInputStream cIn = new ByteArrayInputStream(
((ASN1OctetString)cb.getCertValue()).getOctets());
cert = certFact.generateCertificate(cIn);
}
catch (Exception e)
{
throw new RuntimeException(e.toString());