use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class GoScanner method getScanDetails.
public Scan getScanDetails(Integer scanId) throws CheckmarxException {
HttpEntity httpEntity = new HttpEntity<>(authClient.createAuthHeaders());
try {
log.debug("Retrieving scan with id {}", scanId);
ResponseEntity<Scan> response = restTemplate.exchange(cxGoProperties.getUrl().concat(SCAN), HttpMethod.GET, httpEntity, Scan.class, scanId);
return Optional.ofNullable(response.getBody()).orElseThrow(() -> new CheckmarxRuntimeException("Scan details response body is missing."));
} catch (HttpStatusCodeException e) {
log.error("Error occurred while retrieving the scan with id {}", scanId);
log.error(ExceptionUtils.getStackTrace(e));
throw new CheckmarxException("Error occurred while retrieving the scan with id".concat(Integer.toString(scanId)));
}
}
use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class GoScanner method getScans.
public List<Scan> getScans() throws CheckmarxException {
HttpEntity<?> httpEntity = new HttpEntity<>(authClient.createAuthHeaders());
try {
log.debug("Retrieving all scans");
ResponseEntity<Scan[]> response = restTemplate.exchange(cxGoProperties.getUrl().concat(SCANS), HttpMethod.GET, httpEntity, Scan[].class);
return Arrays.asList(Objects.requireNonNull(response.getBody()));
} catch (HttpStatusCodeException e) {
log.error("Error occurred while retrieving scans");
log.error(ExceptionUtils.getStackTrace(e));
throw new CheckmarxException("Error occurred while retrieving scans");
}
}
use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class GoScanner method getScanResults.
private GoScanResults getScanResults(Integer scanId) throws CheckmarxException {
HttpEntity<?> httpEntity = new HttpEntity<>(authClient.createAuthHeaders());
try {
log.info("Retrieving Scan Results for Scan Id {} ", scanId);
ResponseEntity<GoScanResults> response = restTemplate.exchange(cxGoProperties.getUrl().concat(SCAN_RESULTS), HttpMethod.GET, httpEntity, GoScanResults.class, scanId);
return response.getBody();
} catch (HttpStatusCodeException e) {
log.error("Error occurred while retrieving the scan results for id {}.", scanId);
log.error(ExceptionUtils.getStackTrace(e));
throw new CheckmarxException("Error occurred while retrieving the scan status for id ".concat(Integer.toString(scanId)));
}
}
use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class GoScanner method getNavigationTree.
private OdNavigationTree getNavigationTree(String clientSecret) throws CheckmarxException {
HttpEntity<?> httpEntity = new HttpEntity<>(authClient.createAuthHeaders(clientSecret));
try {
log.debug("Retrieving OD Navigation Tree");
ResponseEntity<OdNavigationTree> response = restTemplate.exchange(cxGoProperties.getUrl().concat("/navigation-tree/navigation-tree"), HttpMethod.GET, httpEntity, OdNavigationTree.class);
return response.getBody();
} catch (HttpStatusCodeException e) {
log.error("Error occurred while retrieving the navigation tree.");
log.error(ExceptionUtils.getStackTrace(e));
throw new CheckmarxException("Error retrieving Business Units.");
}
}
use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxLegacyService method getLdapServerId.
Integer getLdapServerId(String session, String serverName) throws CheckmarxException {
GetLdapServersConfigurations request = new GetLdapServersConfigurations();
request.setSessionId(session);
log.debug("Retrieving Ldap Server Configurations");
GetLdapServersConfigurationsResponse response = (GetLdapServersConfigurationsResponse) ws.marshalSendAndReceive(ws.getDefaultUri(), request, new SoapActionCallback(CX_WS_LDAP_CONFIGURATIONS_URI));
try {
if (!response.getGetLdapServersConfigurationsResult().isIsSuccesfull()) {
log.error(response.getGetLdapServersConfigurationsResult().getErrorMessage());
throw new CheckmarxException(response.getGetLdapServersConfigurationsResult().getErrorMessage());
} else {
List<CxWSLdapServerConfiguration> ldapConfigs = response.getGetLdapServersConfigurationsResult().getServerConfigs().getCxWSLdapServerConfiguration();
for (CxWSLdapServerConfiguration ldap : ldapConfigs) {
if (ldap.getName().equalsIgnoreCase(serverName)) {
return ldap.getId();
}
}
return -1;
}
} catch (NullPointerException e) {
log.warn("Error occurred getting ldap server configurations");
throw new CheckmarxException("Error occurred while getting ldap server configurations");
}
}
Aggregations