Skip to content

Commit

Permalink
copyright year updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalhcl-5960 committed Jan 16, 2025
1 parent a08f198 commit 42ae65e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/hcl/appscan/sdk/CoreConstants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* © Copyright IBM Corporation 2016.
* © Copyright HCL Technologies Ltd. 2017, 2024.
* © Copyright HCL Technologies Ltd. 2017, 2024, 2025.
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* © Copyright HCL Technologies Ltd. 2019, 2020, 2024.
* © Copyright HCL Technologies Ltd. 2019, 2020, 2024, 2025.
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* © Copyright HCL Technologies Ltd. 2024.
* © Copyright HCL Technologies Ltd. 2024, 2025.
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* © Copyright IBM Corporation 2016.
* © Copyright HCL Technologies Ltd. 2017, 2024.
* © Copyright HCL Technologies Ltd. 2017, 2024, 2025.
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* © Copyright IBM Corporation 2016.
* © Copyright HCL Technologies Ltd. 2017, 2024.
* © Copyright HCL Technologies Ltd. 2017, 2024, 2025.
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/

Expand Down
43 changes: 42 additions & 1 deletion src/main/java/com/hcl/appscan/sdk/utils/ServiceUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* © Copyright IBM Corporation 2016.
* © Copyright HCL Technologies Ltd. 2017, 2024.
* © Copyright HCL Technologies Ltd. 2017, 2024, 2025.
* LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/

Expand Down Expand Up @@ -223,6 +223,47 @@ private static boolean hasEntitlement(String scanType, IAuthenticationProvider p
return false;
}

/**
* Checks if the given scanId is valid for scanning.
*
* @param scanId The scanId to test.
* @param applicationId The applicationId to verify.
* @param type The scanType to verify.
* @param provider The IAuthenticationProvider for authentication.
* @return True if the scanId is valid. False is returned if the scanId is not valid, the request fails, or an exception occurs.
*/
public static boolean isScanId(String scanId, String applicationId, String type, IAuthenticationProvider provider) {
if (provider.isTokenExpired()) {
return true;
}

String request_url = provider.getServer() + API_BASIC_DETAILS;
request_url += "?$filter=Id%20eq%20" + scanId + "&%24select=AppId%2C%20Technology";
Map<String, String> request_headers = provider.getAuthorizationHeader(true);

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

if (response.isSuccess()) {
JSONObject obj = (JSONObject) response.getResponseBodyAsJSON();
JSONArray array = (JSONArray) obj.get(ITEMS);
if (array.isEmpty()) {
return false;
} else {
JSONObject body = (JSONObject) array.getJSONObject(0);
String appId = body.getString(CoreConstants.APP_ID);
String technologyName = body.getString("Technology");
return appId.equals(applicationId) && technologyName.equals(updatedScanType(type));
}
}
} catch (IOException | JSONException e) {
// Ignore and return false.
}

return false;
}

public static String updatedScanType(String type) {
switch (type) {
case "Static Analyzer":
Expand Down

0 comments on commit 42ae65e

Please sign in to comment.