Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 547FB99CE for ; Tue, 21 May 2013 09:29:20 +0000 (UTC) Received: (qmail 17876 invoked by uid 500); 21 May 2013 09:29:19 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 17345 invoked by uid 500); 21 May 2013 09:29:17 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 17250 invoked by uid 99); 21 May 2013 09:29:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 May 2013 09:29:15 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of namasrihari@gmail.com designates 209.85.220.179 as permitted sender) Received: from [209.85.220.179] (HELO mail-vc0-f179.google.com) (209.85.220.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 May 2013 09:29:06 +0000 Received: by mail-vc0-f179.google.com with SMTP id hz10so243986vcb.38 for ; Tue, 21 May 2013 02:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=8VtS6i/XXvwmPrai1DLQRdaQGDrQs7JBk3uA9HqsAAg=; b=AfGj8M0EgUP09dUypVsMlLEhd+DQP58iciAg+/IumhBgU2Giuneyto9/Iy+f3h9wFR ZaBa47BYjdfaPIoJiz87gJDZJwCifcU0XvsKpkRsG3k1LJD02j5osAfxKpHWd0CnDTuk //PVHrLSedZINDOE+Ho3RKwRZ90FWHrVQVSN9ahbkcizJkg5wpovz9vlCjXFjLkP6/OQ yiPC22mjpkGaDuvx65bBH7F/lAvaown73cJmfNTifCkNGgleg7eYiFYqwxQ43BO8akPQ EkRM4wdVNLAUU9K5tdZec1dat/5DjDdIYMnwQFZqDbvAWercRR7irEXHV9seV6Nuq3rG RtEA== MIME-Version: 1.0 X-Received: by 10.220.105.9 with SMTP id r9mr534879vco.60.1369128525836; Tue, 21 May 2013 02:28:45 -0700 (PDT) Received: by 10.220.48.202 with HTTP; Tue, 21 May 2013 02:28:45 -0700 (PDT) Date: Tue, 21 May 2013 14:58:45 +0530 Message-ID: Subject: Target server digest authentication fails with Proxy Basic auth From: srihari na To: httpclient-users@hc.apache.org Content-Type: multipart/alternative; boundary=089e01229c126f3c1504dd371349 X-Virus-Checked: Checked by ClamAV on apache.org --089e01229c126f3c1504dd371349 Content-Type: text/plain; charset=ISO-8859-1 Hi Folks, We are trying to do HTTPGet on a target server enabled with Digest authentication. It works perfectly fine, however when proxy with basic authentication is introduced target authentication is failing. We are using IBM JDK, HTTP Client 4.2.5. Has anybody faced similar issues and knows a fix to it? Code: HttpHost proxy = new HttpHost(proxyHost, 808); HttpHost target = new HttpHost(targetHost, 80); HttpGet req = new HttpGet("/default.asp"); Credentials targetCredentials = new UsernamePasswordCredentials(targetUser, targetpassword); Credentials proxyCredentials = new UsernamePasswordCredentials(proxyUser, proxyPassword); DefaultHttpClient httpclient = null; try { final PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(); httpclient = new DefaultHttpClient(connectionManager); HttpContext localContext = new BasicHttpContext(); req.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); System.out.println("executing request to " + target + " via " + proxy); httpclient.getCredentialsProvider().setCredentials(new AuthScope(proxy), proxyCredentials); httpclient.getCredentialsProvider().setCredentials(new AuthScope(target), targetCredentials); HttpResponse rsp = httpclient.execute(target, req,localContext); AuthState proxyAuthState = (AuthState) localContext.getAttribute(ClientContext.PROXY_AUTH_STATE); System.out.println("Proxy auth state: " + proxyAuthState.getState()); System.out.println("Proxy auth scheme: " + proxyAuthState.getAuthScheme()); System.out.println("Proxy auth credentials: " + proxyAuthState.getCredentials()); AuthState targetAuthState = (AuthState) localContext.getAttribute(ClientContext.TARGET_AUTH_STATE); System.out.println("Target auth state: " + targetAuthState.getState()); System.out.println("Target auth scheme: " + targetAuthState.getAuthScheme()); System.out.println("Target auth credentials: " + targetAuthState.getCredentials()); HttpEntity entity = rsp.getEntity(); if (entity != null) { System.out.println(EntityUtils.toString(entity)); } }catch (Exception e) { } finally { httpclient.getConnectionManager().shutdown(); } } -- Regards, Srihari NA --089e01229c126f3c1504dd371349--