Skip to content

Commit 4fe6324

Browse files
authored
Merge pull request #20 from nats-io/regular-lts-1
Regular and LTS WIP, FIPS scaffolding
2 parents 2959973 + f48760d commit 4fe6324

File tree

14 files changed

+284
-35
lines changed

14 files changed

+284
-35
lines changed

.github/workflows/lts-main.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Lts Main Snapshot
2+
permissions:
3+
contents: read
4+
on:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'lts/**'
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
tc: [ 17, 21, 25 ]
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ./lts
20+
env:
21+
BUILD_EVENT: ${{ github.event_name }}
22+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
23+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
24+
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
25+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
26+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
27+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
28+
steps:
29+
- name: Set up JDK
30+
uses: actions/setup-java@v5
31+
with:
32+
java-version: 25
33+
distribution: 'temurin'
34+
- name: Setup Gradle
35+
uses: gradle/actions/setup-gradle@v5
36+
with:
37+
gradle-version: current
38+
- name: Check out code
39+
uses: actions/checkout@v4
40+
- name: Build and Test
41+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
42+
- name: Verify Javadoc
43+
run: ./gradlew javadoc
44+
- name: Publish Snapshot
45+
run: ./gradlew -i publishToSonatype

.github/workflows/lts-pr.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Lts Pull Request
2+
permissions:
3+
contents: read
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
paths:
8+
- 'lts/**'
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
tc: [ 17, 21, 25 ]
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: ./lts
19+
env:
20+
BUILD_EVENT: ${{ github.event_name }}
21+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
22+
steps:
23+
- name: Set up JDK
24+
uses: actions/setup-java@v5
25+
with:
26+
java-version: 25
27+
distribution: 'temurin'
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v5
30+
with:
31+
gradle-version: current
32+
- name: Check out code
33+
uses: actions/checkout@v4
34+
- name: Build and Test
35+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
36+
- name: Verify Javadoc
37+
run: ./gradlew javadoc

.github/workflows/lts-release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Lts Publish Release
2+
permissions:
3+
contents: read
4+
on:
5+
push:
6+
tags: [ 'lts/*' ]
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
tc: [ 17, 21, 25 ]
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ./lts
17+
env:
18+
BUILD_EVENT: "release"
19+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
20+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
21+
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
22+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
23+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
24+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
25+
steps:
26+
- name: Set up JDK
27+
uses: actions/setup-java@v5
28+
with:
29+
java-version: 25
30+
distribution: 'temurin'
31+
- name: Setup Gradle
32+
uses: gradle/actions/setup-gradle@v5
33+
with:
34+
gradle-version: current
35+
- name: Check out code
36+
uses: actions/checkout@v4
37+
- name: Build, Sign and Publish Release
38+
run: chmod +x gradlew && ./gradlew clean compileJava publishToSonatype closeAndReleaseSonatypeStagingRepository

.github/workflows/regular-main.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Regular Main Snapshot
2+
permissions:
3+
contents: read
4+
on:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'regular/**'
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
tc: [ 17, 21, 25 ]
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: ./regular
20+
env:
21+
BUILD_EVENT: ${{ github.event_name }}
22+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
23+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
24+
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
25+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
26+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
27+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
28+
steps:
29+
- name: Set up JDK
30+
uses: actions/setup-java@v5
31+
with:
32+
java-version: 25
33+
distribution: 'temurin'
34+
- name: Setup Gradle
35+
uses: gradle/actions/setup-gradle@v5
36+
with:
37+
gradle-version: current
38+
- name: Check out code
39+
uses: actions/checkout@v4
40+
- name: Build and Test
41+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
42+
- name: Verify Javadoc
43+
run: ./gradlew javadoc
44+
- name: Publish Snapshot
45+
run: ./gradlew -i publishToSonatype

.github/workflows/regular-pr.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Regular Pull Request
2+
permissions:
3+
contents: read
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
paths:
8+
- 'regular/**'
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
tc: [ 17, 21, 25 ]
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: ./regular
19+
env:
20+
BUILD_EVENT: ${{ github.event_name }}
21+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
22+
steps:
23+
- name: Set up JDK
24+
uses: actions/setup-java@v5
25+
with:
26+
java-version: 25
27+
distribution: 'temurin'
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v5
30+
with:
31+
gradle-version: current
32+
- name: Check out code
33+
uses: actions/checkout@v4
34+
- name: Build and Test
35+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
36+
- name: Verify Javadoc
37+
run: ./gradlew javadoc
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Regular Publish Release
2+
permissions:
3+
contents: read
4+
on:
5+
push:
6+
tags: [ 'regular/*' ]
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
tc: [ 17, 21, 25 ]
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ./regular
17+
env:
18+
BUILD_EVENT: "release"
19+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
20+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
21+
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
22+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
23+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
24+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
25+
steps:
26+
- name: Set up JDK
27+
uses: actions/setup-java@v5
28+
with:
29+
java-version: 25
30+
distribution: 'temurin'
31+
- name: Setup Gradle
32+
uses: gradle/actions/setup-gradle@v5
33+
with:
34+
gradle-version: current
35+
- name: Check out code
36+
uses: actions/checkout@v4
37+
- name: Build, Sign and Publish Release
38+
run: chmod +x gradlew && ./gradlew clean compileJava publishToSonatype closeAndReleaseSonatypeStagingRepository

fips/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ plugins {
1010
id("signing")
1111
}
1212

13-
def jarVersion = "3.0.0"
13+
def jarVersion = "3.0.1"
1414
group = 'io.nats.nkeys'
1515

1616
def isRelease = System.getenv("BUILD_EVENT") == "release"
1717
def tc = System.getenv("TARGET_COMPATIBILITY")
18-
def targetJavaVersion = tc == null ? JavaVersion.VERSION_1_8 : JavaVersion.toVersion(tc)
18+
def targetJavaVersion = tc == null ? JavaVersion.VERSION_17 : JavaVersion.toVersion(tc)
1919
def targetId = targetJavaVersion.toString()
20-
def artifact = "fips" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : "-jdk" + targetId)
21-
def bundleName = "io.nats.nkeys.fips" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : ".jdk" + targetId)
20+
def artifact = "fips-jdk" + targetId
21+
def bundleName = "io.nats.nkeys.fips.jdk" + targetId
22+
def coreName = "core-jdk" + targetId
2223

2324
System.out.println("targetCompatibility: " + targetId)
2425
System.out.println("artifact: " + artifact)
26+
System.out.println("core: " + coreName)
2527
System.out.println("bundleName: " + bundleName)
2628

2729
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT" // version is the variable the gradle uses.
2830

2931
java {
30-
sourceCompatibility = JavaVersion.VERSION_1_8
32+
sourceCompatibility = JavaVersion.VERSION_17
3133
targetCompatibility = targetJavaVersion
3234
withSourcesJar()
3335
withJavadocJar()
@@ -41,7 +43,7 @@ repositories {
4143
}
4244

4345
dependencies {
44-
implementation 'io.nats.nkeys:core:3.0.0-SNAPSHOT'
46+
implementation 'io.nats.nkeys:' + coreName + ':3.0.1'
4547
implementation 'org.bouncycastle:bc-fips:2.1.2'
4648
implementation 'org.jspecify:jspecify:1.0.0'
4749

fips/src/main/java/io/nats/nkey/FipsNKeyProvider.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
44
import org.jspecify.annotations.NullMarked;
5-
import sun.security.jca.JCAUtil;
65

7-
import java.security.KeyPair;
8-
import java.security.Security;
6+
import java.security.*;
97

108
@NullMarked
119
public class FipsNKeyProvider extends NKeyProvider {
@@ -15,14 +13,19 @@ public class FipsNKeyProvider extends NKeyProvider {
1513
}
1614

1715
public FipsNKeyProvider() {
18-
setSecureRandom(JCAUtil.getDefSecureRandom());
16+
try {
17+
setSecureRandom(SecureRandom.getInstance("DEFAULT", "BCFIPS"));
18+
}
19+
catch (NoSuchAlgorithmException | NoSuchProviderException e) {
20+
throw new RuntimeException(e);
21+
}
1922
}
2023

2124
/**
2225
* {@inheritDoc}
2326
*/
2427
@Override
25-
public NKey createPair(NKeyType type, byte[] seed) {
28+
public NKey createNKey(NKeyType type, byte[] seed) {
2629
throw new UnsupportedOperationException("createPair not supported yet.");
2730
}
2831

@@ -31,6 +34,7 @@ public NKey createPair(NKeyType type, byte[] seed) {
3134
*/
3235
@Override
3336
public KeyPair getKeyPair(NKey nkey) {
37+
nkey.ensurePair();
3438
throw new UnsupportedOperationException("getKeyPair not supported yet.");
3539
}
3640

lts/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ plugins {
1010
id("signing")
1111
}
1212

13-
def jarVersion = "3.0.0"
13+
def jarVersion = "3.0.1"
1414
group = 'io.nats.nkeys'
1515

1616
def isRelease = System.getenv("BUILD_EVENT") == "release"
1717
def tc = System.getenv("TARGET_COMPATIBILITY")
18-
def targetJavaVersion = tc == null ? JavaVersion.VERSION_1_8 : JavaVersion.toVersion(tc)
18+
def targetJavaVersion = tc == null ? JavaVersion.VERSION_17 : JavaVersion.toVersion(tc)
1919
def targetId = targetJavaVersion.toString()
20-
def artifact = "lts" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : "-jdk" + targetId)
21-
def bundleName = "io.nats.nkeys.lts" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : ".jdk" + targetId)
20+
def artifact = "lts-jdk" + targetId
21+
def bundleName = "io.nats.nkeys.lts.jdk" + targetId
22+
def coreName = "core-jdk" + targetId
2223

2324
System.out.println("targetCompatibility: " + targetId)
2425
System.out.println("artifact: " + artifact)
26+
System.out.println("core: " + coreName)
2527
System.out.println("bundleName: " + bundleName)
2628

2729
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT" // version is the variable the gradle uses.
2830

2931
java {
30-
sourceCompatibility = JavaVersion.VERSION_1_8
32+
sourceCompatibility = JavaVersion.VERSION_17
3133
targetCompatibility = targetJavaVersion
3234
withSourcesJar()
3335
withJavadocJar()
@@ -41,7 +43,7 @@ repositories {
4143
}
4244

4345
dependencies {
44-
implementation 'io.nats.nkeys:core:3.0.0-SNAPSHOT'
46+
implementation 'io.nats.nkeys:' + coreName + ':3.0.1'
4547
implementation 'org.bouncycastle:bcprov-lts8on:2.73.10'
4648
implementation 'org.jspecify:jspecify:1.0.0'
4749

lts/src/main/java/io/nats/nkey/LtsNKeyProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class LtsNKeyProvider extends NKeyProvider {
1919
* {@inheritDoc}
2020
*/
2121
@Override
22-
public NKey createPair(NKeyType type, byte[] seed) {
22+
public NKey createNKey(NKeyType type, byte[] seed) {
2323
Ed25519PrivateKeyParameters privateKey = new Ed25519PrivateKeyParameters(seed);
2424
Ed25519PublicKeyParameters publicKey = privateKey.generatePublicKey();
2525

@@ -38,6 +38,7 @@ public NKey createPair(NKeyType type, byte[] seed) {
3838
*/
3939
@Override
4040
public KeyPair getKeyPair(NKey nkey) {
41+
nkey.ensurePair();
4142
NKeyDecodedSeed decoded = nkey.getDecodedSeed();
4243
byte[] seedBytes = new byte[ED25519_SEED_SIZE];
4344
byte[] pubBytes = new byte[ED25519_PUBLIC_KEYSIZE];

0 commit comments

Comments
 (0)