hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mop Sophia <mopsop...@gmail.com>
Subject Proxy with digest authentication
Date Mon, 11 Apr 2016 16:18:31 GMT
Hi,

I try to do a request using a proxy with digest authentication but the
authentication fails, here is the code :

// Proxy credentials
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope("80.1.2.3", 3128),
        new UsernamePasswordCredentials("proxy_user", "proxy_pass"));
HttpHost proxy = new HttpHost("80.1.2.3", 3128);

CloseableHttpClient httpclient = HttpClients.custom()
        .setSSLSocketFactory(sslsf)
        .setDefaultCredentialsProvider(credsProvider)
        .setProxy(proxy)
        .build();


HttpGet httpget = new HttpGet("https://myhost.com:8443");

HttpClientContext context = HttpClientContext.create();

CloseableHttpResponse resp = httpclient.execute(httpget, context);

Log.d("TST", String.valueOf(resp.getStatusLine()));
Log.d("TST", EntityUtils.toString(resp.getEntity()));

AuthState proxyAuthState = context.getProxyAuthState();
Log.d("TST", "Proxy auth state: " + proxyAuthState.getState());
Log.d("TST", "Proxy auth scheme: " + proxyAuthState.getAuthScheme());
Log.d("TST", "Proxy auth credentials: " + proxyAuthState.getCredentials());
AuthState targetAuthState = context.getTargetAuthState();
Log.d("TST", "Target auth state: " + targetAuthState.getState());
Log.d("TST", "Target auth scheme: " + targetAuthState.getAuthScheme());
Log.d("TST", "Target auth credentials: " + targetAuthState.getCredentials());




Any idea, please ?

Thanks,

St├ęphane

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message