Is it possible to configure a WebServiceTemplate with a java keystore?
I'm looking for a way to configure the location of the keystore in the spring config
I think you can programatically load a keystore based using a KeyStore.Builder:
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"> <property name="messageSender"> <bean class="org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender"> <property name=""></property> </bean> </property> </bean>