agave-common/common-core/src/main/java/org/iplantc/service/common/clients/HTTPSClient.java
/**
	 * Constructs HTTP client with "trust everything" ssl support to make a HTTP request.
	 * @param escapedUri
	 * @param httpUriRequest
	 * @return raw http response object with entity in tact
	 * @throws IOException
	 * @throws RemoteDataException
	 * @throws NoSuchAlgorithmException
	 * @throws KeyStoreException
	 * @throws KeyManagementException 
	 */
Constructs HTTP client with "trust everything" ssl support to make a HTTP request.
Constructs HTTP client with " trust everything " ssl support to make a HTTP request .
private static CloseableHttpResponse doRequest(URI escapedUri, HttpUriRequest httpUriRequest)
	throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException
	{
		CloseableHttpClient httpclient = initClient(escapedUri);
		String username = null;
		String password = null;
		if (!StringUtils.isEmpty(escapedUri.getUserInfo())) {
            String[] tokens = escapedUri.getUserInfo().split(":");
            if (tokens.length >= 1) {
                username = tokens[0];
                password = tokens[1];
            }
        }
		if (!StringUtils.isEmpty(username)) 
		{
			String nullSafePassword = StringUtils.isEmpty(password) ? "" : password;
		    HttpHost targetHost = new HttpHost(escapedUri.getHost(), escapedUri.getPort(), escapedUri.getScheme());
		    CredentialsProvider credsProvider = new BasicCredentialsProvider();
		    credsProvider.setCredentials(
		            new AuthScope(targetHost.getHostName(), targetHost.getPort()),
		            new UsernamePasswordCredentials(username, nullSafePassword));
		    AuthCache authCache = new BasicAuthCache();
		    BasicScheme basicAuth = new BasicScheme();
		    authCache.put(targetHost, basicAuth);
		    HttpClientContext context = HttpClientContext.create();
		    context.setCredentialsProvider(credsProvider);
		    context.setAuthCache(authCache);
		    return httpclient.execute(targetHost, httpUriRequest, context);
		}
		else
		{
			return httpclient.execute(httpUriRequest);
		}
	}
private static CloseableHttpResponse doRequest ( URI escapedUri , HttpUriRequest httpUriRequest ) throws IOException , NoSuchAlgorithmException , KeyStoreException , KeyManagementException { CloseableHttpClient httpclient = initClient ( escapedUri ) ; String username = null ; String password = null ; if ( ! StringUtils . isEmpty ( escapedUri . getUserInfo ( ) ) ) { String [ ] tokens = escapedUri . getUserInfo ( ) . split ( ":" ) ; if ( tokens . length >= 1 ) { username = tokens [ 0 ] ; password = tokens [ 1 ] ; } } if ( ! StringUtils . isEmpty ( username ) ) { String nullSafePassword = StringUtils . isEmpty ( password ) ? "" : password ; HttpHost targetHost = new HttpHost ( escapedUri . getHost ( ) , escapedUri . getPort ( ) , escapedUri . getScheme ( ) ) ; CredentialsProvider credsProvider = new BasicCredentialsProvider ( ) ; credsProvider . setCredentials ( new AuthScope ( targetHost . getHostName ( ) , targetHost . getPort ( ) ) , new UsernamePasswordCredentials ( username , nullSafePassword ) ) ; AuthCache authCache = new BasicAuthCache ( ) ; BasicScheme basicAuth = new BasicScheme ( ) ; authCache . put ( targetHost , basicAuth ) ; HttpClientContext context = HttpClientContext . create ( ) ; context . setCredentialsProvider ( credsProvider ) ; context . setAuthCache ( authCache ) ; return httpclient . execute ( targetHost , httpUriRequest , context ) ; } else { return httpclient . execute ( httpUriRequest ) ; } }
Constructs HTTP client with "trust everything" ssl support to make a HTTP request.
Constructs HTTP client with " trust everything " ssl support to make a HTTP request .
// Create AuthCache instance // Generate BASIC scheme object and add it to the local auth cache // Add AuthCache to the execution context