diff --git a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSecretServlet.java b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSecretServlet.java index 43c70f8127..4892bad0aa 100644 --- a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSecretServlet.java +++ b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSecretServlet.java @@ -9,7 +9,7 @@ public class ProductSAClientSecretServlet extends ProductServiceAccountServlet { @Override protected String getAdapterConfigLocation() { - return "WEB-INF/keycloak-client-secret.json"; + return "/WEB-INF/keycloak-client-secret.json"; } @Override diff --git a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSignedJWTServlet.java b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSignedJWTServlet.java index 2a6fe337b9..58c5f9bdc4 100644 --- a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSignedJWTServlet.java +++ b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductSAClientSignedJWTServlet.java @@ -7,7 +7,7 @@ public class ProductSAClientSignedJWTServlet extends ProductServiceAccountServle @Override protected String getAdapterConfigLocation() { - return "WEB-INF/keycloak-client-signed-jwt.json"; + return "/WEB-INF/keycloak-client-signed-jwt.json"; } @Override diff --git a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java index 91f4a07543..13ab6468b4 100644 --- a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java +++ b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java @@ -32,6 +32,7 @@ import org.keycloak.adapters.authentication.ClientCredentialsProviderUtils; import org.keycloak.representations.AccessToken; import org.keycloak.representations.AccessTokenResponse; import org.keycloak.util.JsonSerialization; +import org.keycloak.util.UriUtils; /** * @author Marek Posolda @@ -155,7 +156,8 @@ public abstract class ProductServiceAccountServlet extends HttpServlet { HttpClient client = getHttpClient(); String token = (String) req.getSession().getAttribute(TOKEN); - HttpGet get = new HttpGet("http://localhost:8080/database/products"); + String requestOrigin = UriUtils.getOrigin(req.getRequestURL().toString()); + HttpGet get = new HttpGet(requestOrigin + "/database/products"); if (token != null) { get.addHeader("Authorization", "Bearer " + token); } @@ -165,7 +167,7 @@ public abstract class ProductServiceAccountServlet extends HttpServlet { int status = response.getStatusLine().getStatusCode(); if (status != 200) { String json = getContent(entity); - String error = "Failed retrieve products. Status: " + status + ", Response: " + json; + String error = "Failed retrieve products. Status: " + status; req.setAttribute(ERROR, error); } else if (entity == null) { req.setAttribute(ERROR, "No entity");