You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Al Grant <bi...@gmail.com> on 2018/02/02 00:00:02 UTC

Client not sending proxy credentials

Hi All,

I am trying to get my https client to get out through our proxy.

I have configured the connection as outlined below but apparently no
credentials are being sent to our proxy so I must be doing something wrong:

        org.apache.cxf.endpoint.Client client =
org.apache.cxf.frontend.ClientProxy.getClient(irsiService);
        org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

        cxfEndpoint.getOutInterceptors().add(loi);
        cxfEndpoint.getInInterceptors().add(lii);

        HTTPConduit http = (HTTPConduit) client.getConduit();
        http.getClient().setProxyServer("webproxy.sales.com.au");
        http.getClient().setProxyServerPort(8080);
        http.getProxyAuthorization().setUserName("username");
        http.getProxyAuthorization().setPassword("password");

        http.setTlsClientParameters(tlsParams);

         // SEND DATA
        response = irsiService.setSale(request);
        System.out.println(response.isSuccess());
        System.out.println("Sent");
        System.out.println("Sale ID: " +response.getSaleId());

Any suggestions?

Cheers

A



--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Re: Client not sending proxy credentials

Posted by Al Grant <bi...@gmail.com>.
Thanks.

So far I can't see how you set a username and password for a Proxy using
that method?



--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Re: Client not sending proxy credentials

Posted by Al Grant <bi...@gmail.com>.
Thanks - yes it actually goes with this but I have to be very patient.

For some reason it sits there trying to send the message for 10 minutes
before it actually gets to send anything.

It might be something to do with OCSP since i am using mutual TLS - unless
anyone here has other ideas?

Cheers

AG




--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Re: Client not sending proxy credentials

Posted by Colm O hEigeartaigh <co...@apache.org>.
On Sun, Feb 11, 2018 at 11:51 PM, Al Grant <bi...@gmail.com> wrote:

>
>             http.setAuthorization(auth);
>

This should be: http.setProxyAuthorization(auth);

Colm.



>             http.setClient(policy);
>         }
>
>         http.setTlsClientParameters(tlsParams);
>
>         // SEND DATA
>         response = isalesService.setSale(request);
>
>
> Cheers
>
> AG
>
>
>
>
>
> --
> Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Re: Client not sending proxy credentials

Posted by Al Grant <bi...@gmail.com>.
Even if i could work out which way to set proxy would be good.

METHOD ONE:

https://stackoverflow.com/questions/31550064/apache-cxf-client-proxy-settings

Proxy is set with : http.getClient().setProxyServer("proxy");

I note the example code also has instantiated HelloPortType helloPort =
cliente.getHelloPort(); - I dont have a HelloPortType class for my service
which was generated from WSDL.

METHOD TWO:

https://github.com/apache/cxf/blob/master/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPProxyConduitTest.java

They set proxy with pol.setProxyServer("localhost"); 

where pol is a HttpClientPolicy.

Are both methods valid? My client seems to contact the correct proxy but
never sends creds.

I am on 3.1.14

Thanks

AG





--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Re: Client not sending proxy credentials

Posted by Al Grant <bi...@gmail.com>.
Hmm, its still not sending creds.

Looking at a few examples online I think I am missing something.

Anyone able to clarify what I am missing?

        HTTPConduit http = (HTTPConduit) client.getConduit();

        if (PROXY) {
            HTTPClientPolicy policy = http.getClient();
            policy.setProxyServer("webproxy.test.au");
            policy.setProxyServerPort(8080);
            policy.setReceiveTimeout(600000);
            ProxyAuthorizationPolicy auth = new ProxyAuthorizationPolicy();
            auth.setUserName(pdf.get("username"));
            auth.setPassword(pdf.get("password"));
            //http.getProxyAuthorization().setUserName(pdf.get("username"));
            //http.getProxyAuthorization().setPassword(pdf.get("password"));
            http.setAuthorization(auth);
            http.setClient(policy);
        }

        http.setTlsClientParameters(tlsParams);

        // SEND DATA
        response = isalesService.setSale(request);


Cheers

AG





--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Re: Client not sending proxy credentials

Posted by Andy McCright <j....@gmail.com>.
Yes, that looks right.

The username and password should be set on the ProxyAuthorizationPolicy -
you can create a new one, set the user/password, and the pass it to the
HTTPConduit.

Good luck!

Andy

On Thu, Feb 1, 2018 at 10:46 PM Al Grant <bi...@gmail.com> wrote:

> Actually just took a second look at your github Andy. More like this
> perhaps:
>
>         HTTPClientPolicy policy = http.getClient();
>         policy.setProxyServer("someproxy.enterprise.au");
>         policy.setProxyServerPort(8080);
>         http.getProxyAuthorization().setUserName("username");
>         http.getProxyAuthorization().setPassword("password");
>         http.setClient(policy);
>
> Cheers
>
> AG
>
>
>
>
> --
> Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html
>

Re: Client not sending proxy credentials

Posted by Al Grant <bi...@gmail.com>.
Actually just took a second look at your github Andy. More like this perhaps:

        HTTPClientPolicy policy = http.getClient();
        policy.setProxyServer("someproxy.enterprise.au");
        policy.setProxyServerPort(8080);
        http.getProxyAuthorization().setUserName("username");
        http.getProxyAuthorization().setPassword("password");
        http.setClient(policy);

Cheers

AG




--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Re: Client not sending proxy credentials

Posted by Al Grant <bi...@gmail.com>.
Or like this? (I can't test it now as I have left the site with proxy):

        org.apache.cxf.endpoint.Client client =
org.apache.cxf.frontend.ClientProxy.getClient(iisrService);
        org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

        cxfEndpoint.getOutInterceptors().add(loi);
        cxfEndpoint.getInInterceptors().add(lii);

        HTTPConduit http = (HTTPConduit) client.getConduit();

        HTTPClientPolicy policy = new HTTPClientPolicy();
        policy.setProxyServer("someproxy.enterprise.au");
        policy.setProxyServerPort(8080);
        http.getProxyAuthorization().setUserName("username");
        http.getProxyAuthorization().setPassword("password");
        http.setClient(policy);

        http.setTlsClientParameters(tlsParams);



--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Re: Client not sending proxy credentials

Posted by Andy McCright <j....@gmail.com>.
Hi Al,

Take a look at what we do in Liberty to configure client proxy
authentication:
https://github.com/OpenLiberty/open-liberty/blob/integration/dev/com.ibm.ws.jaxrs.2.0.client/src/com/ibm/ws/jaxrs20/client/configuration/LibertyJaxRsClientProxyInterceptor.java

The main difference as I see it is that we use the HTTPClientPolicy (that
you get from the HTTPConduit) to set things like the proxy host/port/etc.
and the ProxyAuthorizationPolicy for the username/password.

Hope this helps,

Andy

On Thu, Feb 1, 2018 at 6:00 PM, Al Grant <bi...@gmail.com> wrote:

> Hi All,
>
> I am trying to get my https client to get out through our proxy.
>
> I have configured the connection as outlined below but apparently no
> credentials are being sent to our proxy so I must be doing something wrong:
>
>         org.apache.cxf.endpoint.Client client =
> org.apache.cxf.frontend.ClientProxy.getClient(irsiService);
>         org.apache.cxf.endpoint.Endpoint cxfEndpoint =
> client.getEndpoint();
>
>         cxfEndpoint.getOutInterceptors().add(loi);
>         cxfEndpoint.getInInterceptors().add(lii);
>
>         HTTPConduit http = (HTTPConduit) client.getConduit();
>         http.getClient().setProxyServer("webproxy.sales.com.au");
>         http.getClient().setProxyServerPort(8080);
>         http.getProxyAuthorization().setUserName("username");
>         http.getProxyAuthorization().setPassword("password");
>
>         http.setTlsClientParameters(tlsParams);
>
>          // SEND DATA
>         response = irsiService.setSale(request);
>         System.out.println(response.isSuccess());
>         System.out.println("Sent");
>         System.out.println("Sale ID: " +response.getSaleId());
>
> Any suggestions?
>
> Cheers
>
> A
>
>
>
> --
> Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html
>