Java – use webservicetemplate and keystore

Can I configure a web service template using a Java keystore?

Edit I'm looking for a way to configure the keystore location in the spring configuration

Solution

I think you can use keystore Builder programming loading method based on keystore:

http://java.sun.com/j2se/1.5.0/docs/api/java/security/KeyStore.Builder.html#newInstance%28java.lang.String ,%20java. security. KeyStore. ProtectionParameter%29

So maybe a class has a WebService template or extends it, then set the file path of the keystore in the spring configuration and make it an inizing bean (@ postconstruct in spring 3?), Then load the keystore

File f = new File(keyStorePath);
KeyStore.Builder builder = KeyStore.Builder.newInstance("type",provider,file,protection);
KeyStore keystore = builder.getKeyStore();

OK – actually use it with your webservicetemplate. I think it must be based on the keystore callback, as follows: http://static.springsource.org/spring-ws/sites/1.5/reference/html/security.html#d0e4462

Alternatively, you can use spring. Org springframework. ws. transport. http. Httpsurlconnectionmessagesender, you can set keystoremanager It can then be used by your web service template

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>

HTH

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>