Skip to content

Commit

Permalink
HealthCheck for sims bypass HTTP and Auth, removed login check
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jul 17, 2024
1 parent efcb5ab commit 4a61faf
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public enum AuthenticationPolicy {
public static final String HEALTH = "health";

public static final String HEALTH_CHECK = "check";
public static final String HEALTH_CHECK_LOGIN = "login";
public static final String HEALTH_CHECK_SIM = "sim";
public static final String HEALTH_CHECK_STATUS_TIMESTAMP = "status_timestamp";
public static final String HEALTH_CHECK_ALL = "all";
Expand Down
3 changes: 1 addition & 2 deletions vcell-api/src/main/java/org/vcell/rest/VCellApiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ public void onException(Exception e) {
boolean bIgnoreCertProblemsForHealthService = PropertyLoader.getBooleanProperty(PropertyLoader.sslIgnoreCertProblems, false);
User testUser = localAdminDbServer.getUser(TEST_USER);
UserInfo testUserInfo = localAdminDbServer.getUserInfo(testUser.getID()); // lookup hashed auth credentials in database.
String pathPrefixV0 = PropertyLoader.getRequiredProperty(PropertyLoader.vcellServerPrefixV0);
HealthService healthService = new HealthService(restEventService, "localhost", port, pathPrefixV0,
HealthService healthService = new HealthService(vcMessagingService_int, databaseServerImpl, restEventService,
bIgnoreCertProblemsForHealthService, bIgnoreHostMismatchForHealthService,
testUserInfo);
AdminService adminService = new AdminService(adminDbTopLevel, databaseServerImpl);
Expand Down
17 changes: 3 additions & 14 deletions vcell-api/src/main/java/org/vcell/rest/health/HealthRestlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ public final class HealthRestlet extends Restlet {
private final static Logger lg = LogManager.getLogger(HealthRestlet.class);

enum RequestType {
login,
sim,
all
};
}


public HealthRestlet(Context context) {
Expand All @@ -43,17 +42,15 @@ public void handle(Request req, Response response) {
String requestTypeString = form.getFirstValue(VCellApiApplication.HEALTH_CHECK, true);
RequestType requestType = null;
if (requestTypeString!=null) {
if (requestTypeString.equalsIgnoreCase(VCellApiApplication.HEALTH_CHECK_LOGIN)) {
requestType = RequestType.login;
}else if (requestTypeString.equalsIgnoreCase(VCellApiApplication.HEALTH_CHECK_SIM)) {
if (requestTypeString.equalsIgnoreCase(VCellApiApplication.HEALTH_CHECK_SIM)) {
requestType = RequestType.sim;
}else if (requestTypeString.equalsIgnoreCase(VCellApiApplication.HEALTH_CHECK_ALL)) {
requestType = RequestType.all;
}
}
if (requestType==null){
throw new RuntimeException("expecting /"+VCellApiApplication.HEALTH+"?"+VCellApiApplication.HEALTH_CHECK+"="+
"("+VCellApiApplication.HEALTH_CHECK_LOGIN+"|"+VCellApiApplication.HEALTH_CHECK_SIM+"|"+VCellApiApplication.HEALTH_CHECK_ALL+")"
"("+VCellApiApplication.HEALTH_CHECK_SIM+"|"+VCellApiApplication.HEALTH_CHECK_ALL+")"
+ "[&"+VCellApiApplication.HEALTH_CHECK_ALL_START_TIMESTAMP+"=<start_ms>]"
+ "[&"+VCellApiApplication.HEALTH_CHECK_ALL_END_TIMESTAMP+"=<end_ms>]"
+ "[&"+VCellApiApplication.HEALTH_CHECK_STATUS_TIMESTAMP+"=<status_ms>]");
Expand Down Expand Up @@ -92,14 +89,6 @@ public void handle(Request req, Response response) {
response.setEntity(new JsonRepresentation(healthEventsJSON));
break;
}
case login:{
NagiosStatus nagiosStatus = healthService.getLoginStatus(status_timestamp);
Gson gson = new Gson();
String statusJSON = gson.toJson(nagiosStatus);
response.setStatus(Status.SUCCESS_OK);
response.setEntity(new JsonRepresentation(statusJSON));
break;
}
case sim:{
NagiosStatus nagiosStatus = healthService.getRunsimStatus(status_timestamp);
Gson gson = new Gson();
Expand Down
Loading

0 comments on commit 4a61faf

Please sign in to comment.