use of com.checkmarx.sdk.dto.sca.ClientType in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxHttpClient method getTokenRefreshingRequest.
private static UrlEncodedFormEntity getTokenRefreshingRequest(LoginSettings settings) throws UnsupportedEncodingException {
ClientType clientType = settings.getClientTypeForRefreshToken();
List<BasicNameValuePair> parameters = new ArrayList<>();
parameters.add(new BasicNameValuePair("grant_type", REFRESH_TOKEN_PROP));
parameters.add(new BasicNameValuePair(CLIENT_ID_PROP, clientType.getClientId()));
parameters.add(new BasicNameValuePair(CLIENT_SECRET_PROP, clientType.getClientSecret()));
parameters.add(new BasicNameValuePair(REFRESH_TOKEN_PROP, settings.getRefreshToken()));
return new UrlEncodedFormEntity(parameters, StandardCharsets.UTF_8.name());
}
use of com.checkmarx.sdk.dto.sca.ClientType in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxHttpClient method getAuthRequest.
private static UrlEncodedFormEntity getAuthRequest(LoginSettings settings) {
ClientType clientType = settings.getClientTypeForPasswordAuth();
String grantType = StringUtils.defaultString(clientType.getGrantType(), DEFAULT_GRANT_TYPE);
List<BasicNameValuePair> parameters = new ArrayList<>();
parameters.add(new BasicNameValuePair("username", settings.getUsername()));
parameters.add(new BasicNameValuePair(PASSWORD_PROP, settings.getPassword()));
parameters.add(new BasicNameValuePair("grant_type", grantType));
parameters.add(new BasicNameValuePair("scope", clientType.getScopes()));
parameters.add(new BasicNameValuePair(CLIENT_ID_PROP, clientType.getClientId()));
parameters.add(new BasicNameValuePair(CLIENT_SECRET_PROP, clientType.getClientSecret()));
if (!StringUtils.isEmpty(settings.getTenant())) {
String authContext = String.format("Tenant:%s", settings.getTenant());
parameters.add(new BasicNameValuePair("acr_values", authContext));
}
return new UrlEncodedFormEntity(parameters, StandardCharsets.UTF_8);
}
use of com.checkmarx.sdk.dto.sca.ClientType in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class AstClientHelper method init.
@Override
public ResultsBase init() {
log.debug("Initializing {} client.", getScannerDisplayName());
ASTResults astResults = new ASTResults();
try {
ClientType clientType = getClientType();
LoginSettings settings = getLoginSettings(clientType);
httpClient.login(settings);
} catch (Exception e) {
super.handleInitError(e, astResults);
}
return astResults;
}
use of com.checkmarx.sdk.dto.sca.ClientType in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class ClientTypeResolverTest method testDetermineClientType.
private void testDetermineClientType(String urlPropName) {
ClientTypeResolver resolver = new ClientTypeResolver(new RestClientConfig());
ClientType clientType = resolver.determineClientType(urlPropName);
Assert.assertNotNull("Client type is null.", clientType);
Assert.assertTrue("Client ID is empty.", StringUtils.isNotEmpty(clientType.getClientId()));
Assert.assertTrue("Scopes are empty.", StringUtils.isNotEmpty(clientType.getScopes()));
}
Aggregations