fixed class check to avoid class cast.
@@ -60,14 +60,21 @@ public int read(byte[] b, int off, int len) throws IOException
}
else
{
- ASN1OctetStringParser aos = (ASN1OctetStringParser)_parser.readObject();
+ ASN1Encodable asn1Obj = _parser.readObject();
- if (aos == null)
+ if (asn1Obj == null)
{
_currentStream = null;
return totalRead < 1 ? -1 : totalRead;
}
+ if (!(asn1Obj instanceof ASN1OctetStringParser))
+ {
+ throw new IOException("unknown object encountered: " + asn1Obj.getClass());
+ }
+
+ ASN1OctetStringParser aos = (ASN1OctetStringParser)asn1Obj;
+
_currentStream = aos.getOctetStream();
}
}
