You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by SaravananRamamoorthy <sa...@gmail.com> on 2010/02/01 16:37:06 UTC

basic authentication in cxf webservice client

Hi All,

I have generated webservice client using cxf wsdl2java.

The webservice requires basic authentication.

How do I pass basic authenticatin to webservice client using cxf.

Can we use BindingProvider class for this.

Regards
Saravanan R
-- 
View this message in context: http://old.nabble.com/basic-authentication-in-cxf-webservice-client-tp27406176p27406176.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: basic authentication in cxf webservice client

Posted by Ash Ashkj <ja...@gmail.com>.
Hi Andrei,

Thanks very much for your assistance. It works.
I really appreciate your time and help.

Many thanks,
Ashwini


On Tue, Sep 24, 2013 at 8:38 AM, Andrei Shakirin <as...@talend.com>wrote:

>  Hi,****
>
> ** **
>
> You can do it for example this way:****
>
> ** **
>
>         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();****
>
>         factory.setAddress("http://localhost:9000/CustomerService");****
>
>         CustomerService customerClient =
> factory.create(CustomerService.class);****
>
>         Client client = ClientProxy.getClient(customerClient);****
>
> ** **
>
>         HTTPConduit http =  (HTTPConduit) client.getConduit();****
>
>         AuthorizationPolicy authPolicy = new AuthorizationPolicy();****
>
>         authPolicy.setAuthorizationType("Digest");****
>
>         authPolicy.setUserName("foo");****
>
>         authPolicy.setPassword("bar");****
>
>         http.setAuthorization(authPolicy);****
>
>        …****
>
> ** **
>
> Regards,****
>
> Andrei.****
>
> ** **
>
> *From:* Ash Ashkj [mailto:jainashwini@gmail.com <ja...@gmail.com>]
> *Sent:* Sonntag, 22. September 2013 18:20
> *To:* Andrei Shakirin
> *Cc:* users@cxf.apache.org
>
> *Subject:* Re: basic authentication in cxf webservice client****
>
>  ** **
>
> Thanks very much Andrei!****
>
> How do I implement similar test using JaxWsProxyFactoryBean ?****
>
> I have implemented basic,x509 message level and transfer-layer level auth
> using JaxWsProxyFactoryBean but not getting any clue about digest auth.***
> *
>
> ** **
>
> Many Thanks,****
>
> Ash****
>
> ** **
>
> On Sun, Sep 22, 2013 at 4:45 PM, Andrei Shakirin <as...@talend.com>
> wrote:****
>
> Hi,
>
> You can take following system test as a basis:
> https://svn.apache.org/repos/asf/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthTest.java
>
> Regards,
> Andrei.
>
> > -----Original Message-----
> > From: ash [mailto:jainashwini@gmail.com]
> > Sent: Sonntag, 22. September 2013 01:41
> > To: users@cxf.apache.org
> > Subject: Re: basic authentication in cxf webservice client
> >
> > How do I setup digest auth type to webservice client using cxf?
> >****
>
> ** **
>

RE: basic authentication in cxf webservice client

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

You can do it for example this way:

        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setAddress("http://localhost:9000/CustomerService");
        CustomerService customerClient = factory.create(CustomerService.class);
        Client client = ClientProxy.getClient(customerClient);

        HTTPConduit http =  (HTTPConduit) client.getConduit();
        AuthorizationPolicy authPolicy = new AuthorizationPolicy();
        authPolicy.setAuthorizationType("Digest");
        authPolicy.setUserName("foo");
        authPolicy.setPassword("bar");
        http.setAuthorization(authPolicy);
       ...

Regards,
Andrei.

From: Ash Ashkj [mailto:jainashwini@gmail.com]
Sent: Sonntag, 22. September 2013 18:20
To: Andrei Shakirin
Cc: users@cxf.apache.org<ma...@cxf.apache.org>
Subject: Re: basic authentication in cxf webservice client

Thanks very much Andrei!
How do I implement similar test using JaxWsProxyFactoryBean ?
I have implemented basic,x509 message level and transfer-layer level auth using JaxWsProxyFactoryBean but not getting any clue about digest auth.

Many Thanks,
Ash

On Sun, Sep 22, 2013 at 4:45 PM, Andrei Shakirin <as...@talend.com>> wrote:
Hi,

You can take following system test as a basis: https://svn.apache.org/repos/asf/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthTest.java

Regards,
Andrei.

> -----Original Message-----
> From: ash [mailto:jainashwini@gmail.com<ma...@gmail.com>]
> Sent: Sonntag, 22. September 2013 01:41
> To: users@cxf.apache.org<ma...@cxf.apache.org>
> Subject: Re: basic authentication in cxf webservice client
>
> How do I setup digest auth type to webservice client using cxf?
>


RE: basic authentication in cxf webservice client

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

You can take following system test as a basis: https://svn.apache.org/repos/asf/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthTest.java

Regards,
Andrei.

> -----Original Message-----
> From: ash [mailto:jainashwini@gmail.com]
> Sent: Sonntag, 22. September 2013 01:41
> To: users@cxf.apache.org
> Subject: Re: basic authentication in cxf webservice client
> 
> How do I setup digest auth type to webservice client using cxf?
> 


Re: basic authentication in cxf webservice client

Posted by ash <ja...@gmail.com>.
How do I setup digest auth type to webservice client using cxf?



Re: basic authentication in cxf webservice client

Posted by KnutIvar <kn...@gmail.com>.
The wsport is generated from the wsdl with wsdl2java (cxf codegen plugin)
using jaxb databinding... and the rest is in the previously mentioned code
block... just juse the client generated by the factory, and you have all
methods available.



SaravananRamamoorthy wrote:
> 
> Hi KnutIvar,
> 
> Thanks for your reply.
> 
> This would be really helpful if we are using JAX-WS web service client and
> publish the endpoint through the JaxWsProxyFactoryBean class.
> 
> Can we get the domain i.e realms using the above said class.
> 
> 
> Please suggest me and provide your inputs.
> 
> Regards
> SaravananRamamoorthy
> 
> 
> KnutIvar wrote:
>> 
>> I'm not sure this will help, but If you're using the
>> JaxWsProxyFactoryBean, you might add username/password directly to it...
>> (however, I'm not sure it's http basic security..., but I think so...);
>> 
>> org.apache.cxf.jaxws.JaxWsProxyFactoryBean clientFactory =
>> JaxWsProxyFactoryBean();            
>> clientFactory.setAddress("http://localhost:8088/someservice");
>> clientFactory.setServiceClass(SomeServiceSessionWSPort.class);
>> clientFactory.setUsername("username");
>> clientFactory.setPassword("password");
>> SomeServiceSessionWSPort client =
>> (JVTOrderManagementSessionWSPort)clientFactory.create();
>> 
>> 
>> 
>> SaravananRamamoorthy wrote:
>>> 
>>> Hi Dan,
>>> 
>>> Thanks for your suggestion and reply.
>>> I am also using JAX RS and from that I would call the cxf webservice
>>> client.
>>> Now how do I pass the basic Http Authentication from JAX RS to the cxf
>>> webservice client.
>>> 
>>> Thanks in advance.
>>> 
>>> Regards
>>> Saravanan R
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> dkulp wrote:
>>>> 
>>>> On Mon February 1 2010 10:37:06 am SaravananRamamoorthy wrote:
>>>>> Hi All,
>>>>> 
>>>>> I have generated webservice client using cxf wsdl2java.
>>>>> 
>>>>> The webservice requires basic authentication.
>>>>> 
>>>>> How do I pass basic authenticatin to webservice client using cxf.
>>>>> 
>>>>> Can we use BindingProvider class for this.
>>>> 
>>>> Yep.   The BindingProvider has keys for both the username and the
>>>> password.   
>>>> Just set those on the RequestContext and it should be all set.
>>>> 
>>>> Dan
>>>> 
>>>> 
>>>>> 
>>>>> Regards
>>>>> Saravanan R
>>>>> 
>>>> 
>>>> -- 
>>>> Daniel Kulp
>>>> dkulp@apache.org
>>>> http://www.dankulp.com/blog
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 


-----
http://www.knutivars.net www.knutivars.net 
"http://www.knutivars.net/cxf/index.html Document first Apache CXF and
XMLBeans with Spring. 
-- 
View this message in context: http://old.nabble.com/basic-authentication-in-cxf-webservice-client-tp27406176p27432702.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: basic authentication in cxf webservice client

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Saravanan,

Sorry. Only noticed the workd 'client' just now. My bad.

Gabo

Gabo Manuel wrote:
> Hi Saravanan,
>
> This article aided me before:
>
> http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication/ 
>
>
> It could easily be adjusted to use Digest instead of Basic. Although 
> afaik Dan has already added a means for CXF to support Digest auth out 
> of the box.
>
> Hth.
>
> Gabo
>
> SaravananRamamoorthy wrote:
>> Hi KnutIvar,
>>
>> Thanks for your reply.
>>
>> This would be really helpful if we are using JAX-WS web service 
>> client and
>> publish the endpoint through the JaxWsProxyFactoryBean class.
>>
>> Here my concern is that we are creating the JAX RS service and need to
>> accept Http Basic Authentication
>> from the client program(I have used SOAPUI for testing the service).
>>
>> Please suggest me and provide your inputs.
>>
>> Regards
>> SaravananRamamoorthy
>>
>>
>>
>>
>> KnutIvar wrote:
>>  
>>> I'm not sure this will help, but If you're using the
>>> JaxWsProxyFactoryBean, you might add username/password directly to 
>>> it...
>>> (however, I'm not sure it's http basic security..., but I think so...);
>>>
>>> org.apache.cxf.jaxws.JaxWsProxyFactoryBean clientFactory =
>>> JaxWsProxyFactoryBean();            
>>> clientFactory.setAddress("http://localhost:8088/someservice");
>>> clientFactory.setServiceClass(SomeServiceSessionWSPort.class);
>>> clientFactory.setUsername("username");
>>> clientFactory.setPassword("password");
>>> SomeServiceSessionWSPort client =
>>> (JVTOrderManagementSessionWSPort)clientFactory.create();
>>>
>>>
>>>
>>> SaravananRamamoorthy wrote:
>>>    
>>>> Hi Dan,
>>>>
>>>> Thanks for your suggestion and reply.
>>>> I am also using JAX RS and from that I would call the cxf webservice
>>>> client.
>>>> Now how do I pass the basic Http Authentication from JAX RS to the cxf
>>>> webservice client.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Regards
>>>> Saravanan R
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> dkulp wrote:
>>>>      
>>>>> On Mon February 1 2010 10:37:06 am SaravananRamamoorthy wrote:
>>>>>        
>>>>>> Hi All,
>>>>>>
>>>>>> I have generated webservice client using cxf wsdl2java.
>>>>>>
>>>>>> The webservice requires basic authentication.
>>>>>>
>>>>>> How do I pass basic authenticatin to webservice client using cxf.
>>>>>>
>>>>>> Can we use BindingProvider class for this.
>>>>>>           
>>>>> Yep.   The BindingProvider has keys for both the username and the
>>>>> password.   Just set those on the RequestContext and it should be 
>>>>> all set.
>>>>>
>>>>> Dan
>>>>>
>>>>>
>>>>>        
>>>>>> Regards
>>>>>> Saravanan R
>>>>>>
>>>>>>           
>>>>> -- 
>>>>> Daniel Kulp
>>>>> dkulp@apache.org
>>>>> http://www.dankulp.com/blog
>>>>>
>>>>>
>>>>>         
>>>>       
>>>     
>>
>>   
>

Re: basic authentication in cxf webservice client

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Saravanan,

This article aided me before:

http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication/

It could easily be adjusted to use Digest instead of Basic. Although 
afaik Dan has already added a means for CXF to support Digest auth out 
of the box.

Hth.

Gabo

SaravananRamamoorthy wrote:
> Hi KnutIvar,
>
> Thanks for your reply.
>
> This would be really helpful if we are using JAX-WS web service client and
> publish the endpoint through the JaxWsProxyFactoryBean class.
>
> Here my concern is that we are creating the JAX RS service and need to
> accept Http Basic Authentication
> from the client program(I have used SOAPUI for testing the service).
>
> Please suggest me and provide your inputs.
>
> Regards
> SaravananRamamoorthy
>
>
>
>
> KnutIvar wrote:
>   
>> I'm not sure this will help, but If you're using the
>> JaxWsProxyFactoryBean, you might add username/password directly to it...
>> (however, I'm not sure it's http basic security..., but I think so...);
>>
>> org.apache.cxf.jaxws.JaxWsProxyFactoryBean clientFactory =
>> JaxWsProxyFactoryBean();            
>> clientFactory.setAddress("http://localhost:8088/someservice");
>> clientFactory.setServiceClass(SomeServiceSessionWSPort.class);
>> clientFactory.setUsername("username");
>> clientFactory.setPassword("password");
>> SomeServiceSessionWSPort client =
>> (JVTOrderManagementSessionWSPort)clientFactory.create();
>>
>>
>>
>> SaravananRamamoorthy wrote:
>>     
>>> Hi Dan,
>>>
>>> Thanks for your suggestion and reply.
>>> I am also using JAX RS and from that I would call the cxf webservice
>>> client.
>>> Now how do I pass the basic Http Authentication from JAX RS to the cxf
>>> webservice client.
>>>
>>> Thanks in advance.
>>>
>>> Regards
>>> Saravanan R
>>>
>>>
>>>
>>>
>>>
>>>
>>> dkulp wrote:
>>>       
>>>> On Mon February 1 2010 10:37:06 am SaravananRamamoorthy wrote:
>>>>         
>>>>> Hi All,
>>>>>
>>>>> I have generated webservice client using cxf wsdl2java.
>>>>>
>>>>> The webservice requires basic authentication.
>>>>>
>>>>> How do I pass basic authenticatin to webservice client using cxf.
>>>>>
>>>>> Can we use BindingProvider class for this.
>>>>>           
>>>> Yep.   The BindingProvider has keys for both the username and the
>>>> password.   
>>>> Just set those on the RequestContext and it should be all set.
>>>>
>>>> Dan
>>>>
>>>>
>>>>         
>>>>> Regards
>>>>> Saravanan R
>>>>>
>>>>>           
>>>> -- 
>>>> Daniel Kulp
>>>> dkulp@apache.org
>>>> http://www.dankulp.com/blog
>>>>
>>>>
>>>>         
>>>       
>>     
>
>   

Re: basic authentication in cxf webservice client

Posted by SaravananRamamoorthy <sa...@gmail.com>.
Hi KnutIvar,

Thanks for your reply.

This would be really helpful if we are using JAX-WS web service client and
publish the endpoint through the JaxWsProxyFactoryBean class.

Here my concern is that we are creating the JAX RS service and need to
accept Http Basic Authentication
from the client program(I have used SOAPUI for testing the service).

Please suggest me and provide your inputs.

Regards
SaravananRamamoorthy




KnutIvar wrote:
> 
> I'm not sure this will help, but If you're using the
> JaxWsProxyFactoryBean, you might add username/password directly to it...
> (however, I'm not sure it's http basic security..., but I think so...);
> 
> org.apache.cxf.jaxws.JaxWsProxyFactoryBean clientFactory =
> JaxWsProxyFactoryBean();            
> clientFactory.setAddress("http://localhost:8088/someservice");
> clientFactory.setServiceClass(SomeServiceSessionWSPort.class);
> clientFactory.setUsername("username");
> clientFactory.setPassword("password");
> SomeServiceSessionWSPort client =
> (JVTOrderManagementSessionWSPort)clientFactory.create();
> 
> 
> 
> SaravananRamamoorthy wrote:
>> 
>> Hi Dan,
>> 
>> Thanks for your suggestion and reply.
>> I am also using JAX RS and from that I would call the cxf webservice
>> client.
>> Now how do I pass the basic Http Authentication from JAX RS to the cxf
>> webservice client.
>> 
>> Thanks in advance.
>> 
>> Regards
>> Saravanan R
>> 
>> 
>> 
>> 
>> 
>> 
>> dkulp wrote:
>>> 
>>> On Mon February 1 2010 10:37:06 am SaravananRamamoorthy wrote:
>>>> Hi All,
>>>> 
>>>> I have generated webservice client using cxf wsdl2java.
>>>> 
>>>> The webservice requires basic authentication.
>>>> 
>>>> How do I pass basic authenticatin to webservice client using cxf.
>>>> 
>>>> Can we use BindingProvider class for this.
>>> 
>>> Yep.   The BindingProvider has keys for both the username and the
>>> password.   
>>> Just set those on the RequestContext and it should be all set.
>>> 
>>> Dan
>>> 
>>> 
>>>> 
>>>> Regards
>>>> Saravanan R
>>>> 
>>> 
>>> -- 
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/basic-authentication-in-cxf-webservice-client-tp27406176p27429196.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: basic authentication in cxf webservice client

Posted by KnutIvar <kn...@gmail.com>.
I'm not sure this will help, but If you're using the JaxWsProxyFactoryBean,
you might add username/password directly to it... (however, I'm not sure
it's http basic security..., but I think so...);

org.apache.cxf.jaxws.JaxWsProxyFactoryBean clientFactory =
JaxWsProxyFactoryBean();            
clientFactory.setAddress("http://localhost:8088/someservice");
clientFactory.setServiceClass(SomeServiceSessionWSPort.class);
clientFactory.setUsername("username");
clientFactory.setPassword("password");
SomeServiceSessionWSPort client =
(JVTOrderManagementSessionWSPort)clientFactory.create();



SaravananRamamoorthy wrote:
> 
> Hi Dan,
> 
> Thanks for your suggestion and reply.
> I am also using JAX RS and from that I would call the cxf webservice
> client.
> Now how do I pass the basic Http Authentication from JAX RS to the cxf
> webservice client.
> 
> Thanks in advance.
> 
> Regards
> Saravanan R
> 
> 
> 
> 
> 
> 
> dkulp wrote:
>> 
>> On Mon February 1 2010 10:37:06 am SaravananRamamoorthy wrote:
>>> Hi All,
>>> 
>>> I have generated webservice client using cxf wsdl2java.
>>> 
>>> The webservice requires basic authentication.
>>> 
>>> How do I pass basic authenticatin to webservice client using cxf.
>>> 
>>> Can we use BindingProvider class for this.
>> 
>> Yep.   The BindingProvider has keys for both the username and the
>> password.   
>> Just set those on the RequestContext and it should be all set.
>> 
>> Dan
>> 
>> 
>>> 
>>> Regards
>>> Saravanan R
>>> 
>> 
>> -- 
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>> 
>> 
> 
> 


-----
http://www.knutivars.net www.knutivars.net 
"http://www.knutivars.net/cxf/index.html Document first Apache CXF and
XMLBeans with Spring. 
-- 
View this message in context: http://old.nabble.com/basic-authentication-in-cxf-webservice-client-tp27406176p27427096.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: basic authentication in cxf webservice client

Posted by SaravananRamamoorthy <sa...@gmail.com>.
Hi Dan,

Thanks for your suggestion and reply.
I am also using JAX RS and from that I would call the cxf webservice client.
Now how do I pass the basic Http Authentication from JAX RS to the cxf
webservice client.

Thanks in advance.

Regards
Saravanan R






dkulp wrote:
> 
> On Mon February 1 2010 10:37:06 am SaravananRamamoorthy wrote:
>> Hi All,
>> 
>> I have generated webservice client using cxf wsdl2java.
>> 
>> The webservice requires basic authentication.
>> 
>> How do I pass basic authenticatin to webservice client using cxf.
>> 
>> Can we use BindingProvider class for this.
> 
> Yep.   The BindingProvider has keys for both the username and the
> password.   
> Just set those on the RequestContext and it should be all set.
> 
> Dan
> 
> 
>> 
>> Regards
>> Saravanan R
>> 
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://old.nabble.com/basic-authentication-in-cxf-webservice-client-tp27406176p27413071.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: basic authentication in cxf webservice client

Posted by Daniel Kulp <dk...@apache.org>.
On Mon February 1 2010 10:37:06 am SaravananRamamoorthy wrote:
> Hi All,
> 
> I have generated webservice client using cxf wsdl2java.
> 
> The webservice requires basic authentication.
> 
> How do I pass basic authenticatin to webservice client using cxf.
> 
> Can we use BindingProvider class for this.

Yep.   The BindingProvider has keys for both the username and the password.   
Just set those on the RequestContext and it should be all set.

Dan


> 
> Regards
> Saravanan R
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog