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

Commit 8586a61

Browse files
sumauppayaminikb
authored andcommitted
Fixes #21239: Fixed monitoring page when admin password is non empty (#22196)
1 parent a34e19e commit 8586a61

File tree

1 file changed

+13
-1
lines changed
  • nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils

1 file changed

+13
-1
lines changed

nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/ProxyImpl.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import javax.ws.rs.WebApplicationException;
5050
import javax.ws.rs.client.Client;
5151
import javax.ws.rs.client.ClientBuilder;
52+
import javax.ws.rs.client.Invocation;
5253
import javax.ws.rs.client.WebTarget;
5354
import javax.ws.rs.core.MediaType;
5455
import javax.ws.rs.core.Response;
@@ -85,7 +86,18 @@ public Properties proxyRequest(UriInfo sourceUriInfo, Client client, ServiceLoca
8586
URI forwardURI = forwardUriBuilder.scheme("https").host(forwardInstance.getAdminHost()).port(forwardInstance.getAdminPort()).build(); //Host and Port are replaced to that of forwardInstanceName
8687
client = addAuthenticationInfo(client, forwardInstance, habitat);
8788
WebTarget resourceBuilder = client.target(forwardURI);
88-
Response response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class); //TODO if the target server is down, we get ClientResponseException. Need to handle it
89+
SecureAdmin secureAdmin = habitat.getService(SecureAdmin.class);
90+
final String indicatorValue = SecureAdmin.Util.configuredAdminIndicator(secureAdmin);
91+
Invocation.Builder builder;
92+
Response response;
93+
if (indicatorValue != null) {
94+
builder = resourceBuilder.request(MediaType.APPLICATION_JSON).header(
95+
SecureAdmin.Util.ADMIN_INDICATOR_HEADER_NAME,
96+
indicatorValue);
97+
response = builder.get(Response.class);
98+
} else {
99+
response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class);
100+
}
89101
Response.Status status = Response.Status.fromStatusCode(response.getStatus());
90102
if (status.getFamily() == javax.ws.rs.core.Response.Status.Family.SUCCESSFUL) {
91103
String jsonDoc = response.readEntity(String.class);

0 commit comments

Comments
 (0)