Wrappers for getBaseUniversal
@@ -61,6 +61,42 @@ public static ASN1TaggedObject tryGetExplicitContextBaseTagged(ASN1TaggedObject
return tryGetExplicitBaseTagged(taggedObject, BERTags.CONTEXT_SPECIFIC, tagNo);
}
+ public static ASN1Primitive getBaseUniversal(ASN1TaggedObject taggedObject, int tagClass, int tagNo,
+ boolean declaredExplicit, int baseTagNo)
+ {
+ if (!taggedObject.hasTag(tagClass, tagNo))
+ {
+ String expected = getTagText(tagClass, tagNo);
+ String found = getTagText(taggedObject);
+ throw new IllegalStateException("Expected " + expected + " tag but found " + found);
+ }
+
+ return taggedObject.getBaseUniversal(declaredExplicit, baseTagNo);
+ }
+
+ public static ASN1Primitive getContextBaseUniversal(ASN1TaggedObject taggedObject, int tagNo,
+ boolean declaredExplicit, int baseTagNo)
+ {
+ return getBaseUniversal(taggedObject, BERTags.CONTEXT_SPECIFIC, tagNo, declaredExplicit, baseTagNo);
+ }
+
+ public static ASN1Primitive tryGetBaseUniversal(ASN1TaggedObject taggedObject, int tagClass, int tagNo,
+ boolean declaredExplicit, int baseTagNo)
+ {
+ if (!taggedObject.hasTag(tagClass, tagNo))
+ {
+ return null;
+ }
+
+ return taggedObject.getBaseUniversal(declaredExplicit, baseTagNo);
+ }
+
+ public static ASN1Primitive tryGetContextBaseUniversal(ASN1TaggedObject taggedObject, int tagNo,
+ boolean declaredExplicit, int baseTagNo)
+ {
+ return tryGetBaseUniversal(taggedObject, BERTags.CONTEXT_SPECIFIC, tagNo, declaredExplicit, baseTagNo);
+ }
+
// public static ASN1Encodable parseBaseObject(ASN1TaggedObjectParser taggedObjectParser, int tagClass, int tagNo,
// boolean declaredExplicit, int baseTagClass, int baseTagNo, boolean baseDeclaredExplicit) throws IOException
// {
