use of com.checkmarx.sdk.dto.TokenLoginResponse in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxHttpClient method generateToken.
public TokenLoginResponse generateToken(LoginSettings settings) throws IOException {
UrlEncodedFormEntity requestEntity = getAuthRequest(settings);
HttpPost post = new HttpPost(settings.getAccessControlBaseUrl());
try {
return request(post, ContentType.APPLICATION_FORM_URLENCODED.toString(), requestEntity, TokenLoginResponse.class, HttpStatus.SC_OK, AUTH_MESSAGE, false, false);
} catch (ScannerRuntimeException e) {
if (!e.getMessage().contains("invalid_scope")) {
throw new ScannerRuntimeException(String.format("Failed to generate access token, failure error was: %s", e.getMessage()), e);
}
ClientType.RESOURCE_OWNER.setScopes("sast_rest_api");
settings.setClientTypeForPasswordAuth(ClientType.RESOURCE_OWNER);
requestEntity = getAuthRequest(settings);
return request(post, ContentType.APPLICATION_FORM_URLENCODED.toString(), requestEntity, TokenLoginResponse.class, HttpStatus.SC_OK, AUTH_MESSAGE, false, false);
}
}
Aggregations