Using WebServiceTemplate with a keystore?

I think you can programatically load a keystore based using a KeyStore. Builder: http://java.sun.com/j2se/1.5.0/docs/api/java/security/KeyStore.Builder.html#newInstance%28java.lang.String,%20java.security.Provider,%20java.io.File,%20java.security.KeyStore.ProtectionParameter%29 So maybe have a class that has a webservice template or extends it, then set the file path of the keystore on it in your spring config and make it an inizialing bean (@PostConstruct in Spring 3? ) which then loads the keystore File f = new File(keyStorePath); KeyStore.

Builder builder = KeyStore.Builder. NewInstance("type",provider,file,protection); KeyStore keystore = builder.getKeyStore() Ok - to actually use it with your webservicetemplate I think it must be based around the keystore callback as documented here: http://static.springsource.org/spring-ws/sites/1.5/reference/html/security.html#d0e4462 Or maybe by using the spring org.springframework.ws.transport.http. HttpsUrlConnectionMessageSender which you can set keystoremanager on.

Then that can be used by your webservicetemplate A bit like this: bean id="template" class="org.springframework.ws.client.core. WebServiceTemplate".

I think you can programatically load a keystore based using a KeyStore. Builder: http://java.sun.com/j2se/1.5.0/docs/api/java/security/KeyStore.Builder.html#newInstance%28java.lang.String,%20java.security.Provider,%20java.io.File,%20java.security.KeyStore.ProtectionParameter%29 So maybe have a class that has a webservice template or extends it, then set the file path of the keystore on it in your spring config and make it an inizialing bean (@PostConstruct in Spring 3? ) which then loads the keystore.

File f = new File(keyStorePath); KeyStore. Builder builder = KeyStore.Builder. NewInstance("type",provider,file,protection); KeyStore keystore = builder.getKeyStore(); Ok - to actually use it with your webservicetemplate I think it must be based around the keystore callback as documented here: http://static.springsource.org/spring-ws/sites/1.5/reference/html/security.html#d0e4462 Or maybe by using the spring org.springframework.ws.transport.http.

HttpsUrlConnectionMessageSender which you can set keystoremanager on. Then that can be used by your webservicetemplate. A bit like this: HTH.

Late reply on this thread but anyway: note that once you have your keystore and everything else set up, you may be shocked to find that the WebServiceTemplate doesn't seem to support HTTPS connections! Make sure you set the messageSender property to be org.springframework.ws.transport.http. CommonsHttpMessageSender.

The default WebServiceMessageSender implementation does not support HTTPS.

You should install the certificates you need in the keystore (probably the cacerts file) of the JDK used to run your app server using they keytool command. Here is an example command: keytool -import -trustcacerts -alias someAlias -file someCert. Crt -keystore yourKeystore Edit: Based on the updated question it looks like this may be what you are looking for: static.springsource.org/spring-ws/sites/....

Taylor L - Thanks, although really I'm looking for a way to configure the location of the keystore in spring. I'll update my question to reflect that. – Scobal Mar 10 '10 at 19:44 Take a look at this: static.springsource.Org/spring-ws/sites/1.5/reference/html/… – Taylor Leese Mar 10 '10 at 20:39 L - Yep, that page is a good reference.

But how would I wire up a WebServiceTemplate with a keystore... – Scobal Mar 11 '10 at 11:32.

I'm assuming you mean you want to configure the keystore used by JSSE, since that is the Template will use. JSSE will always always look at the javax.net.ssl" rel="nofollow">javax.net.ssl. KeyStore/javax.net.ssl" rel="nofollow">javax.net.ssl.

KeyStorePassword system properties to find the keystore. You can configure these properties in Spring using an InitializingBean like this. Note that if you are running in an app server the JSSE may already be configured before Spring initializes.In this case you need to use the app server interface to set the keystore -- usually using -D params on command line.

Public class JsseInitializer implements InitializingBean { private String trustStoreLocation; private String trustStorePassword; private String keyStoreLocation; private String keyStorePassword; public String getTrustStoreLocation() { return trustStoreLocation; } public void setTrustStoreLocation(String trustStoreLocation) { this. TrustStoreLocation = trustStoreLocation; } public String getTrustStorePassword() { return trustStorePassword; } public void setTrustStorePassword(String trustStorePassword) { this. TrustStorePassword = trustStorePassword; } public String getKeyStoreLocation() { return keyStoreLocation; } public void setKeyStoreLocation(String keyStoreLocation) { this.

KeyStoreLocation = keyStoreLocation; } public String getKeyStorePassword() { return keyStorePassword; } public void setKeyStorePassword(String keyStorePassword) { this. KeyStorePassword = keyStorePassword; } public void afterPropertiesSet() throws Exception { System. SetProperty("javax.net.ssl" rel="nofollow">javax.net.ssl.

TrustStore", trustStoreLocation); System. SetProperty("javax.net.ssl" rel="nofollow">javax.net.ssl. TrustStorePassword", trustStorePassword); System.

SetProperty("javax.net.ssl" rel="nofollow">javax.net.ssl. KeyStore", keyStoreLocation); System. SetProperty("javax.net.ssl" rel="nofollow">javax.net.ssl.

KeyStorePassword", keyStorePassword); } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions