From 8586a610728ef9a325bd9e2cc18f62f57cddb7b3 Mon Sep 17 00:00:00 2001 From: Sumasri Uppala Date: Wed, 9 Aug 2017 09:28:58 +0530 Subject: [PATCH] Fixes #21239: Fixed monitoring page when admin password is non empty (#22196) --- .../org/glassfish/admin/rest/utils/ProxyImpl.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/ProxyImpl.java b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/ProxyImpl.java index 2cd8abaedae..fb68343da36 100644 --- a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/ProxyImpl.java +++ b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/ProxyImpl.java @@ -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; @@ -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);