Fix service-account demo app on EAP 6.4
This commit is contained in:
parent
4d90898dd9
commit
d818ebdd9e
3 changed files with 6 additions and 4 deletions
|
@ -9,7 +9,7 @@ public class ProductSAClientSecretServlet extends ProductServiceAccountServlet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getAdapterConfigLocation() {
|
protected String getAdapterConfigLocation() {
|
||||||
return "WEB-INF/keycloak-client-secret.json";
|
return "/WEB-INF/keycloak-client-secret.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class ProductSAClientSignedJWTServlet extends ProductServiceAccountServle
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getAdapterConfigLocation() {
|
protected String getAdapterConfigLocation() {
|
||||||
return "WEB-INF/keycloak-client-signed-jwt.json";
|
return "/WEB-INF/keycloak-client-signed-jwt.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.keycloak.adapters.authentication.ClientCredentialsProviderUtils;
|
||||||
import org.keycloak.representations.AccessToken;
|
import org.keycloak.representations.AccessToken;
|
||||||
import org.keycloak.representations.AccessTokenResponse;
|
import org.keycloak.representations.AccessTokenResponse;
|
||||||
import org.keycloak.util.JsonSerialization;
|
import org.keycloak.util.JsonSerialization;
|
||||||
|
import org.keycloak.util.UriUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||||
|
@ -155,7 +156,8 @@ public abstract class ProductServiceAccountServlet extends HttpServlet {
|
||||||
HttpClient client = getHttpClient();
|
HttpClient client = getHttpClient();
|
||||||
String token = (String) req.getSession().getAttribute(TOKEN);
|
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) {
|
if (token != null) {
|
||||||
get.addHeader("Authorization", "Bearer " + token);
|
get.addHeader("Authorization", "Bearer " + token);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +167,7 @@ public abstract class ProductServiceAccountServlet extends HttpServlet {
|
||||||
int status = response.getStatusLine().getStatusCode();
|
int status = response.getStatusLine().getStatusCode();
|
||||||
if (status != 200) {
|
if (status != 200) {
|
||||||
String json = getContent(entity);
|
String json = getContent(entity);
|
||||||
String error = "Failed retrieve products. Status: " + status + ", Response: " + json;
|
String error = "Failed retrieve products. Status: " + status;
|
||||||
req.setAttribute(ERROR, error);
|
req.setAttribute(ERROR, error);
|
||||||
} else if (entity == null) {
|
} else if (entity == null) {
|
||||||
req.setAttribute(ERROR, "No entity");
|
req.setAttribute(ERROR, "No entity");
|
||||||
|
|
Loading…
Reference in a new issue