Don't throw IOException
@@ -258,11 +258,11 @@ public ASN1Primitive getObject()
* @param tagNo The universal {@link BERTags tag number} of the
* expected base object.
*/
- public ASN1Primitive getBaseUniversal(boolean declaredExplicit, int tagNo) throws IOException
+ public ASN1Primitive getBaseUniversal(boolean declaredExplicit, int tagNo)
{
if (tagNo < 1 || tagNo >= 0x1F)
{
- throw new IOException("unsupported tag number");
+ throw new IllegalArgumentException("unsupported tag number: " + tagNo);
}
if (declaredExplicit)
@@ -279,6 +279,8 @@ public ASN1Primitive getBaseUniversal(boolean declaredExplicit, int tagNo) throw
// Handle implicit objects generically by re-encoding with new tag
+ try
+ {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
ASN1OutputStream output = ASN1OutputStream.create(buf, getASN1Encoding());
encode(output, true, BERTags.UNIVERSAL, tagNo);
@@ -288,6 +290,11 @@ public ASN1Primitive getBaseUniversal(boolean declaredExplicit, int tagNo) throw
return ASN1Primitive.fromByteArray(encoding);
}
+ catch (IOException e)
+ {
+ throw new IllegalStateException("failed to re-tag implicit object", e);
+ }
+ }
/**
* @deprecated See {@link ASN1TaggedObjectParser#getObjectParser(int, boolean)}.
