Skip to content

Commit 53b6ff7

Browse files
committed
more cleanup - avoid deprecated ASN1 classes
1 parent 6dbd7cc commit 53b6ff7

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/main/java/org/jruby/ext/openssl/ASN1.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,18 @@ private static Map<ASN1ObjectIdentifier, String> getSymLookup(final Ruby runtime
521521

522522
private final static Object[][] ASN1_INFO = {
523523
{ "EOC", null, "EndOfContent" }, // OpenSSL::ASN1::EOC (0)
524-
{ "BOOLEAN", org.bouncycastle.asn1.DERBoolean.class, "Boolean" },
525-
{ "INTEGER", org.bouncycastle.asn1.DERInteger.class, "Integer" },
524+
{ "BOOLEAN", org.bouncycastle.asn1.ASN1Boolean.class, "Boolean" },
525+
{ "INTEGER", org.bouncycastle.asn1.ASN1Integer.class, "Integer" },
526526
{ "BIT_STRING", org.bouncycastle.asn1.DERBitString.class, "BitString" },
527527
{ "OCTET_STRING", org.bouncycastle.asn1.DEROctetString.class, "OctetString" },
528528
{ "NULL", org.bouncycastle.asn1.DERNull.class, "Null" },
529529
// OpenSSL::ASN1::OBJECT (6) :
530-
{ "OBJECT", org.bouncycastle.asn1.DERObjectIdentifier.class, "ObjectId" },
530+
{ "OBJECT", org.bouncycastle.asn1.ASN1ObjectIdentifier.class, "ObjectId" },
531531
{ "OBJECT_DESCRIPTOR", null, null },
532532
{ "EXTERNAL", null, null },
533533
{ "REAL", null, null },
534534
// OpenSSL::ASN1::ENUMERATED (10) :
535-
{ "ENUMERATED", org.bouncycastle.asn1.DEREnumerated.class, "Enumerated" },
535+
{ "ENUMERATED", org.bouncycastle.asn1.ASN1Enumerated.class, "Enumerated" },
536536
{ "EMBEDDED_PDV", null, null },
537537
// OpenSSL::ASN1::UTF8STRING (12) :
538538
{ "UTF8STRING", org.bouncycastle.asn1.DERUTF8String.class, "UTF8String" },
@@ -1589,19 +1589,16 @@ ASN1Encodable toASN1(final ThreadContext context) {
15891589
}
15901590
}
15911591

1592-
final IRubyObject val = callMethod(context, "value");
1593-
if ( type == ASN1ObjectIdentifier.class || type == DERObjectIdentifier.class ) {
1592+
final IRubyObject val = value(context);
1593+
if ( type == ASN1ObjectIdentifier.class ) {
15941594
return getObjectID(context.runtime, val.toString());
15951595
}
15961596
if ( type == DERNull.class || type == ASN1Null.class ) {
15971597
return DERNull.INSTANCE;
15981598
}
1599-
if ( ASN1Boolean.class.isAssignableFrom( type ) ) {
1599+
if ( ASN1Boolean.class.isAssignableFrom(type) ) {
16001600
return ASN1Boolean.getInstance(val.isTrue());
16011601
}
1602-
if ( type == DERBoolean.class ) {
1603-
return DERBoolean.getInstance(val.isTrue());
1604-
}
16051602
if ( type == DERUTCTime.class ) {
16061603
if ( val instanceof RubyTime ) {
16071604
return new DERUTCTime(((RubyTime) val).getJavaDate());
@@ -1614,20 +1611,13 @@ ASN1Encodable toASN1(final ThreadContext context) {
16141611
}
16151612
return DERGeneralizedTime.getInstance( val.asString().getBytes() );
16161613
}
1617-
if ( type == DERInteger.class ) {
1618-
return new DERInteger( bigIntegerValue(val) );
1619-
}
1620-
if ( ASN1Integer.class.isAssignableFrom( type ) ) {
1614+
if ( ASN1Integer.class.isAssignableFrom(type) ) {
16211615
return new ASN1Integer( bigIntegerValue(val) );
16221616
}
1623-
if ( type == DEREnumerated.class ) {
1624-
return new DEREnumerated( bigIntegerValue(val) );
1625-
}
1626-
if ( type == ASN1Enumerated.class ) {
1617+
if ( ASN1Enumerated.class.isAssignableFrom(type) ) {
16271618
return new ASN1Enumerated( bigIntegerValue(val) );
16281619
}
1629-
//if ( type == DEROctetString.class ) {
1630-
if ( ASN1OctetString.class.isAssignableFrom( type ) ) {
1620+
if ( ASN1OctetString.class.isAssignableFrom(type) ) {
16311621
return new DEROctetString( val.asString().getBytes() );
16321622
}
16331623
if ( type == DERBitString.class ) {

0 commit comments

Comments
 (0)