Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] replace methods removed in BC 1.75 #286

Merged
merged 4 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions src/main/java/org/jruby/ext/openssl/ASN1.java
Original file line number Diff line number Diff line change
Expand Up @@ -1072,23 +1072,22 @@ else if ( obj instanceof DERBMPString ) {
return ASN1.getClass("ObjectId").newInstance(context, runtime.newString(objId), Block.NULL_BLOCK);
}

if ( obj instanceof ASN1ApplicationSpecific ) { // TODO this will likely break in BC version > 1.71
final ASN1ApplicationSpecific appSpecific = (ASN1ApplicationSpecific) obj;
IRubyObject tag = runtime.newFixnum( appSpecific.getApplicationTag() );
IRubyObject tag_class = runtime.newSymbol("APPLICATION");
final ASN1Sequence sequence = (ASN1Sequence) appSpecific.getObject(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);
}

if ( obj instanceof ASN1TaggedObject ) {
if (obj instanceof ASN1TaggedObject) {
justinstoller marked this conversation as resolved.
Show resolved Hide resolved
final ASN1TaggedObject taggedObj = (ASN1TaggedObject) obj;
IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject());
IRubyObject tag = runtime.newFixnum( taggedObj.getTagNo() );
IRubyObject tag_class = runtime.newSymbol("CONTEXT_SPECIFIC");
final RubyArray valArr = runtime.newArray(val);
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
if (taggedObj.getTagClass() == BERTags.APPLICATION) {
IRubyObject tag = runtime.newFixnum( taggedObj.getTagNo() );
IRubyObject tag_class = runtime.newSymbol("APPLICATION");
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);
} else {
IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject());
IRubyObject tag = runtime.newFixnum( taggedObj.getTagNo() );
IRubyObject tag_class = runtime.newSymbol("CONTEXT_SPECIFIC");
final RubyArray valArr = runtime.newArray(val);
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
}
}

if ( obj instanceof ASN1Sequence ) {
Expand Down Expand Up @@ -1698,13 +1697,13 @@ ASN1Encodable toASN1(final ThreadContext context) {
}

if ( type == DERGeneralString.class ) {
return DERGeneralString.getInstance( val.asString().getBytes() );
return ASN1GeneralString.getInstance( val.asString().getBytes() );
}
if ( type == DERVisibleString.class ) {
return DERVisibleString.getInstance( val.asString().getBytes() );
return ASN1VisibleString.getInstance( val.asString().getBytes() );
}
if ( type == DERNumericString.class ) {
return DERNumericString.getInstance( val.asString().getBytes() );
return ASN1NumericString.getInstance( val.asString().getBytes() );
}

if ( val instanceof RubyString ) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jruby/ext/openssl/X509Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Encoding;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1IA5String;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
Expand All @@ -46,7 +47,6 @@
import org.bouncycastle.asn1.ASN1String;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.BERTags;
import org.bouncycastle.asn1.DERIA5String;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERUniversalString;
import org.bouncycastle.asn1.DLSequence;
Expand Down Expand Up @@ -620,7 +620,7 @@ private static boolean formatGeneralName(final GeneralName name, final ByteList
case GeneralName.uniformResourceIdentifier:
if ( ! tagged ) out.append('U').append('R').append('I').
append(':');
val = DERIA5String.getInstance(obj).getString();
val = ASN1IA5String.getInstance(obj).getString();
out.append( ByteList.plain(val) );
break;
case GeneralName.directoryName:
Expand Down
Loading
Loading