use of com.qaprosoft.hockeyapp.http.resttemplate.ssl.DisabledSslClientHttpRequestFactory in project carina by qaprosoft.
the class RestTemplateBuilder method build.
public RestTemplate build() {
if (!isUseDefaultJsonMessageConverter) {
HttpMessageConverter<?> httpMessageConverter = Iterables.tryFind(restTemplate.getMessageConverters(), new Predicate<HttpMessageConverter<?>>() {
@Override
public boolean apply(HttpMessageConverter<?> input) {
return input instanceof MappingJackson2HttpMessageConverter;
}
}).orNull();
restTemplate.getMessageConverters().remove(httpMessageConverter);
}
restTemplate.getMessageConverters().addAll(httpMessageConverters);
if (isDisableSslChecking) {
restTemplate.setRequestFactory(new DisabledSslClientHttpRequestFactory());
}
if (isUseBasicAuth) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(basicAuthUsername, basicAuthPassword));
HttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build();
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient));
}
return restTemplate;
}
Aggregations