// create REST client for BoxClient
final ClientConnectionManager[] clientConnectionManager = new ClientConnectionManager[1];
final IBoxRESTClient restClient = new BoxRESTClient(connectionManager.build()) {
@Override
public HttpClient getRawHttpClient() {
final HttpClient httpClient = super.getRawHttpClient();
clientConnectionManager[0] = httpClient.getConnectionManager();
final SchemeRegistry schemeRegistry = clientConnectionManager[0].getSchemeRegistry();
SSLContextParameters sslContextParameters = configuration.getSslContextParameters();
if (sslContextParameters == null) {
sslContextParameters = new SSLContextParameters();
}
try {
final SSLSocketFactory socketFactory = new SSLSocketFactory(
sslContextParameters.createSSLContext(),
SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
schemeRegistry.register(new Scheme("https", socketFactory, 443));
} catch (GeneralSecurityException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
} catch (IOException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
// set custom HTTP params
final Map<String, Object> configParams = configuration.getHttpParams();
if (configParams != null && !configParams.isEmpty()) {
LOG.debug("Setting {} HTTP Params", configParams.size());
final HttpParams httpParams = httpClient.getParams();
for (Map.Entry<String, Object> param : configParams.entrySet()) {
httpParams.setParameter(param.getKey(), param.getValue());
}
}