You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by John-M Baker <jo...@db.com> on 2008/03/03 11:40:36 UTC

Rampart and CXF

Hi,

Does CXF easily support Rampart security? I.e. is there some sample code 
showing me how to set the authentication credentials?

John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com


---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.

Re: Rampart and CXF

Posted by Daniel Kulp <dk...@apache.org>.
John,

When you call:
 Client cxfClient = ClientProxy.getClient(client);
all you are really doing is pulling out the InvokationHandler and some of 
the settings that it uses from the Java generated proxy.   Thus, by 
modifying  the Client object, you are modifying the "real" object that 
the proxy is using to make the invokation.   So basically, just add your 
interceptors there and then you can discard it.   All calls on your 
proxy (FooService client) go throught the "Client" object and thus any 
interceptors you add.

Dan

On Tuesday 04 March 2008, John-M Baker wrote:
> Hi,
>
> Thanks for your response. Having read the Wiki, I still appear to be
> missing something:
>
> FooService client = ... ; // created from ClientProxyFactoryBean or
> generated JAX-WS client
> MyInterceptor myInterceptor = new MyInterceptor();
>
> Client cxfClient = ClientProxy.getClient(client);
> cxfClient.getInInterceptor().add(myInterceptor);
>
> What do I do with cxfClient? How do I make a call on FooService
> (client) and invoke the interceptor? I'm assuming the call is made
> through Client. Does it really involve the invoke methods on Client? I
> think that by adding an example call to the end fo that code sample,
> the Wiki would make a little more sense.
>
>
> John Baker



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: Rampart and CXF

Posted by John-M Baker <jo...@db.com>.
That's great, So can I recommend a little extra documentation on the Wiki?

"Despite this looking a little strange the Client does X and hence you add 
these extra lines and carry on working as normal".

Thanks!


John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




Ian Roberts <i....@dcs.shef.ac.uk> 
04/03/2008 16:01
Please respond to
cxf-user@incubator.apache.org


To
cxf-user@incubator.apache.org
cc

Subject
Re: Rampart and CXF






John-M Baker wrote:
> So, are you suggesting I use qPort as follows:
> 
> qPort.myWSMethod() ?
> 
> That seems bizarre. Surely I need to do something else?

Nope, it really is that simple.  The qPort is just a JDK dynamic proxy 
that uses the Client under the covers to do its job.

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK



---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.

Re: Rampart and CXF

Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
John-M Baker wrote:
> So, are you suggesting I use qPort as follows:
> 
> qPort.myWSMethod() ?
> 
> That seems bizarre. Surely I need to do something else?

Nope, it really is that simple.  The qPort is just a JDK dynamic proxy 
that uses the Client under the covers to do its job.

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK

Re: Rampart and CXF

Posted by John-M Baker <jo...@db.com>.
I'm now totally confused :-) To recap, I've got a perfectly satisfactory 
solution when WSSecurity is not required. I've used the wsdl2java ant task 
to create a set of sources. My requirement is to implement WSSecurity so 
it is there when required:

Here's the code I'm fiddling with to try and add WSSecurity support:

  Query q = new Query(url);
  qPort = q.getQueryHttpport();

  Client cxfClient = ClientProxy.getClient(qPort);
  cxfClient.getInInterceptors().add(new SAAJOutInterceptor());
  cxfClient.getInInterceptors().add(createWss4jInConfiguration("myuser", 
"moo")); // This just creates a callback handler

So, are you suggesting I use qPort as follows:

qPort.myWSMethod() ?

That seems bizarre. Surely I need to do something else?


John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




Willem Jiang <wi...@gmail.com> 
04/03/2008 15:20
Please respond to
cxf-user@incubator.apache.org


To
cxf-user@incubator.apache.org
cc

Subject
Re: Rampart and CXF






Hi,

You just use the FooService (client) as usual. The cxfClient will build 
up the interceptors each time before it send out the message when you 
invoke the client proxy method.
I will update the wiki as you suggested.

BTW,  You could also add the interceptor through the 
ClientProxyFactoryBean by calling
clientProxyFactoryBean.getInInterceptor().add(myInterceptor);

Willem.

John-M Baker wrote:
> Hi,
>
> Thanks for your response. Having read the Wiki, I still appear to be 
> missing something:
>
> FooService client = ... ; // created from ClientProxyFactoryBean or 
> generated JAX-WS client
> MyInterceptor myInterceptor = new MyInterceptor();
>
> Client cxfClient = ClientProxy.getClient(client);
> cxfClient.getInInterceptor().add(myInterceptor);
>
> What do I do with cxfClient? How do I make a call on FooService (client) 

> and invoke the interceptor? I'm assuming the call is made through 
Client. 
> Does it really involve the invoke methods on Client? I think that by 
> adding an example call to the end fo that code sample, the Wiki would 
make 
> a little more sense.
>
>
> John Baker
> 




---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.

Re: Rampart and CXF

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

You just use the FooService (client) as usual. The cxfClient will build 
up the interceptors each time before it send out the message when you 
invoke the client proxy method.
I will update the wiki as you suggested.

BTW,  You could also add the interceptor through the  
ClientProxyFactoryBean by calling
clientProxyFactoryBean.getInInterceptor().add(myInterceptor);

Willem.

John-M Baker wrote:
> Hi,
>
> Thanks for your response. Having read the Wiki, I still appear to be 
> missing something:
>
> FooService client = ... ; // created from ClientProxyFactoryBean or 
> generated JAX-WS client
> MyInterceptor myInterceptor = new MyInterceptor();
>
> Client cxfClient = ClientProxy.getClient(client);
> cxfClient.getInInterceptor().add(myInterceptor);
>
> What do I do with cxfClient? How do I make a call on FooService (client) 
> and invoke the interceptor? I'm assuming the call is made through Client. 
> Does it really involve the invoke methods on Client? I think that by 
> adding an example call to the end fo that code sample, the Wiki would make 
> a little more sense.
>
>
> John Baker
>   


Re: Rampart and CXF

Posted by John-M Baker <jo...@db.com>.
Hi,

Thanks for your response. Having read the Wiki, I still appear to be 
missing something:

FooService client = ... ; // created from ClientProxyFactoryBean or 
generated JAX-WS client
MyInterceptor myInterceptor = new MyInterceptor();

Client cxfClient = ClientProxy.getClient(client);
cxfClient.getInInterceptor().add(myInterceptor);

What do I do with cxfClient? How do I make a call on FooService (client) 
and invoke the interceptor? I'm assuming the call is made through Client. 
Does it really involve the invoke methods on Client? I think that by 
adding an example call to the end fo that code sample, the Wiki would make 
a little more sense.


John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




Willem Jiang <wi...@gmail.com> 
04/03/2008 14:22
Please respond to
cxf-user@incubator.apache.org


To
cxf-user@incubator.apache.org
cc

Subject
Re: Rampart and CXF






Hi ,

You can find some programmatical ways to add the interceptors here [1]

[1] http://cwiki.apache.org/CXF20DOC/interceptors.html

Willem

John-M Baker wrote:
> Hello,
>
> While I'm a fan of Spring, I need to write an example that does not use 
> Spring. So I've got this far:
>
> protected WSS4JOutInterceptor createWss4jInConfiguration(String user, 
> String password)
> {
>   Map<String,Object> props = new HashMap<String,Object>();
>   props.put("action", "UsernameToken Timestamp");
>   props.put("passwordType", "PasswordDigest");
>   props.put("user", user);
>   props.put("passwordCallback", new 
MyPasswordCallbackHandler(password));
>   return new WSS4JOutInterceptor(props);
> }
>
> List interceptors = new ArrayList();
> interceptors.add(new SAAJOutInterceptor());
> interceptors.add(createWss4jInConfiguration("jbaker", "moo"));
>
> How do I add the interceptors to the stub generated by CXF? ..e. I have:
>
>       Query q = new Query(url);
>       qPort = q.getQueryHttpport();
>
> And I guess the interceptors need to be attached, somehow.
>
> Thanks,
>
>
> John Baker
> 




---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.

Re: Rampart and CXF

Posted by Willem Jiang <wi...@gmail.com>.
Hi ,

You can find some programmatical ways to add the interceptors here [1]

[1] http://cwiki.apache.org/CXF20DOC/interceptors.html

Willem

John-M Baker wrote:
> Hello,
>
> While I'm a fan of Spring, I need to write an example that does not use 
> Spring. So I've got this far:
>
> protected WSS4JOutInterceptor createWss4jInConfiguration(String user, 
> String password)
> {
>   Map<String,Object> props = new HashMap<String,Object>();
>   props.put("action", "UsernameToken Timestamp");
>   props.put("passwordType", "PasswordDigest");
>   props.put("user", user);
>   props.put("passwordCallback", new MyPasswordCallbackHandler(password));
>   return new WSS4JOutInterceptor(props);
> }
>
> List interceptors = new ArrayList();
> interceptors.add(new SAAJOutInterceptor());
> interceptors.add(createWss4jInConfiguration("jbaker", "moo"));
>
> How do I add the interceptors to the stub generated by CXF? ..e. I have:
>
>       Query q = new Query(url);
>       qPort = q.getQueryHttpport();
>
> And I guess the interceptors need to be attached, somehow.
>
> Thanks,
>
>
> John Baker
>   


Re: Rampart and CXF

Posted by John-M Baker <jo...@db.com>.
Hello,

While I'm a fan of Spring, I need to write an example that does not use 
Spring. So I've got this far:

protected WSS4JOutInterceptor createWss4jInConfiguration(String user, 
String password)
{
  Map<String,Object> props = new HashMap<String,Object>();
  props.put("action", "UsernameToken Timestamp");
  props.put("passwordType", "PasswordDigest");
  props.put("user", user);
  props.put("passwordCallback", new MyPasswordCallbackHandler(password));
  return new WSS4JOutInterceptor(props);
}

List interceptors = new ArrayList();
interceptors.add(new SAAJOutInterceptor());
interceptors.add(createWss4jInConfiguration("jbaker", "moo"));

How do I add the interceptors to the stub generated by CXF? ..e. I have:

      Query q = new Query(url);
      qPort = q.getQueryHttpport();

And I guess the interceptors need to be attached, somehow.

Thanks,


John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




Daniel Kulp <dk...@apache.org> 
03/03/2008 21:16
Please respond to
cxf-user@incubator.apache.org


To
cxf-user@incubator.apache.org
cc
John-M Baker/ext/dbcom@DBEMEA
Subject
Re: Rampart and CXF







By "rampart security", I assume you mean WS-Security?

If so, there is a good blog entry at:
http://domagojtechtips.blogspot.com/2007/08/cxf-spring-and-ws-security-putting-it.html

and another at:
http://www.lumidant.com/blog/apache-cxf-tutorial-ws-security-with-spring/

Dan


On Monday 03 March 2008, John-M Baker wrote:
> Hi,
>
> Does CXF easily support Rampart security? I.e. is there some sample
> code showing me how to set the authentication credentials?
>
> John Baker



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog



---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.

Re: Rampart and CXF

Posted by John-M Baker <jo...@db.com>.
I do. Great tutorial and am reading now. Thanks.

John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




Daniel Kulp <dk...@apache.org> 
03/03/2008 21:16
Please respond to
cxf-user@incubator.apache.org


To
cxf-user@incubator.apache.org
cc
John-M Baker/ext/dbcom@DBEMEA
Subject
Re: Rampart and CXF







By "rampart security", I assume you mean WS-Security?

If so, there is a good blog entry at:
http://domagojtechtips.blogspot.com/2007/08/cxf-spring-and-ws-security-putting-it.html

and another at:
http://www.lumidant.com/blog/apache-cxf-tutorial-ws-security-with-spring/

Dan


On Monday 03 March 2008, John-M Baker wrote:
> Hi,
>
> Does CXF easily support Rampart security? I.e. is there some sample
> code showing me how to set the authentication credentials?
>
> John Baker



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog



---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.

Re: Rampart and CXF

Posted by Daniel Kulp <dk...@apache.org>.
By "rampart security", I assume you mean WS-Security?

If so, there is a good blog entry at:
http://domagojtechtips.blogspot.com/2007/08/cxf-spring-and-ws-security-putting-it.html
and another at:
http://www.lumidant.com/blog/apache-cxf-tutorial-ws-security-with-spring/

Dan


On Monday 03 March 2008, John-M Baker wrote:
> Hi,
>
> Does CXF easily support Rampart security? I.e. is there some sample
> code showing me how to set the authentication credentials?
>
> John Baker



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog