Skip to content

Commit

Permalink
As per PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalhcl-5960 committed Dec 4, 2024
1 parent 74be3c8 commit 8475892
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/main/java/com/hcl/appscan/sdk/utils/ServiceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public static String scanTypeShortForm(String type) {
* @param provider The IAuthenticationProvider for authentication.
* @return JSONObject.
*/
public static JSONObject scanSpecificDetails(String type, String scanId, IAuthenticationProvider provider) {
public static JSONObject getScanDetails(String type, String scanId, IAuthenticationProvider provider) {
if (provider.isTokenExpired()) {
return null;
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public static JSONObject scanSpecificDetails(String type, String scanId, IAuthen
* @param provider The IAuthenticationProvider for authentication.
* @return JSONArray.
*/
public static JSONArray getExecutionDetails(String scanId, IAuthenticationProvider provider) {
public static JSONArray getBaseScanDetails(String scanId, IAuthenticationProvider provider) {
if (provider.isTokenExpired()) {
return null;
}
Expand All @@ -334,40 +334,30 @@ public static JSONArray getExecutionDetails(String scanId, IAuthenticationProvid
return (JSONArray) response.getResponseBodyAsJSON();
}
} catch (IOException | JSONException e) {
// Ignore and return false.
// Ignore and move on.
}

return null;
}

/**
* Fetch the details of all the executions of a scan.
* Fetch the build version of the A360 server.
*
* @param provider The IAuthenticationProvider for authentication.
* @return String.
* @return The build server of the server.
*/
public static String getA360Version(IAuthenticationProvider provider) {
if (provider.isTokenExpired()) {
return null;
}

public static String getServiceVersion(IAuthenticationProvider provider) {
String request_url = provider.getServer() + "/assets/versions.json";
Map<String, String> request_headers = provider.getAuthorizationHeader(true);
request_headers.put("accept", "application/json");
request_headers.put("Content-Type", "application/json");

HttpClient client = new HttpClient(provider.getProxy(), provider.getacceptInvalidCerts());
try {
HttpResponse response = client.get(request_url, request_headers, null);

HttpResponse response = client.get(request_url, null, null);
if (response.isSuccess()) {
JSONObject body = (JSONObject) response.getResponseBodyAsJSON();
return (String) body.get("MainVersion");
return body.getString("MainVersion");
}
} catch (IOException | JSONException e) {
// Ignore and return false.
return "0"; //$NON-NLS-1$
}

return null;
}
}

0 comments on commit 8475892

Please sign in to comment.