Scobal Scobal - 1 year ago 430
Java Question

Using WebServiceTemplate with a keystore

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

Answer Source

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:

Or maybe by using the spring which you can set keystoremanager on. Then that can be used by your webservicetemplate.

A bit like this:

<bean id="template" class="">
    <property name="messageSender">
        <bean class="">
            <property name=""></property>


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download