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 a4a3ecf
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 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,21 +1063,18 @@ 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());
System.out.println("arrayig");
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
} catch (IllegalStateException e) {
System.out.println("rolled over");
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);
}

}

if ( obj instanceof ASN1Sequence ) {
Expand Down

0 comments on commit a4a3ecf

Please sign in to comment.