8000 fix: making the embedded resteasy server work again by shawkins · Pull Request #49067 · keycloak/keycloak · GitHub
[go: up one dir, main page]

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public class ResteasyKeycloakApplication extends KeycloakApplication {
protected Set<Class<?>> classes = new HashSet<>();

public ResteasyKeycloakApplication() {
Config.init(new JsonConfigProviderFactory().create()
.orElseThrow(() -> new RuntimeException("Failed to load Keycloak configuration")));
Profile.configure(
new PropertiesProfileConfigResolver(System.getProperties()),
new PropertiesFileProfileConfigResolver()
);
classes.add(RealmsResource.class);
if (Profile.isFeatureEnabled(Profile.Feature.ADMIN_API)) {
classes.add(AdminRoot.class);
Expand All @@ -68,12 +74,6 @@ public ResteasyKeycloakApplication() {
// an endpoint for the load balancer to gather information whether this site should receive requests or not.
classes.add(LoadBalancerResource.class);
}
Config.init(new JsonConfigProviderFactory().create()
.orElseThrow(() -> new RuntimeException("Failed to load Keycloak configuration")));
Profile.configure(
new PropertiesProfileConfigResolver(System.getProperties()),
new PropertiesFileProfileConfigResolver()
);
startup();
}

Expand Down
5 changes: 0 additions & 5 deletions testsuite/utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@
<version>${mssql-jdbc.version}</version>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-junit5</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer</artifactId>
Expand Down
5476
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyStore;
import java.text.SimpleDateFormat;
Expand All @@ -41,7 +42,6 @@
import jakarta.servlet.DispatcherType;
import jakarta.servlet.Filter;

import org.keycloak.Keycloak;
import org.keycloak.authentication.AuthenticatorSpi;
import org.keycloak.authentication.authenticators.browser.DeployedScriptAuthenticatorFactory;
import org.keycloak.authorization.policy.provider.PolicySpi;
Expand Down Expand Up @@ -77,6 +77,7 @@
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.FilterInfo;
import io.undertow.servlet.api.InstanceHandle;
import org.apache.commons.io.FileUtils;
import org.jboss.logging.Logger;
import org.jboss.resteasy.core.ResteasyDeploymentImpl;
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters;
Expand Down Expand Up @@ -320,7 +321,28 @@ public static String detectDataDirectory() {
}

// we generate a dynamic jboss.server.data.dir and remove it at the end.
return Keycloak.initTempDirectory("keycloak-data").toFile().getAbsolutePath();
return initTempDirectory("keycloak-data").toFile().getAbsolutePath();
}

public static Path initTempDirectory(String name) {
String buildDir = System.getProperty("project.build.directory");
if (buildDir == null) {
try {
Path tempDirectory = Files.createTempDirectory(name);
tempDirectory.toFile().deleteOnExit();
return tempDirectory.toAbsolutePath();
} catch (IOException e) {
throw new RuntimeException("Could not create temporary directory", e);
}
} else {
Path tempDirectory = Path.of(buildDir, name);
try {
FileUtils.deleteDirectory(tempDirectory.toFile());
} catch (IOException e) {
e.printStackTrace();
}
return tempDirectory;
}
}

private KeycloakServerConfig config;
Expand Down
Loading
0