Skip to content

Commit 9173da0

Browse files
committed
[refactor] due tests to pass on JRuby 9.4.6.0
which has default package access restrictions
1 parent a69371b commit 9173da0

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/main/java/org/jruby/ext/openssl/impl/ASN1Registry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,19 @@ public static String o2a(final ASN1ObjectIdentifier oid) {
6262
return o2a( oid.getId() );
6363
}
6464

65-
//@Deprecated
6665
public static ASN1ObjectIdentifier sym2oid(final String name) {
6766
final String oid = SYM_TO_OID.get( name.toLowerCase() );
6867
return oid == null ? null : new ASN1ObjectIdentifier( oid );
6968
}
7069

71-
public static String name2oid(final String name) {
70+
static String name2oid(final String name) {
7271
return SYM_TO_OID.get( name.toLowerCase() );
7372
}
7473

7574
public static Map<String, String> getOIDLookup() { return SYM_TO_OID; }
7675

7776
static ASN1ObjectIdentifier nid2obj(int nid) {
78-
return new ASN1ObjectIdentifier( NID_TO_OID[ nid ] );
77+
return new ASN1ObjectIdentifier(nid2oid(nid));
7978
}
8079

8180
public static String nid2oid(int nid) {

src/test/ruby/pkcs7/test_pkcs7.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def test_add_signer_to_signed_and_enveloped_should_add_that_to_stack
404404
BIG_ONE = BigInteger::ONE.to_java
405405

406406
def create_signer_info_with_algo(algo)
407-
md5 = AlgorithmIdentifier.new(ASN1Registry.nid2obj(4))
407+
md5 = algorithm_identifier(4)
408408
org.jruby.ext.openssl.impl.SignerInfoWithPkey.new(
409409
org.bouncycastle.asn1.ASN1Integer.new(BIG_ONE),
410410
org.bouncycastle.asn1.pkcs.IssuerAndSerialNumber.new(org.bouncycastle.asn1.x500.X500Name.new("C=SE"), BIG_ONE),
@@ -421,8 +421,8 @@ def test_add_signer_to_signed_with_new_algo_should_add_that_algo_to_the_algo_lis
421421
p7.type = ASN1Registry::NID_pkcs7_signed
422422

423423
# YES, these numbers are correct. Don't change them. They are OpenSSL internal NIDs
424-
md5 = AlgorithmIdentifier.new(ASN1Registry.nid2obj(4))
425-
md4 = AlgorithmIdentifier.new(ASN1Registry.nid2obj(5))
424+
md5 = algorithm_identifier(4)
425+
md4 = algorithm_identifier(5)
426426

427427
si = create_signer_info_with_algo(md5)
428428
p7.add_signer(si)
@@ -450,8 +450,8 @@ def test_add_signer_to_signed_and_enveloped_with_new_algo_should_add_that_algo_t
450450
p7.type = ASN1Registry::NID_pkcs7_signedAndEnveloped
451451

452452
# YES, these numbers are correct. Don't change them. They are OpenSSL internal NIDs
453-
md5 = AlgorithmIdentifier.new(ASN1Registry.nid2obj(4))
454-
md4 = AlgorithmIdentifier.new(ASN1Registry.nid2obj(5))
453+
md5 = algorithm_identifier(4)
454+
md4 = algorithm_identifier(5)
455455

456456
si = create_signer_info_with_algo(md5)
457457
p7.add_signer(si)
@@ -473,6 +473,13 @@ def test_add_signer_to_signed_and_enveloped_with_new_algo_should_add_that_algo_t
473473
assert p7.get_signed_and_enveloped.md_algs.contains(md5)
474474
end
475475

476+
def algorithm_identifier(nid)
477+
oid = ASN1Registry.nid2oid(nid)
478+
raise "oid for #{nid.inspect} not found!" unless oid
479+
AlgorithmIdentifier.new(org.bouncycastle.asn1.ASN1ObjectIdentifier.new(oid))
480+
end
481+
private :algorithm_identifier
482+
476483
def test_set_content_on_data_throws_exception
477484
p7 = PKCS7.new
478485
p7.type = ASN1Registry::NID_pkcs7_data

0 commit comments

Comments
 (0)