Skip to content

Commit

Permalink
unify how taggedobjects get decoded
Browse files Browse the repository at this point in the history
  • Loading branch information
HoneyryderChuck committed May 15, 2024
1 parent aa03671 commit 524245a
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/main/java/org/jruby/ext/openssl/ASN1.java
Original file line number Diff line number Diff line change
Expand Up @@ -1063,20 +1063,14 @@ else if ( obj instanceof ASN1GraphicString ) {
break;
}

if (taggedObj.getTagClass() == BERTags.APPLICATION) {
try {
final ASN1Sequence sequence = (ASN1Sequence) taggedObj.getBaseUniversal(false, SEQUENCE);
@SuppressWarnings("unchecked")
final RubyArray valArr = decodeObjects(context, ASN1, sequence.getObjects());
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
} catch (IllegalStateException e) {
IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject()).callMethod(context, "value");
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { val, tag, tag_class }, Block.NULL_BLOCK);
}
} else {
IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject());
final RubyArray valArr = runtime.newArray(val);
try {
final ASN1Sequence sequence = (ASN1Sequence) taggedObj.getBaseUniversal(false, SEQUENCE);
@SuppressWarnings("unchecked")
final RubyArray valArr = decodeObjects(context, ASN1, sequence.getObjects());
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
} catch (IllegalStateException e) {
IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject()).callMethod(context, "value");
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { val, tag, tag_class }, Block.NULL_BLOCK);
}
}

Expand Down

0 comments on commit 524245a

Please sign in to comment.