Skip to content

Commit

Permalink
GitHub Actions: build with JDK21
Browse files Browse the repository at this point in the history
Drop build support for Java 8
  • Loading branch information
kwin committed Oct 13, 2023
1 parent 919e28a commit 9cd5f5f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
jdk: [8, 11, 17]
jdk: [11, 17, 21]
include:
# lengthy build steps should only be performed on linux with Java 17 (Sonarcloud analysis, deployment)
- os: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bouncycastle.pkcs.PKCSException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;

import biz.netcentric.cq.tools.actool.configmodel.TestDecryptionService;
import biz.netcentric.cq.tools.actool.crypto.DecryptionService;
Expand Down Expand Up @@ -65,8 +67,9 @@ public void testEncryptedPkcs8RsaKeyWithUnrelatedCertificate() throws IOExceptio
}

@Test
// https://bugs.openjdk.java.net/browse/JDK-8231581 (Java 11) or https://bugs.openjdk.java.net/browse/JDK-8076999 (Java 8)
public void testEncryptedPkcs8Pbes2RsaKeyWithCertificateOnJCASDefault() throws IOException, GeneralSecurityException, OperatorCreationException, PKCSException {
@EnabledForJreRange(max = JRE.JAVA_17)
// https://bugs.openjdk.java.net/browse/JDK-8231581 (Java 11) or https://bugs.openjdk.java.net/browse/JDK-8076999 (Java 8) but works with Java 21 (https://bugs.openjdk.org/browse/JDK-8288050)
public void testEncryptedPkcs8Pbes2RsaKeyWithCertificateOnJCASDefaultPriorJava21() throws IOException, GeneralSecurityException, OperatorCreationException, PKCSException {
try (InputStream inputPkcs8 = this.getClass().getResourceAsStream("example5_rsa_pkcs8");
InputStream inputPemCert = this.getClass().getResourceAsStream("example5_rsa.crt")) {
String privateKey = IOUtils.toString(inputPkcs8, StandardCharsets.US_ASCII);
Expand All @@ -76,6 +79,18 @@ public void testEncryptedPkcs8Pbes2RsaKeyWithCertificateOnJCASDefault() throws I
}
}

@Test
@EnabledForJreRange(min = JRE.JAVA_21)
public void testEncryptedPkcs8Pbes2RsaKeyWithCertificateOnJCASDefaultJava21() throws IOException, GeneralSecurityException, OperatorCreationException, PKCSException {
try (InputStream inputPkcs8 = this.getClass().getResourceAsStream("example5_rsa_pkcs8");
InputStream inputPemCert = this.getClass().getResourceAsStream("example5_rsa.crt")) {
String privateKey = IOUtils.toString(inputPkcs8, StandardCharsets.US_ASCII);
String certificate = IOUtils.toString(inputPemCert, StandardCharsets.US_ASCII);
Key key = Key.createFromPrivateKeyAndCertificate(descryptionService, privateKey, "{password}", certificate, privateKeyDecryptor);
key.getKeyPair();
}
}

@Test
public void testEncryptedPkcs8Pbes2RsaKeyWithCertificateAndBouncycastle() throws IOException, GeneralSecurityException, OperatorCreationException, PKCSException {
privateKeyDecryptor = new BouncycastlePkcs8EncryptedPrivateKeyDecryptor();
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ AEMs Crypto Support provides a 128 bit AES encryption which is stronger than the

To encrypt an unencrypted PKCS#8 private key (in PEM format) you can use the command
`openssl pkcs8 -topk8 -in <unencrypted-private-key-file> -out <encrypted-private-key-file>`. It will ask you for the password interactively.
By default this will use the unsafe `PbeWithMD5AndDES-CBC` algorithm (with 56 bit key). You should consider using more secure algorithms with parameter `v2`, those are only supported with [Bouncy Castle][bouncycastle], though. For more details refer also to [RFC 8018](https://tools.ietf.org/html/rfc8018#appendix-B.2)
By default this will use the unsafe `PbeWithMD5AndDES-CBC` algorithm (with 56 bit key). You should consider using more secure algorithms with parameter `v2`, those are only supported with [Bouncy Castle][bouncycastle] or [Java 21+](https://bugs.openjdk.org/browse/JDK-8288050), though. For more details refer also to [RFC 8018](https://tools.ietf.org/html/rfc8018#appendix-B.2)

### Install Bouncy Castle

Expand Down
62 changes: 4 additions & 58 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@
<slf4j.version>1.7.25</slf4j.version>
<bnd.version>6.3.1</bnd.version>
<bouncycastle.version>1.64</bouncycastle.version>
<java.target.version>8</java.target.version>
<!-- release sets API classpath, source and target, see https://docs.oracle.com/javase/9/tools/javac.htm#GUID-AEEC9F07-CB49-4E96-8BC7-BCC2C7F725C9__GUID-D343F6B4-3FDD-43A8-AD24-43DD70214471 and http://openjdk.java.net/jeps/247 -->
<maven.compiler.release>8</maven.compiler.release>
<mockito.version>4.8.0</mockito.version>
<junit.version>5.9.0</junit.version>
<junit.version>5.10.0</junit.version>
</properties>

<modules>
Expand Down Expand Up @@ -296,11 +297,6 @@
<password>${crx.password}</password>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.21</version>
</plugin>
<!-- for building content packages -->
<plugin>
<groupId>org.apache.jackrabbit</groupId>
Expand Down Expand Up @@ -457,10 +453,7 @@
<version>3.6.1</version>
</requireMavenVersion>
<requireJavaVersion>
<version>1.8.0</version>
<message>Bnd requires Java 8
(https://github.com/bndtools/bnd/wiki/Changes-in-4.0.0)
</message>
<version>${maven.compiler.release}</version>
</requireJavaVersion>
</rules>
</configuration>
Expand All @@ -484,53 +477,6 @@
</build>

<profiles>
<profile>
<id>jdk8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<!-- this affects m-compiler-p and m-javadoc-p -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
<version>1.0</version>
</signature>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk9-or-higher</id>
<activation>
<!-- syntax according to http://maven.apache.org/enforcer/enforcer-rules/versionRanges.html -->
<jdk>[9,)</jdk>
</activation>
<properties>
<!--
release sets API classpath, source and target, see
https://docs.oracle.com/javase/9/tools/javac.htm#GUID-AEEC9F07-CB49-4E96-8BC7-BCC2C7F725C9__GUID-D343F6B4-3FDD-43A8-AD24-43DD70214471
and http://openjdk.java.net/jeps/247 -->
<maven.compiler.release>${java.target.version}</maven.compiler.release>
</properties>
</profile>
<profile>
<id>release</id>
<build>
Expand Down

0 comments on commit 9cd5f5f

Please sign in to comment.