You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Pauline CANTALOUP <Pa...@123multimedia.com> on 2005/05/30 14:24:48 UTC

[HTTPClient] Problems to connect to a proxy

Hello

I have to connect to a proxy in order to reach a website. So I wrote :
        try {
            HttpClient client = new HttpClient();
            HostConfiguration hostConfig=new HostConfiguration();
            hostConfig.setProxy("192.168.10.225",8888);
            client.setHostConfiguration(hostConfig);

            NTCredentials ntc=new
NTCredentials("user","pass","pc-cantaloup","tls");
            client.getState().setProxyCredentials(AuthScope.ANY,ntc);
            GetMethod method = new GetMethod(url);
            method.setFollowRedirects(true);

            // Execute the GET method
            int statusCode = client.executeMethod(method);
            if (statusCode != -1) {
                String contents = method.getResponseBodyAsString();
                method.releaseConnection();
                System.out.println(contents);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
In traces, I readed : "INFO: ntlm authentication scheme selected" so I
supposed the library choose the authentication type by itself. But then I
have this error :

30 mai 2005 14:02:04 org.apache.commons.httpclient.HttpMethodDirector
processProxyAuthChallenge
INFO: Failure authenticating with NTLM <any realm>@192.168.10.225:8888

I thought it was perhaps a problem of encryption so I added :

        try {
        String secProviderName = "com.sun.crypto.provider.SunJCE";
        java.security.Provider secProvider = 
 
(java.security.Provider)Class.forName(secProviderName).newInstance();
        Security.addProvider(secProvider);
        }catch(Exception e) {
            e.printStackTrace();
        }

But nothing changed. The man who manages proxy said he didn't see my request
for authentication. 
So what could I try ?
Thanks in advance for your help !

Pauline Cantaloup
--
123 Multimédia
Service mobilité
05.61.43.16.68 


Décharge / Disclaimer 

Ce message et toutes les pièces jointes (ci-après le "message") sont confidentiels et établis à l'intention exclusive des destinataires. Toute utilisation ou diffusion non autorisée est interdite. Tout message électronique étant susceptible d'altération, 123Multimédia et ses filiales déclinent toute responsabilité au titre de ce message s'il a été altéré, déformé ou falsifié.

This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Therefore neither 123Multimédia nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [HTTPClient] Problems to connect to a proxy

Posted by Oleg Kalnichevski <ol...@apache.org>.
Pauline,

Please post the complete wire/context log of the HTTP session.

http://jakarta.apache.org/commons/httpclient/3.0/logging.html

Oleg

On Mon, May 30, 2005 at 02:24:48PM +0200, Pauline CANTALOUP wrote:
> Hello
> 
> I have to connect to a proxy in order to reach a website. So I wrote :
>         try {
>             HttpClient client = new HttpClient();
>             HostConfiguration hostConfig=new HostConfiguration();
>             hostConfig.setProxy("192.168.10.225",8888);
>             client.setHostConfiguration(hostConfig);
> 
>             NTCredentials ntc=new
> NTCredentials("user","pass","pc-cantaloup","tls");
>             client.getState().setProxyCredentials(AuthScope.ANY,ntc);
>             GetMethod method = new GetMethod(url);
>             method.setFollowRedirects(true);
> 
>             // Execute the GET method
>             int statusCode = client.executeMethod(method);
>             if (statusCode != -1) {
>                 String contents = method.getResponseBodyAsString();
>                 method.releaseConnection();
>                 System.out.println(contents);
>             }
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
> In traces, I readed : "INFO: ntlm authentication scheme selected" so I
> supposed the library choose the authentication type by itself. But then I
> have this error :
> 
> 30 mai 2005 14:02:04 org.apache.commons.httpclient.HttpMethodDirector
> processProxyAuthChallenge
> INFO: Failure authenticating with NTLM <any realm>@192.168.10.225:8888
> 
> I thought it was perhaps a problem of encryption so I added :
> 
>         try {
>         String secProviderName = "com.sun.crypto.provider.SunJCE";
>         java.security.Provider secProvider = 
>  
> (java.security.Provider)Class.forName(secProviderName).newInstance();
>         Security.addProvider(secProvider);
>         }catch(Exception e) {
>             e.printStackTrace();
>         }
> 
> But nothing changed. The man who manages proxy said he didn't see my request
> for authentication. 
> So what could I try ?
> Thanks in advance for your help !
> 
> Pauline Cantaloup
> --
> 123 Multim?dia
> Service mobilit?
> 05.61.43.16.68 
> 
> 
> D?charge / Disclaimer
> 
> Ce message et toutes les pi?ces jointes (ci-apr?s le "message") sont confidentiels et ?tablis ? l'intention exclusive des destinataires. Toute utilisation ou diffusion non autoris?e est interdite. Tout message ?lectronique ?tant susceptible d'alt?ration,
> 
> This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Therefore neither 123Multim?dia nor any of its subsidiari
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org