KEYCLOAK-5242 Added means to run KeycloakServer with https
This commit is contained in:
1 parent
dd6a7b23c3
commit
36080b9833
2 files changed
+30
-2
No files matched your search
@@ -39,7 +39,6 @@ import org.keycloak.services.managers.RealmManager;
|
||||
import org.keycloak.services.resources.KeycloakApplication;
|
||||
import org.keycloak.testsuite.util.cli.TestsuiteCLI;
|
||||
import org.keycloak.util.JsonSerialization;
|
||||
import org.mvel2.util.Make;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import java.io.File;
|
||||
@@ -51,6 +50,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
@@ -64,6 +64,7 @@ public class KeycloakServer {
|
||||
public static class KeycloakServerConfig {
|
||||
private String host = "localhost";
|
||||
private int port = 8081;
|
||||
private int portHttps = -1;
|
||||
private int workerThreads = Math.max(Runtime.getRuntime().availableProcessors(), 2) * 8;
|
||||
private String resourcesHome;
|
||||
|
||||
@@ -75,6 +76,10 @@ public class KeycloakServer {
|
||||
return port;
|
||||
}
|
||||
|
||||
public int getPortHttps() {
|
||||
return portHttps;
|
||||
}
|
||||
|
||||
public String getResourcesHome() {
|
||||
return resourcesHome;
|
||||
}
|
||||
@@ -87,6 +92,10 @@ public class KeycloakServer {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void setPortHttps(int portHttps) {
|
||||
this.portHttps = portHttps;
|
||||
}
|
||||
|
||||
public void setResourcesHome(String resourcesHome) {
|
||||
this.resourcesHome = resourcesHome;
|
||||
}
|
||||
@@ -140,6 +149,10 @@ public class KeycloakServer {
|
||||
config.setPort(Integer.valueOf(System.getProperty("keycloak.port")));
|
||||
}
|
||||
|
||||
if (System.getProperty("keycloak.port.https") != null) {
|
||||
config.setPortHttps(Integer.valueOf(System.getProperty("keycloak.port.https")));
|
||||
}
|
||||
|
||||
if (System.getProperty("keycloak.bind.address") != null) {
|
||||
config.setHost(System.getProperty("keycloak.bind.address"));
|
||||
}
|
||||
@@ -312,6 +325,10 @@ public class KeycloakServer {
|
||||
.setWorkerThreads(config.getWorkerThreads())
|
||||
.setIoThreads(config.getWorkerThreads() / 8);
|
||||
|
||||
if (config.getPortHttps() != -1) {
|
||||
builder = builder.addHttpsListener(config.getPortHttps(), config.getHost(), SSLContext.getDefault());
|
||||
}
|
||||
|
||||
server = new UndertowJaxrsServer();
|
||||
try {
|
||||
server.start(builder);
|
||||
@@ -350,7 +367,9 @@ public class KeycloakServer {
|
||||
info("Loading resources from " + config.getResourcesHome());
|
||||
}
|
||||
|
||||
info("Started Keycloak (http://" + config.getHost() + ":" + config.getPort() + "/auth) in "
|
||||
info("Started Keycloak (http://" + config.getHost() + ":" + config.getPort() + "/auth"
|
||||
+ (config.getPortHttps() > 0 ? ", https://" + config.getHost() + ":" + config.getPortHttps()+ "/auth" : "")
|
||||
+ ") in "
|
||||
+ (System.currentTimeMillis() - start) + " ms\n");
|
||||
} catch (RuntimeException e) {
|
||||
server.stop();
|
||||
|
||||
Reference in new issue
Block a user