Merge pull request #1606 from mposolda/master
Fix service-account demo app on EAP 6.4
This commit is contained in:
commit
76f3842dad
3 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue