Skip to content

Commit

Permalink
Bump bouncycastle jdk15on version to jdk18on 1.78.1 and associated ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
aaron-kumar committed May 19, 2024
1 parent aef528b commit 4f090e9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,22 @@
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<bouncycastle.version>1.70</bouncycastle.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<testng.version>7.7.1</testng.version>
<mockito-core.version>4.11.0</mockito-core.version>
<joda-time.version>2.12.0</joda-time.version>
<jakarta.xml.bind-api-version>2.3.3</jakarta.xml.bind-api-version>
<jaxb-impl-version>2.3.3</jaxb-impl-version>
<guava.version>31.1-jre</guava.version>
<pkix-ocsp.version>2.0.0</pkix-ocsp.version>
<pkix-ocsp.version>2.1.0</pkix-ocsp.version>
<metainf-services.version>1.9</metainf-services.version>
</properties>

<dependencies>
<!-- BouncyCastle -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import network.oxalis.commons.certvalidator.lang.ValidatorParsingException;
import org.kohsuke.MetaInfServices;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

/**
Expand All @@ -24,8 +25,8 @@ public ValidatorRule parse(Object o, Map<String, Object> objectStorage) throws V
ClassType classType = (ClassType) o;

try {
return (ValidatorRule) Class.forName(classType.getValue()).newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
return (ValidatorRule) Class.forName(classType.getValue()).getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new ValidatorParsingException(
String.format("Unable to load rule '%s'.", classType.getValue()), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.bouncycastle.asn1.x509.DistributionPoint;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.x509.extension.X509ExtensionUtil;
import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils;

import java.io.IOException;
import java.security.cert.X509CRL;
Expand Down Expand Up @@ -58,7 +58,7 @@ public static List<String> getCrlDistributionPoints(X509Certificate certificate)
if (!certificate.getNonCriticalExtensionOIDs().contains(CRL_EXTENSION))
return urls;

CRLDistPoint distPoint = CRLDistPoint.getInstance(X509ExtensionUtil.fromExtensionValue(certificate.getExtensionValue(CRL_EXTENSION)));
CRLDistPoint distPoint = CRLDistPoint.getInstance(JcaX509ExtensionUtils.parseExtensionValue(certificate.getExtensionValue(CRL_EXTENSION)));
for (DistributionPoint dp : distPoint.getDistributionPoints())
for (GeneralName name : ((GeneralNames) dp.getDistributionPoint().getName()).getNames())
if (name.getTagNo() == GeneralName.uniformResourceIdentifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class NorwegianOrganizationNumberRuleTest extends X509TestGenerator {
@Test
public void shouldExtractOrgnumberFromCertBasedOnSerialnumber() throws Exception {
final String ORGNR = "123456789";
X509Certificate cert = createX509Certificate("CN=name, OU=None, O=None L=None, C=None, serialNumber=" + ORGNR);
X509Certificate cert = createX509Certificate("CN=name, OU=None, O=None, L=None, C=None, serialNumber=" + ORGNR);

new NorwegianOrganizationNumberRule(new PrincipalNameProvider<String>() {
@Override
Expand All @@ -34,7 +34,7 @@ public boolean validate(String value) {
@Test(expectedExceptions = FailedValidationException.class)
public void invalidOrgnumberFromCertBasedOnSerialnumber() throws Exception {
final String ORGNR = "123 456 789";
X509Certificate cert = createX509Certificate("CN=name, OU=None, O=None L=None, C=None, serialNumber=" + ORGNR);
X509Certificate cert = createX509Certificate("CN=name, OU=None, O=None, L=None, C=None, serialNumber=" + ORGNR);

new NorwegianOrganizationNumberRule(new PrincipalNameProvider<String>() {
@Override
Expand Down Expand Up @@ -89,7 +89,7 @@ public boolean validate(String value) {
@Test(expectedExceptions = FailedValidationException.class)
public void notAcceptedOrgnumberFromCertBasedOnSerialnumber() throws Exception {
final String ORGNR = "123456789";
X509Certificate cert = createX509Certificate("CN=name, OU=None, O=None L=None, C=None, serialNumber=" + ORGNR);
X509Certificate cert = createX509Certificate("CN=name, OU=None, O=None, L=None, C=None, serialNumber=" + ORGNR);

new NorwegianOrganizationNumberRule(new PrincipalNameProvider<String>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class X509TestGenerator {

protected X509Certificate createX509Certificate(Date from, Date to) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, CertificateException, OperatorCreationException, CertIOException {
String domainName = "test";
return createX509Certificate(null, "CN=" + domainName + ", OU=None, O=None L=None, C=None", null, from, to);
return createX509Certificate(null, "CN=" + domainName + ", OU=None, O=None, L=None, C=None", null, from, to);
}

protected X509Certificate createX509Certificate(String subject, X509ExtensionCustom custom, Date from, Date to) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, CertificateException, OperatorCreationException, CertIOException {
Expand All @@ -48,9 +48,9 @@ protected X509Certificate createX509Certificate(X509Certificate issuer, String s
if(issuer != null)
issuerName = new X500Name(issuer.getSubjectX500Principal().getName());
else
issuerName = new X500Name("CN=" + "test" + ", OU=None, O=None L=None, C=None");
issuerName = new X500Name("CN=" + "test" + ", OU=None, O=None, L=None, C=None");

SubjectPublicKeyInfo subjPubKeyInfo = new SubjectPublicKeyInfo(ASN1Sequence.getInstance(RSAPubKey.getEncoded()));
SubjectPublicKeyInfo subjPubKeyInfo = SubjectPublicKeyInfo.getInstance((ASN1Sequence.getInstance(RSAPubKey.getEncoded())));


X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(
Expand All @@ -75,7 +75,7 @@ protected X509Certificate createX509Certificate(X509Certificate issuer, String s

protected X509Certificate createX509Certificate(X509ExtensionCustom x509ExtensionCustom) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, CertificateException, OperatorCreationException, CertIOException {
String domainName = "test";
return createX509Certificate("CN=" + domainName + ", OU=None, O=None L=None, C=None", x509ExtensionCustom, DateTime.now().minusYears(1).toDate(), DateTime.now().plusYears(1).toDate());
return createX509Certificate("CN=" + domainName + ", OU=None, O=None, L=None, C=None", x509ExtensionCustom, DateTime.now().minusYears(1).toDate(), DateTime.now().plusYears(1).toDate());
}

protected X509Certificate createX509Certificate() throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, CertificateException, OperatorCreationException, CertIOException {
Expand Down

0 comments on commit 4f090e9

Please sign in to comment.