wood burning stoves 2.0*
The moose likes Web Services and the fly likes Jax-ws and setting the keystore programmatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Jax-ws and setting the keystore programmatically" Watch "Jax-ws and setting the keystore programmatically" New topic
Author

Jax-ws and setting the keystore programmatically

John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83

I am developing a web service client which is required to set the keystore programmatically.
I was given a private key, which I converted to a keystore.

If I do this:



then the web service calls work.

However, what I need to do is this:




where keystore and password are strings pointing to the appropriate file/password.

But this always gives me a handshake error.

I am trying to think of a way to confirm that this socket factory is even being called.

Any ideas?




John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83

Something indicative.

I replaced


with



And saw that the dummy calls in TestSocketFactory do not get called.

It looks like jax-ws ignores the JAXWSProperties.SSL_SOCKET_FACTORY setting completely.

surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

One question, what document/article/book did you use as an example to build this?
Kesava Krishna
Ranch Hand

Joined: Sep 03, 2012
Posts: 42
Please try using cxf framework, which will take care of all the complex code. You need to use a configuration file in cxf where you can set the keystore file path and pwd and small code snippet, which will take care of adding certificate to request message

Thanks,
Kesava
John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83
surlac surlacovich wrote:One question, what document/article/book did you use as an example to build this?


I used this:

stack overflow reference
John Farrel
Ranch Hand

Joined: May 24, 2010
Posts: 83
Kesava Krishna wrote:Please try using cxf framework, which will take care of all the complex code. You need to use a configuration file in cxf where you can set the keystore file path and pwd and small code snippet, which will take care of adding certificate to request message

Thanks,
Kesava


I'm not sure how to progress from having written a jax-ws client library to using cxf (which appears to use jax-ws underneath).
The documentation seems to say that you develop a cxf client interface the way I already have... basically using wsdl2java on a wsdl.

Can I attach cxf configuration to my existing library?

surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

John Farrel wrote:
I'm not sure how to progress from having written a jax-ws client library to using cxf (which appears to use jax-ws underneath).
...
Can I attach cxf configuration to my existing library?

Yes, you can, but it's not necessary on the client - you can use Apache HTTP-Client or CXF WebClient to communicate with any web-service via HTTPS.

Good example HTTPS+CXF.
Kesava Krishna
Ranch Hand

Joined: Sep 03, 2012
Posts: 42
Please go through this link till the end http://cxf.apache.org/docs/ws-security.html which will clearly explains how to attach certificate to soap request message. This is applicable for jax-ws soap request, and not for jax-rs plain xml request.


Thanks,
Kesava
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Kesava Krishna wrote:This is applicable for jax-ws soap request, and not for jax-rs plain xml request.

Could you please tell us why we can't transfer public key (cert) via jax-rs plain xml request?
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

It should be possible by just attaching a binary (in base64 or something)?
Kesava Krishna
Ranch Hand

Joined: Sep 03, 2012
Posts: 42
Assuming it is purely purely jax-ws based web service it is suggested.

Thanks,
Kesava
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Thanks, Kesava
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jax-ws and setting the keystore programmatically
 
Similar Threads
Certification problems
JAX-WS - understanding BindingProvider
web service security issue
The server sent HTTP status code -1
This SSL code runs... but does it provide security?