-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
kafka-client/src/main/resources/responsive-license-keys/keys/license-signing-key-0.pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA37LvpjgfWmlVAY/wefQ+ | ||
2cL79J7UNJePfsQWjzMc4p8ITBcTGpX/RalhdLJQjbD/SJymAOEfy56RHbuG8vS0 | ||
u79as6yhby8NWFaT1vNsYKOLfoUwqxi49TvxzXkBwdrLPXLbgIW7TNQpYIyM17Tl | ||
tuceASZJGY7dECzeZY303XsmXgsLjaNHqdLlxtdzl8i8i/diqK8/I6oKL0/AsIaC | ||
ZPfuPdQebtko4eE6p4pKjNu3qxNNdV73nV2WwHHMCE/U4CiTbH1nvpSVgr8sLBcW | ||
EtbjDwJi+wp3OX5vblWHskLJDjdjAGbNH89UYyaWTV6C58dTGH4zmffw649Ib+80 | ||
ywB8uH8IuoAJMXgECDT5XygXX2362z8MI4apMV6ouT90KyvamIVXLV1VpNyTn9ZY | ||
AYXkZxImUujhB89Lz/b5ctK/epzi+5/ZDQyrgNaPCwFoPnE/QLeuHmrT2gM381S8 | ||
3Y7fJmAa7sSRF0aPvTDM7hfmP2TRA29106qrEqPh2EX64mqoKCMkM6ZngCpiJgFZ | ||
usvCRRUdBHnXKfyqFux6TBOVrKGrahJVLgkKMaFXma0U+peuXHSE1sktjtb2zUP9 | ||
kqP1bwBtPD43epWPnVxWBqIcXD3poLBu+Hj8lVBV+NQ+XtTPzWmcD8+MSC0zzCUK | ||
umd9JPEA9pzJAqlpRYTEGaUCAwEAAQ== | ||
-----END PUBLIC KEY----- |
10 changes: 9 additions & 1 deletion
10
kafka-client/src/main/resources/responsive-license-keys/license-keys.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
{"keys": []} | ||
{ | ||
"keys": [ | ||
{ | ||
"type": "RSA_4096", | ||
"keyId": "license-signing-key-0", | ||
"path": "/responsive-license-keys/keys/license-signing-key-0.pem" | ||
} | ||
] | ||
} |
60 changes: 60 additions & 0 deletions
60
kafka-client/src/test/java/dev/responsive/kafka/internal/utils/GenerateTrialLicense.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package dev.responsive.kafka.internal.utils; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import dev.responsive.kafka.internal.license.model.LicenseDocumentV1; | ||
import dev.responsive.kafka.internal.license.model.TimedTrialV1; | ||
import java.io.IOException; | ||
import java.time.Instant; | ||
import java.util.Base64; | ||
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; | ||
import software.amazon.awssdk.core.SdkBytes; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.kms.KmsClient; | ||
import software.amazon.awssdk.services.kms.model.MessageType; | ||
import software.amazon.awssdk.services.kms.model.SignRequest; | ||
import software.amazon.awssdk.services.kms.model.SignResponse; | ||
import software.amazon.awssdk.services.kms.model.SigningAlgorithmSpec; | ||
|
||
public class GenerateTrialLicense { | ||
private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
private static final String SIGNING_KEY_ARN = System.getenv("SIGNING_KEY_ARN"); | ||
private static final String SIGNING_KEY_ID = System.getenv("SIGNING_KEY_ID"); | ||
private static final String AWS_PROFILE = System.getenv("AWS_PROFILE"); | ||
private static final String SIGNING_ALGO = "RSASSA_PSS_SHA_256"; | ||
|
||
public static void main(final String[] args) throws IOException { | ||
final var info = new TimedTrialV1( | ||
"timed_trial_v1", | ||
"[email protected]", | ||
Instant.now().getEpochSecond(), | ||
Instant.MAX.getEpochSecond() | ||
); | ||
final byte[] serialized = MAPPER.writeValueAsBytes(info); | ||
final Region region = Region.US_WEST_2; | ||
final byte[] signature; | ||
try (final KmsClient kmsClient = KmsClient.builder() | ||
.credentialsProvider(ProfileCredentialsProvider.create(AWS_PROFILE)) | ||
.region(region) | ||
.build() | ||
) { | ||
final SdkBytes sdkBytes = SdkBytes.fromByteArray(serialized); | ||
final SignRequest signRequest = SignRequest.builder() | ||
.keyId(SIGNING_KEY_ARN) | ||
.message(sdkBytes) | ||
.messageType(MessageType.RAW) | ||
.signingAlgorithm(SigningAlgorithmSpec.RSASSA_PSS_SHA_256) | ||
.build(); | ||
final SignResponse signResponse = kmsClient.sign(signRequest); | ||
final SdkBytes sdkSignature = signResponse.signature(); | ||
signature = sdkSignature.asByteArray(); | ||
} | ||
final LicenseDocumentV1 license = new LicenseDocumentV1( | ||
"1", | ||
Base64.getEncoder().encodeToString(serialized), | ||
Base64.getEncoder().encodeToString(signature), | ||
SIGNING_KEY_ID, | ||
SIGNING_ALGO | ||
); | ||
System.out.println(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(license)); | ||
} | ||
} |