if ( !Utils.isEmpty( username ) ) { HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder(); clientBuilder.setCredentials( username, password ); httpClient = clientBuilder.build(); } else {
clientBuilder.setCredentials( data.realHttpLogin, data.realHttpPassword );
clientBuilder.setCredentials( data.realHttpLogin, data.realHttpPassword );
httpClientBuilder.setCredentials( username, password, authScope ); context = HttpClientUtil.createPreemptiveBasicAuthentication( tempURL.getHost(), tempURL.getPort(), username, password );
if ( StringUtils.isNotBlank( user ) ) { String password = System.getProperty( "http.proxyPassword" ); clientBuilder.setCredentials( user, password ); httpClient = clientBuilder.build();
/** * Returns an instance of an HttpClient. Only one is created per ConnectionServiceClient so all calls should be * made synchronously. * * @return The HTTP client to be used for web service calls */ public static HttpClient getClient( String userId, String password ) { HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder(); if ( StringUtils.isNotEmpty( userId ) && StringUtils.isNotEmpty( password ) ) { clientBuilder.setCredentials( userId, password ); } return clientBuilder.build(); }
@VisibleForTesting HttpClient getHttpClient( String user, String password ) { HttpClientManager.HttpClientBuilderFacade clientBuilder = httpClientManager.createBuilder(); clientBuilder.setCredentials( user, password ); return clientBuilder.build(); }
@VisibleForTesting HttpClient createHttpClient( String user, String password ) { HttpClientManager.HttpClientBuilderFacade httpClientBuilder = httpClientManager.createBuilder(); // client.setTimeout(10000); // client.setConnectionTimeout(10000); if ( StringUtils.isNotBlank( user ) ) { httpClientBuilder.setCredentials( user, password ); } return httpClientBuilder.build(); }
private HttpClient getHttpClient( HttpClientContext context ) { HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder(); String login = environmentSubstitute( meta.getHttpLogin() ); if ( StringUtils.isNotBlank( login ) ) { clientBuilder.setCredentials( login, Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getHttpPassword() ) ) ); } int proxyPort = 0; if ( StringUtils.isNotBlank( meta.getProxyHost() ) ) { proxyPort = Const.toInt( environmentSubstitute( meta.getProxyPort() ), 8080 ); clientBuilder.setProxy( meta.getProxyHost(), proxyPort ); } CloseableHttpClient httpClient = clientBuilder.build(); if ( proxyPort != 0 ) { // Preemptive authentication HttpHost target = new HttpHost( meta.getProxyHost(), proxyPort, "http" ); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local auth cache BasicScheme basicAuth = new BasicScheme(); authCache.put( target, basicAuth ); // Add AuthCache to the execution context context.setAuthCache( authCache ); } return httpClient; }
public HttpClientBuilderFacade setCredentials( String user, String password ) { return setCredentials( user, password, AuthScope.ANY ); }