KEYCLOAK-504

Using https results in RuntimeException if sslRequired is set to false
This commit is contained in:
Stian Thorgersen 2014-06-06 14:54:11 +01:00
parent 80f4b668b2
commit f3211bf34d

View file

@ -280,13 +280,13 @@ public class AdapterDeploymentContext {
protected KeycloakUriBuilder getBaseBuilder(HttpFacade facade, String base) { protected KeycloakUriBuilder getBaseBuilder(HttpFacade facade, String base) {
KeycloakUriBuilder builder = KeycloakUriBuilder.fromUri(base); KeycloakUriBuilder builder = KeycloakUriBuilder.fromUri(base);
URI request = URI.create(facade.getRequest().getURI()); URI request = URI.create(facade.getRequest().getURI());
String scheme = "http"; String scheme = request.getScheme();
if (deployment.isSslRequired()) { if (deployment.isSslRequired()) {
scheme = "https"; scheme = "https";
} if (!request.getScheme().equals(scheme) && request.getPort() != -1) {
if (!request.getScheme().equals(scheme) && request.getPort() != -1) { log.error("request scheme: " + request.getScheme() + " ssl required: " + deployment.isSslRequired());
log.error("request scheme: " + request.getScheme() + " ssl required: " + deployment.isSslRequired()); throw new RuntimeException("Can't resolve relative url from adapter config.");
throw new RuntimeException("Can't resolve relative url from adapter config."); }
} }
builder.scheme(scheme); builder.scheme(scheme);
builder.host(request.getHost()); builder.host(request.getHost());