private Certificate readPKCS7Certificate(
InputStream in)
throws IOException
{
BERInputStream dIn = new BERInputStream(in);
ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
if (seq.size() > 1
&& seq.getObjectAt(0) instanceof DERObjectIdentifier)
{
if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
{
sData = new SignedData(ASN1Sequence.getInstance(
(ASN1TaggedObject)seq.getObjectAt(1), true));
return new X509CertificateObject(
X509CertificateStructure.getInstance(
sData.getCertificates().getObjectAt(sDataObjectCount++)));
}