Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Fixes #21239: Fixed monitoring page when admin password is non empty (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sumauppa authored and yaminikb committed Aug 9, 2017
1 parent a34e19e commit 8586a61
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
Expand Down Expand Up @@ -85,7 +86,18 @@ public Properties proxyRequest(UriInfo sourceUriInfo, Client client, ServiceLoca
URI forwardURI = forwardUriBuilder.scheme("https").host(forwardInstance.getAdminHost()).port(forwardInstance.getAdminPort()).build(); //Host and Port are replaced to that of forwardInstanceName
client = addAuthenticationInfo(client, forwardInstance, habitat);
WebTarget resourceBuilder = client.target(forwardURI);
Response response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class); //TODO if the target server is down, we get ClientResponseException. Need to handle it
SecureAdmin secureAdmin = habitat.getService(SecureAdmin.class);
final String indicatorValue = SecureAdmin.Util.configuredAdminIndicator(secureAdmin);
Invocation.Builder builder;
Response response;
if (indicatorValue != null) {
builder = resourceBuilder.request(MediaType.APPLICATION_JSON).header(
SecureAdmin.Util.ADMIN_INDICATOR_HEADER_NAME,
indicatorValue);
response = builder.get(Response.class);
} else {
response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class);
}
Response.Status status = Response.Status.fromStatusCode(response.getStatus());
if (status.getFamily() == javax.ws.rs.core.Response.Status.Family.SUCCESSFUL) {
String jsonDoc = response.readEntity(String.class);
Expand Down

0 comments on commit 8586a61

Please sign in to comment.