Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,6 @@
.build());
}

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
@Consume(ConfigBuildItem.class)
@Consume(CryptoProviderInitBuildItem.class) // ensures the Providers are loaded prior to handle the keystore #49359
void configureTruststore(KeycloakRecorder recorder) {
recorder.configureTruststore(getFipsMode());
}

/**
* Check whether JDBC driver is present for the specified DB
*
Expand Down Expand Up @@ -374,7 +366,7 @@
logger.infof("Multiple datasources are specified: %s", String.join(", ", datasources));
}

if (transactionManagerConfig.unsafeMultipleLastResources()

Check warning on line 369 in quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java

View workflow job for this annotation

GitHub Actions / Quarkus UT (ubuntu-latest)

unsafeMultipleLastResources() in io.quarkus.narayana.jta.runtime.TransactionManagerBuildTimeConfig has been deprecated and marked for removal
.orElse(UnsafeMultipleLastResourcesMode.DEFAULT) != UnsafeMultipleLastResourcesMode.FAIL) {
return;
}
Expand Down Expand Up @@ -907,8 +899,10 @@
@Produce(CryptoProviderInitBuildItem.class)
@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void setCryptoProvider(KeycloakRecorder recorder) {
recorder.setCryptoProvider(getFipsMode());
void initCrypto(KeycloakRecorder recorder) {
FipsMode fipsMode = getFipsMode();
recorder.setCryptoProvider(fipsMode);
recorder.configureTruststore(fipsMode);
Comment thread
shawkins marked this conversation as resolved.
}

private FipsMode getFipsMode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ void testUserManagedEntityNotAddedToDefaultPU(CLIResult cliResult) {
cliResult.assertNoMessage("(JPA Startup Thread: client-store) Error while creating file");
cliResult.assertNoMessage("(JPA Startup Thread: keycloak-default) Error while creating file");

cliResult.assertStringCount("name: new-user-store", 1);
cliResult.assertStringCount("name: client-store", 1);
cliResult.assertStringCount("name: pu-without-dialect-store", 1);
cliResult.assertStringCount("com.acme.provider.legacy.jpa.entity.Realm", 1);
cliResult.assertMessageWasShownExactlyNumberOfTimes("name: new-user-store", 1);
cliResult.assertMessageWasShownExactlyNumberOfTimes("name: client-store", 1);
cliResult.assertMessageWasShownExactlyNumberOfTimes("name: pu-without-dialect-store", 1);
cliResult.assertMessageWasShownExactlyNumberOfTimes("com.acme.provider.legacy.jpa.entity.Realm", 1);

cliResult.assertMessage("jakarta.persistence.jtaDataSource: client-store");
cliResult.assertMessage("jakarta.persistence.jtaDataSource: new-user-store");
cliResult.assertMessage("jakarta.persistence.jtaDataSource: pu-without-dialect-store");
cliResult.assertStringCount("hibernate.dialect: org.hibernate.dialect.H2Dialect", 4);
cliResult.assertMessageWasShownExactlyNumberOfTimes("hibernate.dialect: org.hibernate.dialect.H2Dialect", 4);

cliResult.assertStartedDevMode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.keycloak.it.junit5.extension.CLIResult;
import org.keycloak.it.junit5.extension.DistributionTest;
import org.keycloak.it.junit5.extension.KeycloakRunner;
import org.keycloak.it.junit5.extension.RawDistOnly;
Expand Down Expand Up @@ -62,12 +63,16 @@ void testMutualAuthWithTruststorePaths(KeycloakRunner runner) {
rawDist.copyOrReplaceFileFromClasspath("/self-signed.p12", Path.of("conf", "self-signed.p12"));
Path keyStore = rawDist.getDistPath().resolve("conf").resolve("self-signed.p12").toAbsolutePath();

runner.run("--verbose", "start", "--db=dev-file", "--http-enabled=true", "--hostname=mykeycloak.org",
CLIResult result = runner.run("--verbose", "start", "--db=dev-file", "--http-enabled=true", "--hostname=mykeycloak.org", "--log-level=org.keycloak.truststore:debug",
"--truststore-paths=" + paths, "--https-client-auth=required", "--https-key-store-file=" + keyStore);

given().trustStore(TruststoreDistTest.class.getResource("/self-signed-truststore.p12").getPath(), TruststoreBuilder.DUMMY_PASSWORD)
.keyStore(TruststoreDistTest.class.getResource("/self-signed.p12").getPath(), "password")
.get("https://mykeycloak.org:8443").then().body(Matchers.containsString("https://mykeycloak.org"));

// ensure that the provider factories init with the correct truststore
// this is from the startup, so no additional waiting is necessary
assertTrue(result.getOutputStream().stream().anyMatch(s -> s.matches(".*File truststore provider initialized: .*keycloak-truststore.p12.*")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.regex.Pattern;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -200,8 +199,4 @@ default void assertJsonLogDefaultsApplied() throws JsonProcessingException {
}
}

default void assertStringCount(String msg, int count) {
Pattern pattern = Pattern.compile(msg);
assertThat((int) pattern.matcher(getOutput()).results().count(), is(count));
}
}
Loading